A/B Micrologix 1200: converting floating point values?

downey18

Member
Join Date
Feb 2008
Location
Chicago
Posts
37
I am using an AB Micrologix 1200 that contains a counter with a destination of a floating point number. The number can get very large so I need the size that a floating point number can offer, more then 32,768. But I also want to be able to grab certain parts of this number. I am using a OMI that can only display 4 numbers per OMI item on the screen. So if I have the number 345,433, I want to be able to put the 5,433 into the first item on the OMI, and the 34 into the second right next to the first. So the numbers on the OMI look like this: (0034)(5433). So my question is, does anyone know of a way to address certain bits or words in a floating point number? And I cannot use a COP statement as the 1200 family won't let you copy between a floating and an integer.
(n)
 
Last edited:
downey18 said:
I am using an AB Micrologix 1200 that contains a counter with a destination of a floating point number. The number can get very large so I need the size that a floating point number can offer, more then 32,768. But I also want to be able to grab certain parts of this number. I am using a OMI that can only display 4 numbers per OMI item on the screen. So if I have the number 345,433, I want to be able to put the 5,433 into the first item on the OMI, and the 34 into the second right next to the first. So the numbers on the OMI look like this: (0034)(5433). So my question is, does anyone know of a way to address certain bits or words in a floating point number? And I cannot use a COP statement as the 1200 family won't let you copy between a floating and an integer.
(n)

Why not just use two integer counters with a preset of 9999. That would give you 99999999. The lower order counter done would increment the higher order counter. Your display would then just show the values of these two counters. If you need a larger number, use three counters and so-on.
 
Last edited:
Greetings Downey18.

First off, you can copy between a float and an integer in a ML but you use the CPW instruction, not the COP instructon.

However, doing so is not going to help you break your float apart the way you want it. In a float the first bit is the sign bit, the next 8 are the exponent normalized to 128, and the remaining 23 bits are a binary mantissa where the mantissa = 1/2^1 + 1/2^2 + 1/2^3 + 1/2^4.... + 1/2^22 + 1/2^23.

To top it off, although a floating point number can hold large numbers, there is a resolution problem that is systemic to the floating point format, and all computers that use the 32 bit IEEE-754 float format, including the ML1200 PLC, will have the resolution problem. From a practical standpoint it means that you cannot count by ones any higher than 16,777,215. Try adding 1 to 16,777,215 with your PLC and see what happens. Nothing. No matter how many times you add one, the number won't get any bigger.

For counting to really big numbers the best way is to use a long integer (32 bit integer) and the ML1200 supports that. A long integer can count -2,147,483,648 to +2,147,483,647. Two billion plus should be big enough for most applications.

But that brings us to the problem of displaying it on a 4 digit display. The simplest way is to use two cascaded counters as Robert suggested.

However, if you feel so inclined to use a long integer then you can break the long into two 4 digit integers by dividing the long by 10,000 and specifying the math resister, S:13 as the destination and then moving the math register contents to two integers.
ie
DIV L9:0 10000 S:13.
MOV S:13 N7:1
MOV S:14 N7:0

N7:0 contains the quotient or the largest four digits and N7:1 will contain the remainder or the lowest four digits.


EDIT:
Hmmm... I thought this question seemed familiar.
http://www.plctalk.net/qanda/showthread.php?t=37367
 
Last edited:
I guess I didn't really think about using cascading since my number was so large i.e. millions but now I see it doesn't matter the size. I did post previously about a similar problem for binary numbers (for the same project no less) and went with cascading counters before. For some reason my brain didn't make the connection b/t the two :/ Now that I'm thoroughly embarrassed, I appreciate your help robertmee and Alaric.
 
downey18 said:
I guess I didn't really think about using cascading since my number was so large i.e. millions but now I see it doesn't matter the size. I did post previously about a similar problem for binary numbers (for the same project no less) and went with cascading counters before. For some reason my brain didn't make the connection b/t the two :/ Now that I'm thoroughly embarrassed, I appreciate your help robertmee and Alaric.

One little note about using multiple numeric displays. Because of the way a numeric display justifies your number you may have so weird looking screens so you will probably want to play around with it and create several values to display. I have not worked with the Micro pannels but with the larger C-More's you have to play with the justification a bit to make things look right.
 
More problems

Alaric said:
But that brings us to the problem of displaying it on a 4 digit display. The simplest way is to use two cascaded counters as Robert suggested.

However, if you feel so inclined to use a long integer then you can break the long into two 4 digit integers by dividing the long by 10,000 and specifying the math resister, S:13 as the destination and then moving the math register contents to two integers.
ie
DIV L9:0 10000 S:13.
MOV S:13 N7:1
MOV S:14 N7:0

N7:0 contains the quotient or the largest four digits and N7:1 will contain the remainder or the lowest four digits.

Hello,
I'm using the method described above to split my long integer apart, but I'm getting some weird results when I split the number apart. Below is what I am seeing when I take my PLC online:


---------------------
DIV
Source A: L9:0
45739 ;The long number adds fine so the program works up to here
Source B: 10000
10000
Dest: S13
46 ;Why is this rounding up?
--------------------

MOV
Source: S:13
46
Dest: N7:63
46
---------------------

MOV
Source: S:14
457 ;Where is this coming from?
Dest: N7:64
457
----------------------

In other words, in my remainder I'm getting 46 and my quotient is 457 and doesn't change?? I have tried everything I can think of to get past this but I am stuck. I am not using L9:0, N7:63, aor N7:64 anywhere else in the program. I am using math in other places but htat shouldn't affect S:13 and S:14 since the moves are right after the div block. Any ideas??
 

Similar Topics

Hi, all. I am not so familiar with Allen Bradley PLCs. I currently have a (working) MicroLogix 1400 PLC program that I need to convert to...
Replies
1
Views
2,233
Hi everyone, I'm working on a project where I need to exchange data between a Siemens S7-1200 PLC and an Allen-Bradley MicroLogix 1400 PLC. The...
Replies
8
Views
626
I have a MicroLogix 1200 that has an 8 input and a 16 output. Every 6 months-year I get a fault and when online go to error it is something like...
Replies
3
Views
501
Have a bad output on a Micrologix 1200. Moved wire over to an available output, changed program to associate with new output. downloaded program...
Replies
8
Views
751
I need help achieving the following task: ML1200 sending 4 to 20 mA thru analog output ch0 to a DC speed controller analog input(4 to 20 mA) my...
Replies
3
Views
669
Back
Top Bottom