Equivalent of BTD in 500

AshleyParr

Member
Join Date
Dec 2008
Location
Midlands, UK
Posts
184
Hi guys,

I have been playing around with an ethernet ip device, it send me data in bytes (12xSINT). This is no problem in logix 5000 as i have used BTD instruction & then played around with the COP as the bits were sent in the correct order.

Now how ever i am trying to do the same with logic 500 and experiencing some difficulties. Mainly the bytes appear to be retrieve in the opposite order and then:
  • The first four bytes should be a DINT but are split into N7:0 & N7:1
  • The Second four bytes should be a DINT but are split into N7:2 & N7:3
  • The two bytes after that should be an INT, so this works ok into N7:4
  • The byte after that needs to be a byte, in N7:5
  • The byte after that needs to be a byte, in N7:6

Is there a way to replicate what i did in 5000 in 500?

Thanks in advance,
Ash
 
Not sure I fully understand what you're trying to do. If your bytes are out of order, you can use the SWP instruction in Logix500.

The down & dirty way to get around the lack of BTD instruction would be to move each bit one at a time (XIC N7:5/8 OTE N7:6/0, etc.) If, as I suspect, you want to move the most significant byte of N7:5 into the least significant byte of N7:6, you could do MVM N7:5 16#FF00 N7:6 and then SWP #N7:6 1. The MSB in N7:5 could be cleared by AND N7:5 16#00FF N7:5. There might be a better way to do this, but we'd need an explanation of specifically what your goal is with this data.
 
OK i apologise for not making much sense, it was late on for me when i posted that and i got a few things mixed up.

I will tackle my first issue first, as that seems to make sense,

I have 4 bytes now going into 2 integers, N7:0 & N7:1. I have checked the bits and all match but I then need to convert this into a floating point value, i tried this by using the COP instruction but this does not give the correct value.

Any ideas on creating a float from these two integers?

Thanks,
Ash

---------------------------------
Edit: Ok iv just been playing around and i think ive cracked it

MVM N7:0 FF00 #N7:1
MVM N7:1 FF00 #N7:0

Does that make sense?
 
Last edited:
The COP (or CPW) instruction should work to convert a floating point bit pattern from two INTs into a single float. Which instruction and how to set the length depends on which processor you're using.

The SWP instruction can swap the bytes with integers for you (not sure if this is available in all models supported by RSLogix500).

The MVM is a good way to strip the upper bits away from an INT which has a SINT as the lower sixteen bits.

There are also LINTs in certain Micrologix models so you might be able to copy your numbers into a LINT if you need to represent a long integer. Even in the SLCs without LINTs, there are double word math instructions available and ways to perform math on a long integer if the need arises.

I have also seen three ways of moving the upper 8 bits of a word down to the lower 8 placeholders: 8 consecutive BSR instructions, brute force mapping to another word, and using a DIVide by 256.
 
I have 4 bytes now going into 2 integers, N7:0 & N7:1. I have checked the bits and all match but I then need to convert this into a floating point value, i tried this by using the COP instruction but this does not give the correct value.

Any ideas on creating a float from these two integers?

OK, now I think I understand what you're after. This sounds very similar to what this technote discusses, among others, regarding sending 32-bit data to/from a 16-bit controller. You've got the same thing going on with your SLC.

You essentially have two words, it's up to you to determine which is MSW and which is LSW. Your floating point value will consist of:
(MSW * 65536) + (LSW converted to an unsigned value)

Let's assume N7:0 is the LSW. You can convert this to float F8:0 by the attached pic.

Then, assuming N7:1 is the MSW, multiply this by 65536 and store in F8:1. Then add F8:0 & F8:1 to get the final value.

Edit: Ok iv just been playing around and i think ive cracked it

MVM N7:0 FF00 #N7:1
MVM N7:1 FF00 #N7:0

Does that make sense?

No, i don't think that will work. Read up on the SWP instruction in the help file.

16bit Unsigned to Float.jpg
 
...The SWP instruction can swap the bytes within integers for you (not sure if this is available in all models supported by RSLogix500).

The MVM is a good way to strip the upper bits away from an INT which has a SINT as the lower eight bits.

Corrections in red...
 
Same as the above i.m facing problem in getting AB 842D encoder values in AB SLC5/04 PLC.
I.m getting values in two integers say I2.1 & I2.2. In I2.1 i.m getting negative to positive values if rotate encoder in one direction also...
Same encoder is working fine in AB 1769 L30ER PLC, getting values in DINT directly....

Plz give suggestions.
 
Harish,
1. It's usually better to start a new thread rather than post on one that's three years old.
2. Have you tried what was suggested above? Please report with details so someone can assist further if needed.
 

Similar Topics

I am rewriting a program for AB CPX, for SMC electric actuators. I have used both IO-Link and Ethernet/IP with AB CPX, and the most helpful...
Replies
13
Views
4,503
Hello to all, I know there are a few people here very experienced with Codesys. I wonder does Codesys have something similar to OB35 in STEP7...
Replies
3
Views
616
Does anyone know the S7 equivalent of the Mitsubishi Q-Series command PLF? PLF is a one-cycle pulse on the falling edge of the input signal. See...
Replies
5
Views
554
Is there an equivalent Rockwell PLC NOP instruction that is available for the M340 M580 Schneider PLC? Thanks,
Replies
10
Views
2,711
I used GSV to get the current status of older 1769 I/O modules. What is the equivalent for new 5069-I/O ? I know individual points/channels have...
Replies
0
Views
1,015
Back
Top Bottom