How to copying bits from a float to bit file using AB.

Join Date
Apr 2002
Location
No income tax, no capital gains tax. Freedom!
Posts
8,351
I have a Micrologix 1500. I need to copy a bits from a floating point file into a bit file. I have tried using the COP and the MOV command, but I keep on getting overlow errors in the case of the MOV command and data size errors in the case of the COP command. The COP documentation on the on-line help says I should be able to copy between two different data types but it will not let me copy floats to bits. The COP command does not work as documented. I tried using

COP #F8:41 #b3:2 64

The documentation said that the lenght is specified in destination usings and I want to copy 64 bits worth of data.

You may ask why do I need to do this? A msg block reads 8 floats from a smart device. 7 of the floats are really floats, but one of the floats is really just a bunch of status bits that must be copied to a Bit file to make sense of them. Otherwise two msg blocks would be required. One to get the floating point values and another to get the status bits. This requires more msg block and time and I and my customers don't want to use two msg blocks.

Surely someone has done this before.
 
Peter,

As long as the floating point value stays between +32767 and -32768 you should be able to MOV (move) the floating point location (example: F8:0) into a binary location (example: B3:0) or into an integer location (example: N7:0) with no trouble. Do this in your “receiving” PLC. Once you have the value (bit pattern) properly stored in a binary or an integer location, then you should be able to decode the bits in the normal manner.

I think that the problem you are having stems from the fact that floating point numbers are stored in TWO words - using the IEEE 754 standard for Single precision floating point format. You can read about this format if you’re into that sort of thing at:

http://www.ab.com/manuals/cp/1747-rm001c-en-p.pdf

see Adobe page 544 of 582 - or book page F-6.

If your floating point "status" word does not stay between the values given above - then you’ll have to do some conversions on the floating point value to MAKE it fit into a binary or integer location. Or maybe consider adding one more floating point to your message length and breaking the "status" pattern into two separate float locations on the "sending" end. I’ve never had ANY success decoding a floating point value into a usable bit pattern.

Hope this helps - offline until Monday.

PS - if this doesn't do it - post again with some actual "problem" values and memory addresses that you're working with. I MIGHT get a chance to work on the conversion this weekend.

Edit PS - you said:
I tried using

COP #F8:41 #b3:2 64

The documentation said that the lenght is specified in destination usings and I want to copy 64 bits worth of data.

The 64 on the end of that command is for 64 words - not bits. Could this be what's bugging you? For the record: a binary word (B3:0) contains 16 bits - an integer word (N7:0) contains 16 bits - but a floating point location (F8:0) is made up of 32 bits (two words) - but the floating point bits are set up in the "sign-exponent-mantissa" format as described in the link above.

Good luck.
 
Last edited:
Peter:

If only one float is really (32) bits, then why copy all eight floats?

As Ron said, floats are 2-word elements.

When using the COP command (which will do what you want, the MOV command will not), and you are mixing data types (like floats and integers), it is the destination element that determines the number of words transferred.

For example, the command

COP #F8:0 #N7:0 4

will take the 2-word element F8:0 and break it into N7:0 and N7:1, and F8:1 will go into N7:2 and N7:3. 4 Integer words come from 2 Float elements.

Conversely

COP #N7:0 #F8:0 4

Will have N7:0 and N7:1 go into F8:0, N7:2 and N7:3 go into F8:1, N7:4 and N7:5 go into F8:2, and N7:6 and N7:7 go into F8:3. 4 float elements come from 8 integer words.

By having a length of 64 in your COP instruction, you were trying to get 32 floats into 64 binary WORDs (=1024 bits!). That's why you got the overflow error - you were trying to address data tables that didn't exist.

You probably want a simple

COP #F8:48 #B3:2 2

to get the bits out of the floats.
 
This is beginning to look like a MicroLogix bug

Ron,

I tried

COP #F8:41 #N7:0 1
COP #F8:41 #N7:0 2
COP #F8:41 #L10:0 1
COP #F8:41 #L10:0 2

The COP command does not let one copy from a float file to any other type of file which is contrary to the documentation.

MOV works as you suggested. I can copy a FLOAT to a LONG too. That will do but the customers would rather have this data in a bit file.

This topic has come up in the past and I know that I have copied a float to two integers on a SLC.
 
