- Main
- Tutorials
- Library
- Samples

- File List
- Globals

Namespaces | Functions | Variables
rtd_calibration.py File Reference

RTD Calibration Sample More...

Go to the source code of this file.

## Namespaces
| rtd_calibration

## Functions
def | main ()

## Variables
int | RTD_SENSOR_TYPE_PT100 = 1

## Detailed Description

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

Definition in file rtd_calibration.py.