Sign in to follow this  
Followers 0
waterboy

How to Count Registers that <> 0 ? in PLC-5

10 posts in this topic

Using PLC-5 I am looking for a way to count how many N registers within a certain range are greater than zero -I cant come up with a ladder technique so I was gonna use STX. Before I do that, anyone have a thought how to do this in ladder?

Share this post


Link to post
Share on other sites
Will the starting and ending N registers be constant? If so, then you could use a for next loop and indirect addressing with a compare to check if each register is equal to zero or not.

Share this post


Link to post
Share on other sites
Yep... that worked... Didn't even occur to me there was a FOR instruction in ladder. I gotta give up the decaf. Now if only there was an IF . . . Thanks Ken

Share this post


Link to post
Share on other sites
In a PLC-5 I would use the FSC instruction then on each "TRUE" comparison add 1 to an "INT" by using the ".FD" bit and resume scan y resseting the ".IN" bit.

Share this post


Link to post
Share on other sites
I looked at that too but I thought that instruction stopped looking at the first find?

Share this post


Link to post
Share on other sites
That is correct, that is when you add to your count and resume the scan by resseting the .IN bit. The instruction hasn't completed until the .DN bit.

Share this post


Link to post
Share on other sites
Ah, I misunderstood what the .IN did then. I'll try that too, thanks!

Share this post


Link to post
Share on other sites
You could do it in ladder, with labels and jumps.

Share this post


Link to post
Share on other sites
Basically any instruction not in the right hand column.

Share this post


Link to post
Share on other sites
No problem, If you are expecting a greater number of "TRUE" results then I would also change the comparison to #INT = 0 . Then subtract the total count from R6.*.Len. As the FSC waits for an action on each "TRUE" comparison.

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