User Tools

Site Tools




int getTemp (u8 tempId, u8 tempCh)

tempId : The ID of the Temperature Input Module (0 ~ 9)
tempCh: The channel on the Temperature Input Module (1 ~ 2)
returns the temperature in °C multiplied by 10. (-1000 ~ 5000)

Gets the temperature read from a PT100 sensor connected to Temperature Input Module tempId on channel tempCh.

The return value is the temperature in °C multiplied by 10. In other words if getTemp returns the value 205, the actual temperature is 20.5 °C.

If an error occurs, the following values may be returned.

Exception Description
20001 ~ 20003 An error occurred while transmitting the value to the CPU
20004 Invalid module ID
20005 Sensor is not connected
55555 Value exceeds valid maximum
11111 Value is below valid minimum

The following sample program prints the temperature to the debug console every second

#include "moacon500.h"
void cmain(void)
 int temp = 0;
     temp = getTemp(0, 1);                //Get the Temperature
                                          //Print the temperature(e.g. "Temp: 20.5")
     printf("Temp: %d.%d \r\n", temp/10, temp%10);
     delay(1000);                         //Wait for 1 second

The sampling rate of the Temperature Input Module is 200ms per channel, and is constantly sampling the temperature sensor. getTemp returns the most recently sampled value.

The Temperature Input Module samples all channels at once, so at 200ms per channel, the total sampling time for four channels is 800ms. Therefore, there is no benefit in calling getTemp at a rate greater than 800ms, as it will always return the same value. getTemp's execution time is roughly 3ms.

When the system is first powered on, all four channels are scanned once. Calling getTemp at this time will return an invalid value. Please allow at least 800ms from the time the system is powered on before calling getTemp.

The following is an image of a PT100 temperature sensor.

go MOACON home

moacon/gettemp/index.txt · Last modified: 2016/04/14 11:07 (external edit)