- Main
- Tutorials
- Library
- Samples

- File List
- Globals

rtd_calibration.py
Go to the documentation of this file.
1 '''
2 Copyright (C) 2019 Moxa Inc. All rights reserved.
3 SPDX-License-Identifier: Apache-2.0
4
5 RTD Calibration Python Sample Application
6
7 Date Author Comment
8 2019-02-11 William Chang Created it.
9 '''
10
11
21
22 from ioThinx_4530 import ioThinx_4530_API
23 import argparse
24 from time import sleep
25
26 RTD_SENSOR_TYPE_PT100 = 1
27
28
29 def main():
30 parser = argparse.ArgumentParser(description="RTD calibration sample program.")
31 parser.add_argument("-s", "--slot", dest="rtd_slot", type=int, default=8)
32 parser.add_argument("-c", "--channel", dest="rtd_channel", type=int, default=0)
33 parser.add_argument("-e", "--calibration_temperature", dest="rtd_calibration_temperature", type=int, default=0)
34 parser.add_argument("-t", "--type", dest="rtd_type", type=int, default=RTD_SENSOR_TYPE_PT100)
35 args = parser.parse_args()
36
37 rtd_slot = args.rtd_slot
38 rtd_channel = args.rtd_channel
39 rtd_calibration_temperature = args.rtd_calibration_temperature
40 rtd_type = args.rtd_type
41 print("RTD slot = {}".format(rtd_slot))
42 print("RTD channel = {}".format(rtd_channel))
43 print("RTD type = {}".format(rtd_type))
44 print("calibration temperature = {}".format(rtd_calibration_temperature))
45
46 # initialize ioThinx I/O
47 device = ioThinx_4530_API.ioThinx_4530_API()
48 # temporarily set config
49 device.ioThinx_RTD_Config_SetSensorTypes(rtd_slot, rtd_channel, 1, [rtd_type])
50 # reload config
51 device.ioThinx_IO_Config_Reload()
52
53 print("After executing this program, a non-volatile offset will be set for the selected channel.")
54 print("1. Ensure the sensor is connected.")
55 print("2. Ensure the channel and its sensor type is correctly selected.")
56 print("3. Put the sensor into a glass that contains a mixture of ice and water.")
57 print("4. Do not remove the sensor from the ice water during calibration...")
58 ch = input("Continue ? (y/n): ")
59 if ch == 'y':
60 # get RTD value
61 rtd_value = device.ioThinx_RTD_GetValues(rtd_slot, rtd_channel, 1)
62 print("RTD value before calibration: {}".format(rtd_value))
63 # execute the API with zero degrees Celsius as input parameter
64 device.ioThinx_RTD_SetCalibrations(rtd_slot, rtd_channel, 1, [rtd_calibration_temperature])
65 # wait for calibration ok
66 print("Calibrating...")
67 sleep(3)
68 # get RTD value
69 rtd_value = device.ioThinx_RTD_GetValues(rtd_slot, rtd_channel, 1)
70 print("RTD value after calibration: {}".format(rtd_value))
71 print("Finish.")
72 else:
73 print("Abort.")
74
75
76 if __name__ == '__main__':
77 main()
rtd_calibration.main
def main()
Definition: rtd_calibration.py:29
format
char const int const cJSON_bool format
Definition: cJSON.h:161