|
LCC Fusion Project 1.0
LCC Automation
|
Encapsulates one BSD channel (sense + decision + actuation). More...
#include <BsdSensor.h>
Public Member Functions | |
| BsdSensor (uint8_t index, int sensePin, int gatePin) | |
| Construct a sensor. More... | |
| void | begin (BsdRelay *pRelay) |
| Initialize hardware and internal state. More... | |
| void | update (uint16_t occLow_mA, uint16_t occHigh_mA) |
| Advance the sensor state machine and measurements. More... | |
| SensorState | state () const |
| Current state of the channel. | |
| bool | isShorted () const |
| Returns true when the channel is tripped or lockout (rail disconnected). | |
| bool | isOccupied () const |
Returns true when filtered current exceeds occLow_mA. | |
| float | currentA () const |
Returns the filtered current estimate in Amps (if ADC_REF_V / ACS_SENS are in SI). | |
| void | setState (SensorState s) |
| Set the channel state and actuate outputs accordingly. More... | |
| void | setOccupied (bool occ) |
| Override the occupancy flag (primarily for tests). | |
| void | reset () |
| Clear a fault and return to OK (power path enabled, inrush blanking starts). | |
Private Member Functions | |
| bool | _inInrush (uint32_t now) const |
| True while still in the inrush blanking window. More... | |
| float | _readCurrentA () const |
| Sample ADC three times, average, convert to volts and then Amps. More... | |
Private Attributes | |
| BsdRelay * | pRelay_ = nullptr |
| Optional relay driver attached via. More... | |
| uint16_t | occHigh_mA = 0 |
| Last trip threshold passed to update (see note below). | |
| uint8_t | idx_ = 0 |
| Channel index (informational). | |
| int | sensePin_ = -1 |
| ADC1 input pin for current sense. | |
| int | gatePin_ = -1 |
| MOSFET gate output (HIGH=ON). | |
| float | current_filtered_A_ = 0.0f |
| IIR filtered current (Amps). | |
| uint8_t | retry_stage_ = 0 |
| 0..RETRY_MAX-1 retry stage. | |
| uint32_t | last_sample_ms_ = 0 |
| Last sample timestamp. | |
| uint32_t | unblank_at_ms_ = 0 |
| Timestamp when inrush blanking ENDS. | |
| uint32_t | next_retry_ms_ = 0 |
| Next retry timestamp. | |
| bool | isOccupied_ = false |
| Occupancy flag (spelling kept for compatibility). | |
Encapsulates one BSD channel (sense + decision + actuation).
Typical lifecycle:
Definition at line 73 of file BsdSensor.h.
|
inline |
Construct a sensor.
| index | Channel index (0..7); informational only. |
| sensePin | ADC1 pin connected to the current sensor output. |
| gatePin | Digital output pin that drives the MOSFET gate (HIGH=ON). |
Definition at line 81 of file BsdSensor.h.
|
inlineprivate |
True while still in the inrush blanking window.
| now | Current millis() value. |
Definition at line 262 of file BsdSensor.h.

|
inlineprivate |
Sample ADC three times, average, convert to volts and then Amps.
ADC_REF_V/2 and sensitivity ACS_SENS). Definition at line 270 of file BsdSensor.h.

|
inline |
Initialize hardware and internal state.
Sets gate pin as OUTPUT, initializes state to SensorState OK, zeros filters and timers, and applies an initial inrush blanking window.
| pRelay | Pointer to a BsdRelay.h for this channel (or nullptr to detach). |
Definition at line 95 of file BsdSensor.h.


|
inline |
Set the channel state and actuate outputs accordingly.
When moving to SensorState OK, the power path is enabled and a new inrush blanking window is started. When moving to TRIPPED/LOCKOUT, the power path is disabled and occupancy is cleared.
| s | Desired state. |
Definition at line 194 of file BsdSensor.h.

|
inline |
Advance the sensor state machine and measurements.
Samples current, updates filters, updates occupancy, and manages short/overcurrent detection and retry/lockout behavior.
| occLow_mA | Lower threshold for occupancy detection (below this is unoccupied) |
| occHigh_mA | High threshold for occupancy detection (above this is a short) |
SAMPLE_PERIOD_MS. Definition at line 116 of file BsdSensor.h.

|
private |
Optional relay driver attached via.
Definition at line 224 of file BsdSensor.h.