User Tools

Site Tools

한국어

comfilepi:codesys:codesys12

Analog Input and Temperature Sensing

Let's do temperature sensing and analog input using the MODPORT Field I/O Controller.

As a demonstration, connect a potentiometer and a PT100 sensor.

1. Add channels. See the MODPORT user's manual

The final state should look like this

2. Add a POU for MODPORT access.

3. Programming using the ST language.

PROGRAM MODPORT_PROC
VAR
	HAD0_VALUE : DWORD;
	TH0_VALUE : REAL;
	TH_ORG : WORD;
END_VAR

HAD0_VALUE := %IW1 * 65536 + %IW2;

TH_ORG := %IW3;
IF (TH_ORG AND 16#8000) = 16#8000 THEN
	TH_ORG := TH_ORG - 16#8000;
	TH0_VALUE := TH_ORG/10;
	TH0_VALUE := -TH0_VALUE;
ELSE
	TH0_VALUE := TH_ORG/10;
END_IF

4. And create a simple visualization.

Check the result.

Download the project file : modport_adc.zip

CODESYS with the ComfilePi

comfilepi/codesys/codesys12.txt · Last modified: 2022/07/08 05:52 by COMFILE Technology