Analog Input

brent4169

Member
Join Date
Sep 2006
Location
dallas
Posts
7
I am working on a project using a SLC 500 with an analog input module. I need to read in the voltage which ranges from 0 to 10 volts and output the voltage to an ASCII string through the serial port. I need to have the message say something like " The voltage is 8.4 volts. " etc.... I have figured out how to scale the voltage and convert it to a string. My question is how do you go about capturing the floating point portion of this number and convert it to a string? Any ideas?
 
For scaling the Input use SCP inst for 5/03 to 5/05 & SCL inst for 5/01 to 5/02


In SCP Input is the your anlog input address

I:X.Y where X is the slot of the module & Y is your analog input connected channel
Input max 16384

Input min 3277
Output max 10
output min 0

output F8:0
 
Depending on your application, this may work:
Instead of scaling to a floating point, scale to an integer, with an implied decimal.

Use 0-100 as your scaling min and max. Then convert the integer to ascii, test the value of your input if it's equal or greater than 10 put a decimal character after the first two characters, else after the first one. Once you have your string "built" send to the comm. port.
 
Here is a description of some logic that will convert your floating point number into two integers; the integer value to the left of the decimal point and the integer representation of the fractional value to the right of the decimal point. Then those two integers are concatenated into a single string value.

This is essentially the logic discussed in the link provided by rPraveenkum. Since the MOV is going to round, this logic takes care of rounding. This does not include the logic for negative numbers, but then you said you want values from 0 to 10.

Let's say the floating point value you want to convert is in F8:10.
1) Move F8:10 to N7:10 (This creates the rounded value of you floating point number.)
2) Subtract F8:10 - N7:10 = F8:11 (This creates a preliminary fractional value.)
3) If F8:11 < 0, then Sub N7:10 - 1 = N7:11 Else F8:11 >= 0, then Move N7:10 to N7:11 (This take care of rounding, so N7:11 now contains your whole number component. Use branching in one rung for this logic.)
4) Subtract F8:10 - N7:11 = F8:12 (This is the real fractional component of your number.)
5) Multiply F8:12 X 10 = N7:12 (This puts the factional component of your number into an integer. You need to multiply by what multiple of 10 you want for the resolution. That is, if you want 10th, multiply by 10; if you want 1000th, multiply by 1000.)
6) Convert (AIC) N7:11 to ST10:1 (Your whole number component is now a string.)
7) Convert (AIC) N7:12 to ST10:2 (Your fraction component is now a string.)
8) Concatenate (ACN) ST10:1 and "." to ST10:3 (Concatenate the whole number with the decimal point. For example, you can put the decimal point in ST10:0 and use ACN ST10:1 ST10:0 ST10:3.)
9) Concatenate (ACN) ST10:3 and ST10:2 to ST10:3 (Concatenate the whole number and decimal string with the fractional component string and your floating point number is not a string in ST10:3.)
 

Similar Topics

I'm having trouble calming down 2 Tempo Sonics. I'm using Studio 5000 CompactLogix my Raw value is jumping around from 8575.0 to 8755.0 at a...
Replies
30
Views
1,136
I cannot add SLC500 analog input tag (I: 8.3) to EZSeries Touch Panel Editor (V 5.3). I used all the listed tag datatype but it all says "Invalid...
Replies
10
Views
257
Hi, I have questions. I have Analog Input that need to put into Ignition Designer. But I don't know how to put?
Replies
1
Views
118
Omron AD081-V1 Analog Input Card Offset & Gain Adjustment Entering Adjustment Mode 1. Set the input card in adjustment mode (Turn ON Dip SW No-1)...
Replies
0
Views
87
Why AMIo800 Analog input module's I/O LED is Lighting up Red? Checked module connections, 4-20ma wires etc but this light is continuously Lighting...
Replies
1
Views
112
Back
Top Bottom