Get feet and inch from total inches

Capman

Member
Join Date
Nov 2014
Location
Virginia
Posts
3
I have a scaled analog input in a micrologix 1200. I can get total feet and total inches. What I am trying to do is display is feet and inch. so for example i want to display 8' 4". if I have 100 inches I can divide by 12 and get 8.33333. how do i get to the next step and get the to derive the inch fro 8.3333. by the way I scales the input to 16ths
 
I have a scaled analog input in a micrologix 1200. I can get total feet and total inches. What I am trying to do is display is feet and inch. so for example i want to display 8' 4". if I have 100 inches I can divide by 12 and get 8.33333. how do i get to the next step and get the to derive the inch fro 8.3333. by the way I scales the input to 16ths

Integer Division will return Feet
Modulo will return inches

Given 12 Inches per Foot
100 INT DIV 12 = 8
100 MOD 12 = 4
 
forgot about that .. no CPT

I guess that basic math will have to work.
Since your resolution is 1/16 you will have a bit more work, but for INCH

aa is FEET
bb is intermediate
cc is INCH
100 INT DIV 12 = aa (aa = 8)
aa * 12 = bb (bb = 96)
100 - bb = cc (cc = 4)

If you can separate the fractional, then you can do the above., and add the fractional back to the display.
 
Last edited:
MicroLogix does not have Modulus.

I believe if you do an integer divide, it will round the result. A workaround for this is to put the value into a Float register, do the divide, subtract 0.5, then move it back into an integer. This will basically give you the truncated value of the divide. Then, multiply the result by the original divisor, and subtract that from the original value and that will be your modulus.

So for example:
100 >> 100.0 (make it a float)
100.0 / 12.0 = 8.333
8.333 - 0.5 = 7.833
7.833 >> 8 (move back to integer; this is your feet)
8 * 12 = 96
100 - 96 = 4 (this is your inches)
 
Check this in the help file on the 'DIV' instruction

The unrounded quotient is placed in the most significant word of the math register; the remainder is placed in the least significant word.

And this from the instruction manual

Use the DIV instruction to divide one value by another value (Source A/ Source B) and place the result in the Destination. If the Sources are single words and the Destination is directly addressed to S:13 (math register), then the quotient is stored in S:14 and the remainder is stored in S:13. If long words are used, then the results are rounded.

(Note: my underlining)

See if you get the result you need.
 

Similar Topics

Hi I'm trying to use a L27erm compact logix controller with high seed input I can see the pulses coming in to a counter but when I look at the...
Replies
1
Views
1,264
Hello, I am communicating MB RTU with a device that will give me a tank level in decimal format but the end user needs the display to be in...
Replies
9
Views
4,183
I'm sitting on my flight marveling at technology. Free WiFi on a Delta flight courtesy of Ebay, 30 minutes at a time. Surprisingly, it's fast and...
Replies
6
Views
2,951
Hi, I have recently bought a T100 transmitter and R100 receiver from Omnex Wireless it is working properly for controling a Tyrex boom...
Replies
1
Views
2,048
Gear Reduction Box = 3.0 Drive Sprocket = 22 Teeth Driven Sprocket = 88 Teeth VFD = PowerFlex 40 I have a VFD controlling the speed of a...
Replies
25
Views
29,556
Back
Top Bottom