APR instruction with Omron

irondesk40

Member
Join Date
Jan 2008
Location
nc
Posts
630
Could someone explain the APR instruction in what might be considered easier to understand terms than what I have read in the manaul.
Just having a hard time grasping it.

Inherited a program from some Italians and they use it quite a bit with inputs from level sensors.

For example

APR
D3570
D3501
D358

Thanks a lot
 
Quick look at the manual, this may not be an easy question to answer.

What processor is being used?

What is the value of the Control Word.
The control word will determine exactly what the instruction is doing. Different values for the control word make the instruction work differently.

Not much help, but with a little more information, we might be able to get there.
 
I cannot read Italian but suspect that the APR fucntion is probably being used to linearise an input. I have used this quite often before for that purpose.

Basically how I have used it is to set up a table in DM. The table represented litres at various levels in a tank matched up to ma readings at the various points. If a tank is laying on it's side with dished ends, I obtained from the manufacturer litre values at each ma point from the level transmitter - these values were obviously not linear. I then used the APR function to linearise the output in the program to display the tank capacity in litres on a SCADA screen.
 
The APR instruction has a few functions but in this case it is being used to scale some values. There are several scale instructions in the Omron PLC but other than APR these are simple X to Y linear (straight line) conversions. APR is described as an extrapolation of Y from the value of X based on co-ordinates. Put simply the APR creates a broken line approximation graph which is useful for converting actual values from non-linear analogue input sources. Say for instance you have a hopper with a cone at the base but vertical sides starting halfway up and a linear probe looking down at the level. In this case the level of product is not directly proportional to the volume. The calculation for volume is different for the lower half than the upper half but the APR instruction can do this for you (if set up correctly)

In your case your control word (DM3570) contains the value +2048, which is 0800hex. This converts to input data = binary, output data = binary, source data form f(x)=f(S), both source and result words are signed 16bit binary data and you have 1 set of co-ordinates that are being used to convert the data.

Values used by the PLC when calculating the APR function.

DM3570 = Control word

DM3571 = Max value of X (or in this case the source signal)

DM3572 = Min value of Y (result data)

DM3573 = 1st co-ordinate of X – NOT minimum value (in this case it is actually X max)

DM3574 = 1st co-ordinate of Y (in this case Y max – Result data)

DM3501 = source data – Originally from the first input point of the CJ1W-MAD42 on the main rack

DM358 = the scaled result word.



Hope this helps – I use this function quite often in fact rather than using the standard scale functions but the first time it was explained to me it took some time to get my head around it.
 
APR instruction

Hi All,

Thanks in advance for reading this post.

I am not sure if it is allowed to post a similar question in a reply thread but here goes.

I am trying to debug an OMRON CJ1M PLC program which converts analogue pressure sensor, connected in Main Rack 001 (CJ1W-MAD42) and having the input (4-20mA) into the equivalent Bar pressure.

To do this, the attached APR(069) function is being used.

The control word (at D4090) is: &49152 (Binary: 1100000000000000) which means that extrapolation settings are: BCD input and output, f(x)=f(S), unsigned data, and number of coordinates (m)=1.
For the coordinates, the data is:
D4091 = &9999
D4092 = &0
D4093 = &7296
D4094 = &240
Given the discrepancy between the values in registers D4091 and D4093, would the Xm = 7296 or 9999. And would the straight (extrapolation) line start from BCD(x=0,y=0) and end at BCD(x=2280,y=150).

I should also mention that the main purpose of my debugging is that currently the PLC outputs pressure as a whole number value (e.g. 1Bar or 7Bar etc). What I am hoping to achieve is to convert it to a more precise floating point value by implementing the extrapolation line and real-time conversion.

Many thanks (and apologies for the long question)
FT

APR.jpg
 
Last edited:
Try this instead, I decided to write a scale function block that would output INT and REAL values - right click on the function block part of the program tree, insert new function block from file, drop into program, easy :) see picture. You do not need to assign both outputs if you only need the REAL value.

NOTE: The MAD42 input can be setup as 0-4000 or 0-8000 as the input conversion. This is an INT value.

Scale.jpg
 

Attachments

  • Scale_INT_v2.zip
    1.2 KB · Views: 110
Many thanks for your reply Woody. I really appreciate it.

I'm afraid that the customer may not be so willing for me to change the PLC code. So as a first option, I was thinking to read in the Source data (BCD value) through OPC into our company's real-time software package, where I can use the D4090 line to extrapolate the Result word 16bit BCD (as the PLC is currently doing) but convert it into floating point/real - rather than an integer- pressure value.

Would you say that this is possible or the fact that source data (from the PLC's ADC) is 16bit BCD means that the current APR (069) is setup for int data only (and therefore nothing external can be done with the soruce data to obtain the real value for pressure without making your suggested changes in the PLC ladder logic).

Another thing I am confused about is that: when Actual OFFSET (source data) = BCD34, the PLC outputs Pressure (result word) = 1 BCD/INT. But not sure how this result value is being calculated since according to the APR coordinate setting, the formula in this case should be: Pressure = (150/2280)*34 =2.2 (Or is this incorrect).


Apologies for the basic questions as I am a novice when it comes to PLC programming. Please le me know if you would like me to post the PLC code

Many thanks.
 
OK, I see. The problem you are having is that you want to scale a 4 digit BCD value (Actual OFFSET) and have a result as a 4 digit BCD value (PRESSURE).

The settings for the APR function are incorrect. The should be as follows;
D4090 - Control word #C000 this is currently set correct
D4091 - Xmax (when scaling BCD to BCD this is always the max source value)
D4092 - Ymin (scaled minimum value)
D4093 - Xmax (last max value of source value)
D4094 - Ymax (Last max value of scaled value)

It looks a bit odd to have Xmax listed twice but the linear approximation function can take multiple X-Y conversions to almost create a curve if needed. In this case we are only using two points to create a straight line conversion. For BCD conversion this is unsigned and Xmin is ALWAYS zero therefore does not need to be specified. If you want Xmin to be greater than zero then you need to use two sets of coordinates or use binary instead of BCD.

SO... the problem with the current code is D4091 and D4093 need to be exactly the same value AND none of the values are actually BCD

For example if your input word (Actual OFFSET) has a range of 0-4000 BCD and you want an output of 0-150 BCD setting should be;
D4090 - #C000 Control word
D4091 - &4000 Xmax
D4092 - &0 Ymin
D4093 - &4000 Xmax
D4094 - &150 Ymax

You need to know the range of your input value. As an after thought, if the input exceeds the input max value then the converted value is capped at the Ymax value.

Cheers
 
Last edited:

Similar Topics

have a program that I have inherited that the instruction. APR D3570 D3501 D358 The value in D3570 is equal to 800 hex (+2048) Could someone...
Replies
1
Views
3,725
I'm trying to dig to the source of a minor "recoverable" system fault throwing a fault light on a machine that has been confusing my operator...
Replies
3
Views
91
I'm using a SLC typed write from the ControlLogix5572 to the MicroLogix 1400, with path: 2, (MicroLogix IP). The ControlLogix equipment has a...
Replies
0
Views
106
Does this instruction calculate values during a single scan, or does it require number of scans based on element count in the array? For Example...
Replies
3
Views
118
Hello All, Was hoping I could get a little help with Modicon ladder logic. This is the first time I have seen Modicon logic and currently trying...
Replies
6
Views
280
Back
Top Bottom