Extract part of an integer in MicroLogix 1100

Nortech

Member
Join Date
Mar 2018
Location
Spain
Posts
59
Hi All,

I am communicating with a cognex camera from a MicroLogix over EIP.

I am reading in a part count and a Pass/fail (1 or 2).

My issue is that the two integers are being written into the same int file (N15:1). When I view them as HEX I am seeing 3802 for example. When you separate this it reads 38 02, which in HEX means 56 2 which is 56 bottles and a fail, which is correct and accurate every time.

Is there a way to use the EQL command for the first half of the int N15:1?

Maybe something line N15:1.Data[1] or something like that?

Any help is much appreciated, thanks in advance.
 
Try looking at mask moves MVM, you will move the first have to another N file then you can do a = to
 
Isolating the bottom half of the word is easy, just AND N15:1 with 255 (or FFh) and put the result in another register. This will clear out the top half of the word and leave you with 02 using your example.

The top half is a bit trickier because you have to shift the bits too. Do an AND on N15:1 with FF00h, this will clear out the bottom half of the word. Then divide the resulting value by 256 and you will have your answer. Dividing by powers of two shifts bits to the right in a word, 256 = 2^8. This method breaks down with signed numbers though so you can't use it if bit 15 is on--which means the value can't be larger than 2^7 or 128.
 
Last edited:
The BTD instruction is what you want. Take a certain number of bits starting from here and put them in another tag starting there. Make sure you clear the destination word before you execute the BTD, because the BTD won't "turn off" any bits outside of it's effective area that may have inadvertently be turned on, and will give you errors.
Disclaimer: I'm not 100% certain that the BTD is supported in the micrologix processors. I don't work with them much any more! If not, MVM or AND with some bit shifting as the people above have suggested is the way to go.
 
Disclaimer: I'm not 100% certain that the BTD is supported in the micrologix processors. I don't work with them much any more! If not, MVM or AND with some bit shifting as the people above have suggested is the way to go.

I don't think the BTD was available in RSLogix 500 at all, no matter what processor.
 
It should be simple to strip off the data you want in just a few steps
Step 1
Move the lower 2 HEX words by using a MVM function (Masked Move) to a new Integer
This would give you the 02 value for failed count (N15:10)
Step 2
Shift the second 2 HEX words to the right 8 bits using the SBR function (Shift Bit Right) to a new integer. This will give you parts count (N15:11)
This should be all you need to
Play around with the Bit Shift to get it right
 

Similar Topics

Hi everyone. Quick questions. On UnityPro, I want to open and quickly read tags from a .STA files witouth opening the program. I have 30 plc...
Replies
2
Views
130
Hi all, I am working with an IO link sensor (measuring current across motor)and need to read in and store the sensor values for 5 seconds, then...
Replies
13
Views
1,200
Customer has a circa 2004 SLC-500 PLC. Fieldbus is a 1747-SDN DeviceNet scanner. Customer has SLC-500 file (.rss) with no comments. Has no *.dnt...
Replies
7
Views
549
Hi guys, I need a GSD file for the following sinamics drive (S120). IO Device SINAMICS S120 CU320-2 PN V4.4 PN-V2.2 with DriveES/SIMOTION...
Replies
6
Views
1,390
I would like to extract data from a Bizerba is50 using WebSockets or Profinet. I currently cannot find any information on the subject, any help...
Replies
1
Views
717
Back
Top Bottom