Previous post where I have talked about the APR function & given an example:
http://www.plctalk.net/qanda/showthread.php?t=41135
For a simple linear scale or conversion here are two examples for the CP1E.
The analogue input (ch90 & ch91) is converted into a value of 0-6000 inside the PLC this is a signed integer value which could also be treated as unsigned if we never go below zero. Actual entire data range is -300 to +6300.
This count of 0-6000 needs to be scaled to a value of 0-200.0, for the purposes of this example we will scale to 0-2000.
If we work with signed integer data (INT) for analogue input 1 your setup should be as follows:
DM100 = #0800 (Control word)
DM101 = +0 (minimum value of converted input from sensor to PLC)
DM102 = +0 (minimum scaled value)
DM103 = +6000 (maximum value of converted input from sensor to PLC)
DM104 = +2000 (maximum scaled value)
In the attached program example the converted data is in DM150, I have also used the sensor disconnected detection bit to turn on/off the APR conversion. This could also be used to set a fixed value to the converted word if a sensor fault occurs.
If we work with unsigned integer data (UINT) for analogue input 2 your setup should be as follows:
DM110 = #0000 (Control word)
DM111 = &6000 (maximum value of converted input from sensor to PLC)
DM112 = &0 (minimum scaled value)
DM113 = &6000 (maximum value of converted input from sensor to PLC)
DM114 = &2000 (maximum scaled value)
NOTE: With unsigned data conversion the x0 value must be set to the xMax value - the PLC assumes x0 = 0
This is why I prefer to work with signed data where possible (or floating point).
The sensor disconnected detection bit for input 2 is also used here to turn on/off the APR conversion.
Have a look at the attached program - I have made two sections one for signed values and one for unsigned values. Hopefully this should be self-explanatory.
You should be able to cut & paste into your program.
View attachment APR Program CP1E.zip
Merry Christmas
http://www.plctalk.net/qanda/showthread.php?t=41135
For a simple linear scale or conversion here are two examples for the CP1E.
The analogue input (ch90 & ch91) is converted into a value of 0-6000 inside the PLC this is a signed integer value which could also be treated as unsigned if we never go below zero. Actual entire data range is -300 to +6300.
This count of 0-6000 needs to be scaled to a value of 0-200.0, for the purposes of this example we will scale to 0-2000.
If we work with signed integer data (INT) for analogue input 1 your setup should be as follows:
DM100 = #0800 (Control word)
DM101 = +0 (minimum value of converted input from sensor to PLC)
DM102 = +0 (minimum scaled value)
DM103 = +6000 (maximum value of converted input from sensor to PLC)
DM104 = +2000 (maximum scaled value)
In the attached program example the converted data is in DM150, I have also used the sensor disconnected detection bit to turn on/off the APR conversion. This could also be used to set a fixed value to the converted word if a sensor fault occurs.
If we work with unsigned integer data (UINT) for analogue input 2 your setup should be as follows:
DM110 = #0000 (Control word)
DM111 = &6000 (maximum value of converted input from sensor to PLC)
DM112 = &0 (minimum scaled value)
DM113 = &6000 (maximum value of converted input from sensor to PLC)
DM114 = &2000 (maximum scaled value)
NOTE: With unsigned data conversion the x0 value must be set to the xMax value - the PLC assumes x0 = 0
This is why I prefer to work with signed data where possible (or floating point).
The sensor disconnected detection bit for input 2 is also used here to turn on/off the APR conversion.
Have a look at the attached program - I have made two sections one for signed values and one for unsigned values. Hopefully this should be self-explanatory.
You should be able to cut & paste into your program.
View attachment APR Program CP1E.zip
Merry Christmas