Sign in to follow this  
Followers 0
Michael Lloyd

Logix 5000 Bool to Int to Bool Question

4 posts in this topic

I have a little routine that I use for controlling a test timer. The original version used an array called Byp_Toggle of the type INT. The routine checks the word and if it's not 0 then it starts a timer. I use bits in the word and the Timer.TT to enable a timed jump around a shutdown for testing. If the "tester" turns the bit off, the timer stops and the shutdown is enabled. If the tester FORGETS to turn the bypass off the timer times out and the shutdown is enabled and the word is cleared (set to 0). It works fine as it is but, we recently switched to Kepware and apparently Kepware doesn't easily support writing to bits of a word. I've changed all of my other arrays to BOOL[32] and they work fine. For some reason I'm two blocked on how I can read the BOOL[32] array as a DINT and use that to start the timer when it's not 0 as well as turning all of the bits off in the BOOL[32] array when the timer goes off or all of the DINT bits are zero I attached the original logic to help make it more clear what I am trying to do. BYP_TOGGLE in the original version is an INT. In the attached file, I have already changed it to BOOL[32] and it's causing errors in the routine. I understand why it's causing errors, I'm trying to figure out a way to make the "idea" work with a BOOL[32] array without doing something kludgey (like adding all of the bits up and putting them into a word). Test_Timer.zip

Share this post


Link to post
Share on other sites
I'd try to COP or CPS the BOOL[32] array into a newly created DINT tag, which you could then examine at bit or word level. "Important: You must test and confirm that the instruction doesn’t change data that you don’t want it to change. The COP and CPS instructions operate on contiguous memory and perform a straight byte-to-byte memory copy. In some cases, they write past the the array into other members of the tag. This happens if the length is too big and the tag is a user-defined data type."

Share this post


Link to post
Share on other sites
CPS and COP do not work with a Boolean array. That's one of the reasons that I used an INT for my original version. I can brute force this thing with a structured text file if I have to. I can map each bit of the BOOL[32] array to bits in a DINT and then, in a separate structured text file I can set the BOOL[32] array bits to zero and when the zero portion of the subroutine triggers (timer times out) I can call that subroutine. I won't need the branch in the first instruction if I do that. I was hoping for a simpler way to do it but I think I can make it work

Share this post


Link to post
Share on other sites
Oops... jumped on this one too soon. You are correct. I can change Byp_Toggle to a UDT and do exactly what I need to do. Thanks!

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