- Main
- Tutorials
- Library
- Samples

- File List
- Globals

Namespaces | Functions | Variables
tc_calibration.py File Reference

TC Calibration Sample More...

Go to the source code of this file.

## Namespaces
| tc_calibration

## Functions
def | main ()

## Variables
int | TC_SENSOR_TYPE_K = 1

## Detailed Description

TC Calibration Sample

Copyright
  2019 Moxa Inc. All rights reserved.

Date
  2019-02-11

Author
  William Chang

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

Definition in file tc_calibration.py.