#include <TLI4971.h>
Public Types | |
| enum | OCDMODE { NONE , INTERRUPT , POLLING } |
| enum | MEASRANGE { FSR120 = 0x05 , FSR100 = 0x06 , FSR75 = 0x08 , FSR50 = 0x0C , FSR37_5 = 0x10 , FSR25 = 0x18 } |
| enum | OPMODE { SD_BID = 0 , FD = 0x1<<5 , SD_UNI = 0x2<<5 , S_ENDED = 0x3<<5 } |
| enum | OCDDEGLITCH { D0 , D1 , D2 , D3 , D4 , D5 , D6 , D7 , D8 , D9 , D10 , D11 , D12 , D13 , D14 , D15 } |
| enum | OCDTHR { THR1_1 , THR1_2 , THR1_3 , THR1_4 , THR1_5 , THR1_6 , THR1_7 , THR1_8 , THR2_1 , THR2_2 , THR2_3 , THR2_4 , THR2_5 , THR2_6 , THR2_7 , THR2_8 } |
| enum | VRefExt { V1_65 , V1_2 , V1_5 , V1_8 , V2_5 } |
Public Member Functions | |
| TLI4971 (int aout, int vref, int pwr, int sici, int ocd1, int ocd2, int mux, bool mc5V=true) | |
| Current sensor instance constructor. | |
| ~TLI4971 (void) | |
| Current sensor instance destructor . Reconfigurates pins to INPUT and ADC resolution to 8 Bit | |
| bool | begin (void) |
| Turn on sensor supply, initialy reads sensor configuration and checks if sensor can be configurated. | |
| bool | reset (void) |
| Resets sensor to factory settings. | |
| void | end (void) |
| Ends sensor library Turn off sensor supply. | |
| double | read (void) |
| Reads sensor outputs and calculates current value. If Software OCD is used, this function can trigger the handler. | |
| void | ocdPolling (void) |
| If polling is used as OCD mode this function will perform the polling. Needs to be called repeatedly, e.g. in loop. Handler functions for OCD-signals will be called by this method. SW-OCD will be detected as well, if in use. | |
| void | configAdc (bool logicLevel5V, int adcResolution=-1) |
| Configurate ADC. | |
| double | getLastSwOcdCurrent (void) |
| As soon as a Software OCD is triggered, the current value (> threshold) is stored. This function returns it. | |
| bool | registerOcd1Function (int mode, void(*func)(void)) |
| Register a handler, which shall be called when the sensor triggeres OCD1. | |
| bool | registerOcd2Function (int mode, void(*func)(void)) |
| Register a handler which shall be called when the sensor triggeres OCD2. | |
| bool | registerSwOcdFunction (double currentLevel, void(*func)(void)) |
| Register a handler, which shall be called when the sensor value exceeds a certain threshold. | |
| bool | setMeasRange (int measuringRange) |
| Sets the measurement Range of the sensor (refer to Programming Guide). | |
| bool | setOpMode (int operatingMode) |
| Set operating mode of the sensor (refer to Programming guide). | |
| bool | configOcd1 (bool enable, int threshold=THR1_1, int deglitchTime=D0) |
| Configuration of OCD1. | |
| bool | configOcd2 (bool enable, int threshold=THR2_1, int deglitchTime=D0) |
| Configuration of OCD2. | |
| bool | setOcdCompHyst (int threshold) |
| Sets the OCD hysteresis. OCD signals will reset if current < 20% of the provided threshold. | |
| bool | setSwOcdCompHyst (double hysterese) |
| Set Hysteresis value for SW-OCD. Signal will be reset when current < threshold - hysteresis. | |
| bool | setVrefExt (int vrefExtVoltage) |
| Sets the reference voltage level. This can be used for Single Ended mode (setting needs to match external reference voltage), as well as Semi-differential Uni-directional mode (sensor will output this voltage at vRef). | |
| bool | setRatioGain (bool enable) |
| If this is enabled the sensitivity is ratio-metric to VDD respective to VREF in single-ended mode. Default is disabled. | |
| bool | setRatioOff (bool enable) |
| If this is enabled the ratio-metric offset behavior of the quiescent voltage is activated. Default is disabled. | |
| bool | getOcd1State (void) |
| Reads state of ocd1-pin from sensor. | |
| bool | getOcd2State (void) |
| Reads state of ocd2-pin from sensor. | |
| bool | getSwOcdState (void) |
| Get state of Software OCD. | |
| enum TLI4971::OCDMODE |
| enum TLI4971::MEASRANGE |
| enum TLI4971::OPMODE |
| enum TLI4971::OCDDEGLITCH |
| enum TLI4971::OCDTHR |
| enum TLI4971::VRefExt |
| TLI4971::TLI4971 | ( | int | aout, |
| int | vref, | ||
| int | pwr, | ||
| int | sici, | ||
| int | ocd1, | ||
| int | ocd2, | ||
| int | mux, | ||
| bool | mc5V = true |
||
| ) |
Current sensor instance constructor.
| [in] | aout | analog channel for reading sensors analog output |
| [in] | vref | analog channel for sensors reference voltage output |
| [in] | pwr | pin for switching sensors VDD |
| [in] | sici | pin for SICI communication |
| [in] | ocd1 | pin for over-current detection 1 signal of sensor |
| [in] | ocd2 | pin for over-current detection 2 signal of sensor |
| [in] | mux | pin connected to analog mulitplexer on Shield2Go |
| [in] | mc5V | states whether microcontroller is a 5V or 3V3 device (needed for calculation) |

