Functions
tc_calibration Namespace Reference

Functions

def main ()
 

Detailed Description

Copyright (C) 2019 Moxa Inc. All rights reserved.
SPDX-License-Identifier: Apache-2.0

TC Calibration Python Sample Application

Date          Author            Comment
2019-02-11    William Chang     Created it.

Function Documentation

◆ main()

def tc_calibration.main ( )

Definition at line 29 of file tc_calibration.py.

29 def main():
30  parser = argparse.ArgumentParser(description="TC calibration sample program.")
31  parser.add_argument("-s", "--slot", dest="tc_slot", type=int, default=7)
32  parser.add_argument("-c", "--channel", dest="tc_channel", type=int, default=0)
33  parser.add_argument("-e", "--calibration_temperature", dest="tc_calibration_temperature", type=int, default=0)
34  parser.add_argument("-t", "--type", dest="tc_type", type=int, default=TC_SENSOR_TYPE_K)
35  args = parser.parse_args()
36 
37  tc_slot = args.tc_slot
38  tc_channel = args.tc_channel
39  tc_calibration_temperature = args.tc_calibration_temperature
40  tc_type = args.tc_type
41  print("TC slot = {}".format(tc_slot))
42  print("TC channel = {}".format(tc_channel))
43  print("TC type = {}".format(tc_type))
44  print("calibration temperature = {}".format(tc_calibration_temperature))
45 
46  # initialize ioThinx I/O
47  device = ioThinx_4530_API.ioThinx_4530_API()
48 
49  # temporarily set config
50  device.ioThinx_TC_Config_SetSensorTypes(tc_slot, tc_channel, 1, [tc_type])
51 
52  # reload config
53  device.ioThinx_IO_Config_Reload()
54  print("After executing this program, a non-volatile offset will be set for the selected channel.")
55  print("1. Ensure the sensor is connected.")
56  print("2. Ensure the channel and its sensor type is correctly selected.")
57  print("3. Put the sensor into a glass that contains a mixture of ice and water.")
58  print("4. Do not remove the sensor from the ice water during calibration...")
59  ch = input("Continue ? (y/n): ")
60 
61  if ch == 'y':
62  # get TC value
63  tc_value = device.ioThinx_TC_GetValues(tc_slot, tc_channel, 1)
64  print("TC value before calibration: {}".format(tc_value))
65  # execute the API with zero degrees Celsius as input parameter
66  device.ioThinx_TC_SetCalibrations(tc_slot, tc_channel, 1, [tc_calibration_temperature])
67  # wait for calibration ok
68  print("Calibrating...")
69  sleep(3)
70  # get TC value
71  tc_value = device.ioThinx_TC_GetValues(tc_slot, tc_channel, 1)
72  print("TC value after calibration: {}".format(tc_value))
73  print("Finish.")
74  else:
75  print("Abort.")
76 
77 
def main()
Definition: misc.py:32