Sign in to follow this  
Followers 0
jydepower

Checking if an Array of Bool is 0

16 posts in this topic

Hallo. Ive made an array of bool for all my alarms. The idea was if any Bool wrent 1 i could do something. Now i have a problem finding a function that does that check. Is this possible or do have to use another aproach? Edited by jydepower

Share this post


Link to post
Share on other sites
Per 32 address's you could use K8<Arrayname> not equal to 0

Share this post


Link to post
Share on other sites
Im using ladder in IEC developer. I dont understand K8 :) The array im using i bigger than 100.

Share this post


Link to post
Share on other sites
It standard ladde you can write K4M0 Each K value = 4 bits K4M0 means M0-M15 seen as a 16 bits value K8M0 means M0-M31 seen a a 32 bit value In IEC Developer the same can be done with your an array K8<Arrayname>[0] NE 0 K8<Arrayname>[32] NE 0 K8<Arrayname>[64] NE 0 K8<Arrayname>[96] NE 0 Edited by Gambit

Share this post


Link to post
Share on other sites
You can use static variables like K4M0 but I don't think you can use labels with K*, like you say K8<Arrayname>[0] NE 0. I might be wrong, but I've never been able to use this with labels. Please correct me if I'm wrong. Another option would be to convert to a DINT and then compare to 0 like the picture attached.

Share this post


Link to post
Share on other sites
Kaare your solution is better but as an alternative. Using K8 on a Array is possible. Unfortunately you cannot index anymore Edited by Gambit

Share this post


Link to post
Share on other sites
I actually thought about converting to dint. But thought there might be a function to directly check the array. Ill use what you have made kaare. Thanks for the help both of you.

Share this post


Link to post
Share on other sites
It's actually very nice with the converting function. It made me make groups right away. Like emergency alarms overload alarms etc.

Share this post


Link to post
Share on other sites
M0Z = M0 + [The value of Z]. So basically if we say M0Z, and Z has the value of 4, then M3 will be set/reset. Edited by kaare_t

Share this post


Link to post
Share on other sites
Not sure what you mean, but here's some more examples: Z = 4 -> M0Z = M3 Z = 10 -> M0Z = M9 Z = 15 -> M0Z = M14 As you see, if you index then the value of Z will be added to the value of the M/D and so on. Here's some more examples: Z = 4 -> M100Z = M103 Z = 10 -> M100Z = M109 Z = 15 -> M100Z = M114 Z = 4 -> M1100 = M1103 Z = 10 -> M1100 = M1109 Z = 15 -> M1100 = M1114

Share this post


Link to post
Share on other sites
Hmm must admit im completely lost now. How and where do you define that? (Z = 4 -> M100Z = M103) how do i say this in ladder? Know any guide or something where i can learn to understand this? Remember im still in ladder.

Share this post


Link to post
Share on other sites
Here are some exmples: 1: Basic usage of Z 2: Your application using Z and hardware addresses 3: Your application using index and bit arrays with labels Note that no3 is preferred since you normally don't want to use hardware addresses. Sometimes there's no choice so you must use hardware addresses and then you must use no2

Share this post


Link to post
Share on other sites
I understand your usage of code. But I still don't get the picture of the z indexing. For me it looks like another register. Just like d and w except it only goes from 0-7. And in your post you talk about hardware addresses, I don't see those in your examples.

Share this post


Link to post
Share on other sites
Sorry, I use the word "Hardware addressing" when referring to M, D, W and so on... In essence every address not declared in Header/GVL and used with labels instead of "directly" addressing the address. Yes, Z's are basically an integer in the same way as D's except that you can use them for indexing "hardware addresses". You can try to write M0D0 instead of M0Z and see what happens.

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