| TLI4971::~TLI4971 | ( | void | ) |
Current sensor instance destructor .
Reconfigurates pins to INPUT and ADC resolution to 8 Bit

| bool TLI4971::begin | ( | void | ) |
Turn on sensor supply, initialy reads sensor configuration and checks if sensor can be configurated.
| true | if sensor can be configurated |
| false | if sensor not available for configuration (SICI communication failed) |

| bool TLI4971::reset | ( | void | ) |
Resets sensor to factory settings.
| true | if restart succeded |
| false | if restart failed (SICI communication not possible) |

| void TLI4971::end | ( | void | ) |
Ends sensor library Turn off sensor supply.
| double TLI4971::read | ( | void | ) |
Reads sensor outputs and calculates current value. If Software OCD is used, this function can trigger the handler.
| current | value in Ampere |
| void TLI4971::ocdPolling | ( | void | ) |
If polling is used as OCD mode this function will perform the polling. Needs to be called repeatedly, e.g. in loop. Handler functions for OCD-signals will be called by this method. SW-OCD will be detected as well, if in use.

| void TLI4971::configAdc | ( | bool | logicLevel5V, |
| int | adcResolution = -1 |
||
| ) |
Configurate ADC.
| [in] | logicLevel5V | true for 5V microcontrollers, false for 3.3V microcontrollers |
| [in] | adcResolution | number of Bits the ADC returns |
| double TLI4971::getLastSwOcdCurrent | ( | void | ) |
As soon as a Software OCD is triggered, the current value (> threshold) is stored. This function returns it.
| last | current value which triggered the Software-OCD |
| bool TLI4971::registerOcd1Function | ( | int | mode, |
| void(*)(void) | func | ||
| ) |
Register a handler, which shall be called when the sensor triggeres OCD1.
| [in] | mode | INTERRUPT if hardware interrupt is available at the microcontroller for this pin. POLLING if no hardware interrupt is available for this pin. See as well ocdPolling() in this case. |
| [in] | *func | pointer to handler function |
| true | if registering was possible |
| false | if registering failed |
| bool TLI4971::registerOcd2Function | ( | int | mode, |
| void(*)(void) | func | ||
| ) |
Register a handler which shall be called when the sensor triggeres OCD2.
| [in] | mode | INTERRUPT if hardware interrupt is available at the microcontroller for this pin. POLLING if no hardware interrupt is available for this pin. Use as well ocdPolling() in this case. |
| [in] | *func | pointer to handler function |
| true | if registering was possible |
| false | if registering failed |
| bool TLI4971::registerSwOcdFunction | ( | double | currentLevel, |
| void(*)(void) | func | ||
| ) |
Register a handler, which shall be called when the sensor value exceeds a certain threshold.
| [in] | currentLevel | threshold in Ampere |
| [in] | *func | pointer to handler function |
| true | if registering was possible |
| false | if registering failed |
| bool TLI4971::setMeasRange | ( | int | measuringRange | ) |
Sets the measurement Range of the sensor (refer to Programming Guide).
| [in] | measuringRange | Range of Current measurement. Possible values are: FSR120 = +/- 120A FSR100 = +/- 100A FSR75 = +/- 75A FSR50 = +/- 50A FSR37_5 = +/-37.5A FSR25 = +/- 25A |
| true | if configuration succeeded |
| false | if configuration failed |
| bool TLI4971::setOpMode | ( | int | operatingMode | ) |
Set operating mode of the sensor (refer to Programming guide).
| [in] | operatingMode | Mode of sensor operation. Changes the behaviour of AOut and Vref dependent of the measured current. Possible modes are: SD_BID = Semi-differential Bi-directional: Sensor provides reference voltage. Current flow in both directions are measured. FD = fully differential: vref is used as differential output signal from sensor. Increases resolution by factor 2. SD_UNI = Semi-differential Uni-directional: Sensor provides reference voltage. Direction of current flow is known by the application. See setVrefExt() as well. SE = Single Ended: Reference Voltage is provided by the µC or an external circuit. See setVrefExt() as well. |
| true | if configuration succeeded |
| false | if configuration failed |
Configuration of OCD1.
| [in] | enable | true to enable OCD1 signal, false to disable. |
| [in] | threshold | set a Threshold level for OCD1. Range: [THR1_1 - THR1_8] according to Programming guide. |
| [in] | deglitchTime | set a time for deglitching. Range: [D0 - D7] according to Programming guide. |
| true | if configuration succeeded |
| false | if configuration failed |
Configuration of OCD2.
| [in] | enable | true to enable OCD2 signal, false to disable. |
| [in] | threshold | set a Threshold level for OCD2. Range: [THR2_1 - THR2_8] according to Programming guide. |
| [in] | deglitchTime | set a time for deglitching. Range: [D0 - D15] according to Programming guide. |
| true | if configuration succeeded |
| false | if configuration failed |
| bool TLI4971::setOcdCompHyst | ( | int | threshold | ) |
Sets the OCD hysteresis. OCD signals will reset if current < 20% of the provided threshold.
| [in] | threshold | 20% of this Threshold are set as hysteresis for both OCD signals. Range: [THR1_1 - THR2_8] |
| true | if configuration succeeded |
| false | if configuration failed |
| bool TLI4971::setSwOcdCompHyst | ( | double | hysteresis | ) |
Set Hysteresis value for SW-OCD. Signal will be reset when current < threshold - hysteresis.
| [in] | hysteresis | value in Ampere to be set as Hysteresis. |
| true | if setting hysteresis was successful |
| false | if setting hysteresis was not successful |
| bool TLI4971::setVrefExt | ( | int | vrefExtVoltage | ) |
Sets the reference voltage level. This can be used for Single Ended mode (setting needs to match external reference voltage), as well as Semi-differential Uni-directional mode (sensor will output this voltage at vRef).
| [in] | vrefExtVoltage | Voltage level to set at vRef. Possible levels: V1_65 = 1.65V V1_2 = 1.2V V1_5 = 1.5V V1_8 = 1.8V V2_5 = 2.5V |
| true | if configuration succeeded |
| false | if configuration failed |
| bool TLI4971::setRatioGain | ( | bool | enable | ) |
If this is enabled the sensitivity is ratio-metric to VDD respective to VREF in single-ended mode. Default is disabled.
| [in] | enable | true: ratio-metric gain is enabled false: ratio-metric gain is disabled |
| true | if configuration succeeded |
| false | if configuration failed |
| bool TLI4971::setRatioOff | ( | bool | enable | ) |
If this is enabled the ratio-metric offset behavior of the quiescent voltage is activated. Default is disabled.
| [in] | enable | true: ratio-metric offset is enabled false: ratio-metric offset is disabled |
| true | if configuration succeeded |
| false | if configuration failed |
| bool TLI4971::getOcd1State | ( | void | ) |
Reads state of ocd1-pin from sensor.
| true | if OCD1 is triggered |
| false | if OCD1 is not triggered |
| bool TLI4971::getOcd2State | ( | void | ) |
Reads state of ocd2-pin from sensor.
| true | if OCD2 is triggered |
| false | if OCD2 is not triggered |
| bool TLI4971::getSwOcdState | ( | void | ) |
Get state of Software OCD.
| true | if Software-OCD is triggered |
| false | if Software-OCD is not triggered |