You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old October 25th, 2002, 05:35 PM   #1
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,735
How to copying bits from a float to bit file using AB.

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.
  Reply With Quote
Old October 25th, 2002, 06:12 PM   #2
Ron Beaufort
Lifetime Supporting Member
United States

Ron Beaufort is offline
 
Ron Beaufort's Avatar
 
Join Date: Jul 2002
Location: Charleston, SC
Posts: 5,443
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:
Quote:
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.
__________________

2-B ?
Best regards, ----+----] [----+------------( )----
Ron | |
PLC Training Boot Camp | 2-B |
+----]/[----+

I once was lost, but now am found, was blind, but now I see.


Last edited by Ron Beaufort; October 25th, 2002 at 06:24 PM.
  Reply With Quote
Old October 25th, 2002, 06:24 PM   #3
Allen Nelson
Member
United States

Allen Nelson is offline
 
Join Date: Apr 2002
Location: West Chester, PA
Posts: 1,368
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.
__________________
©¿©¬
  Reply With Quote
Old October 25th, 2002, 06:37 PM   #4
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,735
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.
  Reply With Quote
Old October 25th, 2002, 06:38 PM   #5
Ron Beaufort
Lifetime Supporting Member
United States

Ron Beaufort is offline
 
Ron Beaufort's Avatar
 
Join Date: Jul 2002
Location: Charleston, SC
Posts: 5,443
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.
__________________

2-B ?
Best regards, ----+----] [----+------------( )----
Ron | |
PLC Training Boot Camp | 2-B |
+----]/[----+

I once was lost, but now am found, was blind, but now I see.

  Reply With Quote
Old October 25th, 2002, 06:40 PM   #6
Ron Beaufort
Lifetime Supporting Member
United States

Ron Beaufort is offline
 
Ron Beaufort's Avatar
 
Join Date: Jul 2002
Location: Charleston, SC
Posts: 5,443
give me a few minutes - I've been working this with an SLC-5/04 - let me fire up a Micro1500 and try it out
__________________

2-B ?
Best regards, ----+----] [----+------------( )----
Ron | |
PLC Training Boot Camp | 2-B |
+----]/[----+

I once was lost, but now am found, was blind, but now I see.

  Reply With Quote
Old October 25th, 2002, 06:49 PM   #7
Ron Beaufort
Lifetime Supporting Member
United States

Ron Beaufort is offline
 
Ron Beaufort's Avatar
 
Join Date: Jul 2002
Location: Charleston, SC
Posts: 5,443
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.
__________________

2-B ?
Best regards, ----+----] [----+------------( )----
Ron | |
PLC Training Boot Camp | 2-B |
+----]/[----+

I once was lost, but now am found, was blind, but now I see.

  Reply With Quote
Old October 25th, 2002, 06:57 PM   #8
Ron Beaufort
Lifetime Supporting Member
United States

Ron Beaufort is offline
 
Ron Beaufort's Avatar
 
Join Date: Jul 2002
Location: Charleston, SC
Posts: 5,443
guys,

the following note DOES appear in the online instruction help file under the COP section:
Quote:
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.
__________________

2-B ?
Best regards, ----+----] [----+------------( )----
Ron | |
PLC Training Boot Camp | 2-B |
+----]/[----+

I once was lost, but now am found, was blind, but now I see.

  Reply With Quote
Old October 25th, 2002, 09:04 PM   #9
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,735
Quote:
Originally posted by Allen Nelson
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?
  Reply With Quote
Old October 25th, 2002, 09:17 PM   #10
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,735
There appears to be a difference between SLC and MicroLogix.

Quote:
Originally posted by Allen Nelson
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.
  Reply With Quote
Old October 26th, 2002, 08:02 AM   #11
Allen Nelson
Member
United States

Allen Nelson is offline
 
Join Date: Apr 2002
Location: West Chester, PA
Posts: 1,368
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?
__________________
©¿©¬
  Reply With Quote
Old October 26th, 2002, 10:36 AM   #12
Kim Gold
Member
Canada

Kim Gold is offline
 
Kim Gold's Avatar
 
Join Date: Jun 2002
Location: Stoney Creek, Ontario
Posts: 241
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)
  Reply With Quote
Old October 26th, 2002, 10:53 AM   #13
Ken Roach
Lifetime Supporting Member + Moderator
United States

Ken Roach is offline
 
Ken Roach's Avatar
 
Join Date: Apr 2002
Location: Seattle, WA
Posts: 14,263
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......
  Reply With Quote
Old October 26th, 2002, 11:41 AM   #14
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,735
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.
  Reply With Quote
Old October 26th, 2002, 01:41 PM   #15
Ron Beaufort
Lifetime Supporting Member
United States

Ron Beaufort is offline
 
Ron Beaufort's Avatar
 
Join Date: Jul 2002
Location: Charleston, SC
Posts: 5,443
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.
Attached Files
File Type: zip convertf.zip (14.7 KB, 39 views)
__________________

2-B ?
Best regards, ----+----] [----+------------( )----
Ron | |
PLC Training Boot Camp | 2-B |
+----]/[----+

I once was lost, but now am found, was blind, but now I see.

  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
signed and unsigned guest LIVE PLC Questions And Answers 13 September 12th, 2017 01:45 AM
Sequencers randy LIVE PLC Questions And Answers 43 December 20th, 2014 03:10 PM
10 Bit Encoder Decoder/ GE90-30 Control Freak LIVE PLC Questions And Answers 6 July 12th, 2005 12:28 PM
Data Tables bosshen LIVE PLC Questions And Answers 5 April 28th, 2003 07:30 PM
word to bit or bits by themselves.. to excel??? Altair LIVE PLC Questions And Answers 3 March 30th, 2003 12:57 AM


All times are GMT -5. The time now is 05:42 AM.


.