How to deal with analogue signal using software CoDeSys plz,(when AI=4MA the AO=20MA and when AI=20MA the AO=4MA
Answers
For example, if you use AI523, 4 mA correponds to digital value of 1 and 20 mA corresponds to 27648. Please refer CoDeSys online help file of the respective module for more details.
Additionaly you can use"LIN_TRAFO" FB(whihc is part Utiliites library) for scaling.
Hi!
As suggested by the former answer here is a bit of code. Also attached.
br
GustavA
PROGRAM PLC_PRG_1
VAR
AI_4mA: INT;
fb1: LIN_TRAFO;
AO_in_Real: REAL;
AO_20mA: INT;
END_VAR
CAL fb1(IN := AI_4mA, IN_MIN := 0, IN_MAX := 27648, OUT_MIN := 27648, OUT_MAX := 0)
LD fb1.OUT
ST AO_in_Real
LD AO_in_Real
REAL_TO_INT
ST AO_20mA
Greetings
i would say you just need to do scaling for the signal in the reverse way
you can do that by substract the reading value by the max analogue signal value (32767) and you had to take care of the -ve sign
hope that i explane that well
regards
Add new comment