I would like to read 0.1 degree resolution from the thermocouples I have hooked up to the IR-AI-04-TR module. Currently, all temperature numbers are integers with the following macro code:
unsigned short Temperatures[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
unsigned short i = 0
unsigned short j = 0
unsigned short ambient_temp = 0
GetDataEx(Temperatures[0], "Weintek Remote IO (MODBUS TCP/IP)", 3x, 0, 16)
for i = 0 to 15
Temperatures[i] = Temperatures[i] / 10.0 // adjust scale
next i
How can I read more precise temperatures?
Hi @itsmomito,
The iR-AI04-TR user manual states that “The temperature resolution for thermocouple and RTD is 0.1 degrees. That is, 101.5 degrees = 1015 digital value.”. In order to reflect this resolution within a a macro you will need to convert your array of short integers into floats. To do this, I would recommend that you add an array of float and configure the macro as shown:
unsigned short Temperatures[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
float fTemperatures[16]
unsigned short i = 0
unsigned short j = 0
unsigned short ambient_temp = 0
GetDataEx(Temperatures[0], "Weintek Remote IO (MODBUS TCP/IP)", 3x, 0, 16)
for i = 0 to 15
fTemperatures[i] = Temperatures[i]
fTemperatures[i]= fTemperatures[i] / 10.0 // floating point division
next i
With the current configuration, the HMI performs integer division and truncates any digits after the decimal point. However, the modification above will force the HMI to perform floating point division and yield values like 101.5 instead of 101 or 1015.