how to do analog programme

L

Thread Starter

lim

Hi, i'm still new to PLC programming especially related to analog type.
i understand that there is scaling involved. my question is say for a
4-20mA input and my output is -100 to 200 respectively (i know how to
do 0 to 200), how do i put the negative portion onto the PLC program
and show the result onto a HMI ???
thanx
 
The result depends a lot on your PLC. Some have function blocks to convert analog ins directly to engineering units - and some do not.

The HMI you are using will determine the method as well. Some older units only accept integer values and so the register in the PLC must be set up to work well within the limitations of the HMI. (ex.: If your HMI only allows decimal point placement and you need more precision you will have to send over the engineering units multiplied by 10 or 100 and converted to an integer. If the HMI is really limited you may even have to designate the minus sign as a graphic that appears or disappears based on whether you set a bit in the PLC.)

What hardware are you working with??

-Steve
 
F

Friedrich Haase

<pre>
Moin lim,

here a picture and formula which might help you with scaling.

2nd side scaling
^
| /
E2 -----------------------O
| / |
| / |
| / |
E ---------------O |
| / | |
| / | |
E1 ---------O | |
| / | | |
-+-------|-----|-------|---> 1st side scaling
| | | |
V1 V V2


E2 - E1
E = --------- * ( V - V1 ) + E1
V2 - V1

If the picture looks strange in your email client cut and paste it into a text editor without a proportional font, i.e. with a fixed font.

Regards
Friedrich
 
S

Shahid Waqas Chaudhry

Personally, I use the scaling on the PLC side but it could be on the HMI side. A standard function would be very convenient with
The following Inputs:
RawValue:= Analog Input
MinEU:= Minimum Engineering Unit
MaxEU:= Maximum Engineering Unit
The outputs are:
EUOutput:= Engineering Unit Output
Error:= Error Code (for conversion errors)

The formula is as below:

EUOutput = [ Raw * MaxValue / (MaxEU - MinEU) ] + MinEU

where MaxValue is the Digital value corresponding to 20mA (You can find this
from the user/module manual)

You can add some code for the error conditions (eg below/over range etc) if
required. Preferably, you should use a signed float/real value for the EUOutput or signed integer. Then it is a simple exercise of copying the tag to the HMI. I hope this is helpful.

Best Regards,
Shahid Waqas Chaudhry
System Integrator
[email protected]
 
Top