class Analog Port¶
The analog object is used to read one of the analog inputs.
Constructor¶
-
class
omc048.
analog_voltage
(id: integer)¶ Create an analog object associated with one of the two analog voltage ports. Use port number 1 for 0-24V input(pin 18) and number 2 for 0-5V input(pin 19)
id
is the analog port number.
-
class
omc048.
analog_current
(id: integer)¶ Create an analog object associated with one of the four analog mA ports. Use port number 1 to 4 for the ports connected to respectivly pin 23 to 26.
id
is the analog port number.
Methods¶
-
analog.
read
() → float¶ Read the analog input value from the port. The returned value is in millivolts for the voltage ports and in milliampere for the mA inputs.
-
analog.
read_raw
() → integer¶ Read the raw analog input value from the port. The returned value is the unconverted value from the ADC input ranging between –32768 and 32767. In practice this value should not be below -10.
-
analog.
calibrate
(level: integer)¶ Set the calibration value for specified level. The low level calibration is for 0V/0mA, the high level is for 24mA/5V/24V depending on the port.
level
The value to calibrate. 0 for low and 1 for high.
Example¶
The following example prints a warning when a low voltage is reached.
import omc048
a2 = omc048.analog_voltage(2)
low_voltage = False
while True:
if (not low_voltage) and (a2.read() < 2.8):
low_voltage = True
print("Low voltage warning!")