analog to digital:)

theripley

Member
Join Date
Jul 2008
Location
laguna
Posts
545
Hi

How can an analog signal (4-20 mA) will be translated to a digital value (linear) understood by the PLC & drive the corresponding output?
Please post sample basic programs (preferably in CX or GX).


Best regards,
theripley
 
I used a Contrologix (CX?) processor to control a PID loop using the PIDE fucntion block, then put the output of this into a Split Range (STRP) function block to give a digital output to a motor.

From reading your post, I presume that you would just be looking at the STRP function block but I'll include the PID in the diagram.

I hooked the PIDE CVEU to the STRP IN and had the heat out and cold out as my digital outputs for open and close.

Attached is a picture of the function block with the settings for the STRP which took a while for me to refine.

FunctionBlock.jpg
 
do you mean as in a pulse train? invert the signal by subtracting it by the max value and feed the outcome into a timer. use the done bit to reset the timer.

Here's what i have found:
Given the following,
10 bit A/D, voltages +/- 10 V, resolution 1024 (0=-10 V, 1023=+10 V).

Problem:
Convert 4.565 V to an integer value.

Solution:

V = int [(Vin-Vmin) (R-1) + Vmin]
[(Vmax-Vmin)

Therefore,

4.565 V = 745..

I believe this is the value inserted to the program of the PLC when 4.565 V is gained.

My question is:

How can i use this 745 value in the program?
Kindly include examples of such programs preferably in omron/ mitsubishi..
 
Creativepaper,

My bad, i did not specify regarding CX (Omron programming software).. I somehow got lost on the attached image..
 
How can i use this 745 value in the program?
Kindly include examples of such programs preferably in omron/ mitsubishi..

Well, what does that value represent? Is it a signal from a Flow Meter? Level Sensor? Temperature? Weight?

The signal has some meaning otherwise the field device providing it would not have been purchased correct? So ask yourself why you have the signal in the first place, and how does the end user benefit by having it?

For giggles lets say the signal is from a flow meter, and the flow meter is setup so -10V = 0 GPM, +10V = 350 GPM.

If I did my math right that value of 745 would equate to a flow rate of ~254 GPM. Well you can display that value on an HMI, or use that as a PID PV value in the PLC for control...

You can trend it, data log it...

So many options!
 
If I did my math right that value of 745 would equate to a flow rate of ~254 GPM. Well you can display that value on an HMI, or use that as a PID PV value in the PLC for control...

Do you have an example program for this..Like @ 745 value (254 GPM), a device (say a motor) would lower its speed..I would really appreciate if you have sample codes written in CX (omron) or GX (mitsubishi)..Tnx a lot:)
 
Sorry no sample code (I'm a AB/GE guy), but you have already done the math for this, you did it when you converted your voltage to a value in your previous post.

Search for forums for "scaling".

All you are doing is converting signal units from one to another...

The PLC A/D converter handles the mA/V conversion into an RAW unitless integer value. You then need to "scale" or convert that RAW value into a useful engineering unit (%, GPM, LBS..)

The easiest method is to remember the classic formula for a line: y = mx + b.

y = Scaled Value (dependent value)
x = Raw Value (independent value)
m = Slope
b = offset.

Draw an x - y coordinate plane on a piece of paper. All you need is 2 known points to calculate your line slope (assuming the signal is linear), which you have. In my example (0,0) and (350,1023). Go back to those algebra classes calculate the slope, and determine if there is an offset. In my example there is no offset so the equation reduces to: y = mx

You only need simple math instructions in the PLC to achieve this calculation. You can go so simple as to calculate m on paper and hardcode that value into a multiply instruction to get y...just comment how you calculated m.

Some PLCs such as AB have instructions that do all of this for you, you just enter the Raw Min/Max and Scaled Min/Max and you are done. Your software may have this instruction as well.

However it is good practice to understand the basics of scaling.
 
Last edited:
.....Like @ 745 value (254 GPM), a device (say a motor) would lower its speed..I would really appreciate if you have sample codes written in CX (omron) or GX (mitsubishi)..Tnx a lot:)

Now, when you get into controlling another analog output based on an analog input things get more complicated. You need to understand the scaling concept before you think of taking the next rather large of analog control.
 
b = offset.

Go back to those algebra classes calculate the slope, and determine if there is an offset. In my example there is no offset so the equation reduces to: y = mx

Sir,

Can you elaborate more on offset & its significant in "scaling"?
Sorry, if i sounded so naive..On the y=mx+b, m=slope & b=constant..therefore,if i have a line y=2x+1 it means that the line has a slope of 2 and that it crosses the y-axis at 1..Well, this is very mathematics :)
 
Yes mam, Erika! If you have a line, the "Offset" is the value of Y where the line crosses the Y-axis (the amount that the line is shifted above or below the X-axis when the value of mX = 0).

In PLC scaling, the offset will be the value that must be added to the scaling equation to produce the Minimum Scaled Value when the Input Value = Input Minimum. Here are the scaling equations written in terms of Input Min, Input Max, Scaled Min and Scaled Max:

Scaled value = input value X slope + offset
Slope = scaled max - scaled min / input max - input min
Offset = scaled min - (input min X slope)

For example, suppose I have a Weight Controller that has a range of 0 to 175 pounds per minute. My Input Minimum is 3277 and Input Maximum is 16384. So my scaling equations would look like this:

Slope = (175-0) / ( 16384-3277) = 0.0133516
Offset = 0-(3277 X 0.0133516) =-43.753193

The above says that when the input is 3277 (minimum), then my offset must be -43.753193 so that my controller shows an output of 0 lbs/minute.

And my ladder logic would be like below. You can see that location N30:10 (Loss in Weight) last read a scaled rate of 66 lbs/minute.

(PS: I liked your previous real picture better than that Avatar!)

Scaling Example -Loss in Weight2.jpg
 
Last edited:
Sirs,

I am currently seeking for sample programs written in CX (omron) and/ or GX (mitsubishi) containing the topics above..Kindly extend some help..

Best regards,
theripley
 

Similar Topics

Hello, I have a small programming task that I need help solving. I have to: * Create an analog input (4-20v)and a digital output * The analog...
Replies
45
Views
24,977
I am attempting to interface a Mistras acoustic sensor to a AB Micro820. The problem I have is the sensor logic is 3.3VDC and Micro820 is 24VDC...
Replies
10
Views
2,372
Hey I was wondering if you guys could explain to me how the signal flows on a analog & digital signal. for example: Explain the wiring of a...
Replies
2
Views
2,147
Hi, I have 7 years of experience as a maintenance / PLC programmer in a fairly old steel mill. I was the one who converted PLC2 to CtrlLGx...
Replies
4
Views
2,350
Hello, I was wondering if you guys could help explain to me how the wiring and signal on Digital and Analog inputs/outputs run from the PLC to the...
Replies
2
Views
2,659
Back
Top Bottom