Yo, Allen,

I've never used your "one-float-into-two-binaries" COPY idea. You're right (I just tried it) - he can move the two words of ONE floating point into two binary words with a COP command. But I've got a sneaky feeling that the original "status" bit pattern might be scrambled during the transfer - due to the format mentioned above. I wish I had time to work through this before I go home - now my curiosity is going to drive me nuts all night.

Have a good weekend.
 
OOPS, the SLC-5/04 will do it - but the MicroLogix1500 won't - it gives me "Operand sizes do not match" when I try to verify the rung.

What's your deadline on this? I've GOT to work this out myself. Maybe I'll have something Monday. I'll race you guys.
 
guys,

the following note DOES appear in the online instruction help file under the COP section:
Note: When using the MicroLogix 1200 and MicroLogix 1500 controllers, the Source and Destination file types must be the same. There are exceptions, however. To read more, click this link

but the "exceptions" link given doesn't help us out though -

Gotta go - my wife is calling me to come home.
 
Allen Nelson said:
Peter:

If only one float is really (32) bits, then why copy all eight floats?

As Ron said, floats are 2-word elements.

When using the COP command (which will do what you want, the MOV command will not), and you are mixing data types (like floats and integers), it is the destination element that determines the number of words transferred.

For example, the command

COP #F8:0 #N7:0 4

will take the 2-word element F8:0 and break it into N7:0 and N7:1, and F8:1 will go into N7:2 and N7:3. 4 Integer words come from 2 Float elements.

Conversely

COP #N7:0 #F8:0 4

Will have N7:0 and N7:1 go into F8:0, N7:2 and N7:3 go into F8:1, N7:4 and N7:5 go into F8:2, and N7:6 and N7:7 go into F8:3. 4 float elements come from 8 integer words.

By having a length of 64 in your COP instruction, you were trying to get 32 floats into 64 binary WORDs (=1024 bits!). That's why you got the overflow error - you were trying to address data tables that didn't exist.

You probably want a simple

COP #F8:48 #B3:2 2

to get the bits out of the floats.


I only need one or two words out of the 8 floats. I have tried what you suggest. The micrologix does not work the same as a SLC. The SLC does what you suggest but the Micrologix does not let one copy floats to another type. It will not even compile.

Now I know the a binary data element is a word and not a bit. I tried all combinations and nothing worked so it was hard to tell what was right.

Have you done this with a MicroLogix?
 
There appears to be a difference between SLC and MicroLogix.

Allen Nelson said:
Peter:

If only one float is really (32) bits, then why copy all eight floats?

As Ron said, floats are 2-word elements.

When using the COP command (which will do what you want, the MOV command will not), and you are mixing data types (like floats and integers), it is the destination element that determines the number of words transferred.

For example, the command

COP #F8:0 #N7:0 4

will take the 2-word element F8:0 and break it into N7:0 and N7:1, and F8:1 will go into N7:2 and N7:3. 4 Integer words come from 2 Float elements.

Conversely

COP #N7:0 #F8:0 4

Will have N7:0 and N7:1 go into F8:0, N7:2 and N7:3 go into F8:1, N7:4 and N7:5 go into F8:2, and N7:6 and N7:7 go into F8:3. 4 float elements come from 8 integer words.

By having a length of 64 in your COP instruction, you were trying to get 32 floats into 64 binary WORDs (=1024 bits!). That's why you got the overflow error - you were trying to address data tables that didn't exist.

You probably want a simple

COP #F8:48 #B3:2 2

to get the bits out of the floats.


I only need one or two words out of the 8 floats. I have tried what you suggest. The micrologix does not work the same as a SLC. The SLC does what you suggest but the Micrologix does not let one copy floats to another type. It will not even compile.

Now I know the a binary data element is a word and not a bit. I tried all combinations and nothing worked so it was hard to tell what was right.

Have you done this with a MicroLogix?

Ron, I am making a motion controller that should communicate nicely with a MicroLogix. The motion controller must return positions, velocity, outputs and status bits. During the design specification, we decided that we would read a status block of floating point numbers that includes the above. We then assumed ( bad, bad, bad ) the SLC and MicroLogix could use the COP command to copy the floating point value, that is actually status bits, into a bit file.

