Module Power Monitor
This module contains a class to check the state of the power.
class Hysteresis
The hysteresis object checks the state of the hysteresis by reading the analog port value.
Constructor
- class power_monitor.Hysteresis(analog_port, value_low, value_high, init_state=True)
Create a hysteresis object associated with the given hysteresis. Argument value_low is the lower threshold and value_high is the higher threshold. The init_state is the current state of the hysteresis by initialization.
Methods
- Hysteresis.check() Boolean
This will read the current value of the analog port and update the current state of the hysteresis. The return value will be the state of the hysteresis which is determined as follows.
True if (adc >= higher threshold)
True if (adc > lower threshold) + (adc < higher threshold) + last result of hysteresis.check() was True
False if (adc < higher threshold) + last result of hysteresis.check() was False
False if (adc <= lower threshold)
Example
The following code shows an example with the analog voltage and a hysteresis object. If the batteries are considered not empty the program will continue the program
import omc048
from power_monitor import Hysteresis
adc = omc048.analog_voltage(1)
hys = Hysteresis(adc, 24.0, 24.2)
if hys.check():
# power up sensors and start logging...