Sign in to follow this  
Followers 0
devo.xx

SLC 5/05 - DWORD Bit compares

12 posts in this topic

Hey guys, So I've posted this before, but I don't have a lot of experience with AB controllers, my background is in Mitsubishi. This time I'm looking for some syntax help that I haven't been able to find in my documentation. I want to use a Bit-String to keep track of the locations of items. Such that when the bit is 1 an item is in that zone, when it is 0 the zone is free/open. I have used this sort of location handling before to detect where my Trolley is compared to where it needs to go: Trolley Loc - 0010 (2 dec) Trolley Dest - 0100 (4 dec) If Trolley Loc < Dest then Drive to the left else if Loc > Dest then Drive to the Right else if Loc = Dest then (run some other code to slow down etc.) In this particular application, I have 18 zones plus 2 on either end for "Nothing goes here." N10:5 N10:4 0000 0000 0000 0100 1001 0010 0001 0010 - Represents the location of my items N10:7 N10:6 0000 0000 0000 0000 1000 0000 0000 0000 - Represents the location of my Trolley N10:9 N10:8 0000 0000 0000 0000 0000 0010 0000 0000 - Represents the destination that the Trolley is driving to I can run a MEQ with my destination to verify that there is an item in that zone. In Mitsubishi I could set up a bunch of Bits and reference them like this: M0 - Just one bit (equivalent B3:0/0) K0M0 - Just one bit K1M0 - Start at M0 and include the next 8 bits K2M0 - Start at M0 and include the next 16 bits (equivalent B3:0) ... etc. up to K128 (The same Kx reference works for Word devices, ie. K1D0 is D0 and the next 8 words.) Is there some sort of Syntax that I can use to check across multiple Word devices or Bit devices?

Share this post


Link to post
Share on other sites
Compare the most significant words for 'Greater Than' or 'Less Than'. If either condition is true you have your answer. But if the first compare is 'Equal To' then compare the least significant words. Use whatever result (Greater Than, Less Than or Equal) as the answer. Edited by b_carlton

Share this post


Link to post
Share on other sites
If there is only 1 trolley wouldn't it be easier to use a single INT for the trolley location and a single INT for trolley destination? Say N10:6 = trolley location N10:7= trolley destination Then if -[XIC]- N10:4/[N10:7] = True There is an item at the trolley destination.

Share this post


Link to post
Share on other sites
I came across that syntax in the documentation but didn't quite understand how to use it... [N10:7] vs N10:7 But for this application, I have 18 locations, plus 2 NUL locations, 20 total. So a single INT won't work, I was hoping for a DINT or DWORD.

Share this post


Link to post
Share on other sites
Looking at my advice again ... with your operational bits including the highest bit in the lowest word then the comparisons become problematic if the high bit in either word is on as the SLC treats the N registers as signed, the top bit is the negative sign. I'll look more deeply into the 32 bit handling capability of the SLC 5/05 tomorrow.

Share this post


Link to post
Share on other sites
This syntax is for indirect addressing. Example: if N10:7 has the value 1 and you have an -[]- instruction with the address N10:4/[N10:7] and bit 1 is on in N10:4 then the -[]- will scan "true" if N10:7 has the value 15 and you have an -[]- instruction with the address N10:4/[N10:7] and bit 15 is on in N10:4 then the -[]- will scan "true" if N10:7 has the value 17 and you have an -[]- instruction with the address N10:4/[N10:7] and bit 17 is on in N10:4 (N10:5 bit 1) then the -[]- will scan "true"

Share this post


Link to post
Share on other sites
I think you will have to do a preliminary determination using the top bits of the lower word. If they are both off then there will be no problem and you can carry out the determination as described before. If both bits are ON then you have an 'Equals' answer and can get out ('final answer) If the top bit of the upper bit is on and the lower WORD is not equal to zero then you have a 'Greater Than'. If the lower word is equal to zero then you have a 'Less Than' If the top bit of the lower word is on and the upper word is not equal to zero then you have a 'Less Than'. If the upper word is equal to zero you have a 'Greater Than' Sorry but there doesn't seem to be a 32 bit compare.

Share this post


Link to post
Share on other sites
N10:4/[N10:7] style addressing is indirect addressing and works similarly to indexed addressing in Mitsubishi. The "[N10:7]" would be equivalent to a Z0, and "N10:4/" would be like an M0: N10:7 = Z0 = 3 N10:4/[N10:7] points to address N10:4/3 M0Z0 points to address M3 Also, if you want to do a 32 bit compare in AB, you have to but the upper and lower registers in adjacent N registers, then COP them to an L register and use the compare instructions on that.

Share this post


Link to post
Share on other sites
I'm guessing L is for "LONG"? I can't make a Data Type for "L"? Edited by devo.xx

Share this post


Link to post
Share on other sites
Which is the primary difficulty

Share this post


Link to post
Share on other sites
My apologies. I do most of my programming on an ML1400, which does have a Long data type. The 5/05 apparently does not.

Share this post


Link to post
Share on other sites
As long as the rung is verified you should be able to monitor the bit you have indirectly addressed in the offline file. *Screenshot attached*

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0