At this time I can only MOV a floating point number into an long on a micrologix. This is usable but it would be nice work the same on both SLCs, MicroLogix, and ControLogix. It is less confusing for the user.

I will verity that COP #f8:41 #B3:2 2 works in a SLC next week. I know that COP #F8:41 #N7:0 2 works on a SLC.
 
The problem with being an expert is that you think you know everything...

Peter:

You're right - I've never tried this on a Micrologix. My projects are never so small that a Micro is used.

Like Ron, I'm trying to see if there are any program tricks that could be used. While I don't have a 1500, I've got Emulate500, which I'm hoping will do.

When I try to enter the rung COP F8:41 B3:0, I get the error message "Invalid File Type for Processor" - i.e., the Micrologix doesn't support Floats.

Now I'll admit my version of RSLogix500 is a little old (v. 4.5, ©2000) so perhaps there's a firmware revision that allows floats. The only types of 1500 that I have the option of programming are the 1500-LSP Series A, -LSP Series B, and -LRP Series B. What your's?

I don't suppose that could be your problem, could it?
 
I tried this using RSEmulate 500.
Processor: MicroLogix 1500 Series C

When trying: COP #F8:0 #N7:0
I got a message OPERAND SIZES DO NOT MATCH.

But MOV F8:0 N7:0 or MOV F8:0 B3:0 worked fine.

Try moving 1 word at a time without using the # (indexed addressing)
 
The MicroLogix 1200 and 1500 have an unusual instruction called CPW (Copy Words) that was introduced in Series C, Firmware Revision 6 (Sept '01, along with RSLogix 500 version 5.0).

This instruction may be different enough from the COP instruction to do what Peter wants; I don't have a Bulletin 1764 processor right here so I can't test yet.

And I *swore* I wouldn't go into the office this weekend......
 
Ken take a break

Ken,

I don't have any production line depending on this information. I will check it out on Monday. My RSLogix is 5.00 and the firmware was just updated about a month ago for this project.

I really don't do much PLC programming, but when I do I seem to find the oddities.

Ken, if you have any pull with the firmware gurus in MicroLogix land, I would like to suggest:

In a next firmware revision, make the MicroLogix do the COP in the same manner as the SLC. I believe in fewer instructions and more consistency. It looks like this problem would have bit everyone and will confuse others in the future.

To the RSLogix programmers:

RSLogix register file data windows should remember the size, columns and number format when the window is closed so that it will be restored to exactly the state as when the window is reopenned. Better yet would be to allow each word to be formated individually so that some can be in hex, others in decimal and others in binary. These suggestions would save much time of the users of RSLogix.
 
Peter,

Maybe this will help - IF you can limit the value in your Floating Point "status" word to 24 bits or less. I'm almost certain that anything more than that is going to be out of reach. When I try to use more of the 32 bits in the floating point location, I lose resolution on some of the least significant bits.

Try this out - and when you type in the BIG values into F8:0 don't worry when it shifts into expotential notation. According to my tests, it looks like the DISPLAY loses resolution - but the math still works out OK.

I haven't had time to test it through EVERY possibility - but I think it will perform as described in the rung comments.

PS - I tried using CPW to copy the floats into longs (example: L9:0) and then CPW or MOV back. You can access the bits in the longs (example: L9:0/3) but not within the floats. You can shift the values between floats and longs - but the float formatting scrambles the bit patterns.

Good luck.
 

Similar Topics

I'm not super familiar with the Micrologix line of processors, but I am pretty familiar with RSLogix 500. I'm trying to simply copy a string to...
Replies
4
Views
260
Hi All, I am looking to copy and paste a routine. I know this has to be done offline. My question is, when I go back online, these tags are...
Replies
6
Views
480
Hello everyone, friends. I need help with something related to SCL. In a FB, I need to copy the value in the DB to the DB at another address. I...
Replies
3
Views
1,350
Hello all! Is it possible to COP a SINT array to a UDT structured the same as a SINT array, except all BOOL bits? I have a module that has an...
Replies
5
Views
3,139
Hello, looking for a way to capture and display the accumulated time for a retentive timer in rslogix 500 on a microligix 1400 plc example move...
Replies
3
Views
1,632
Back
Top Bottom