PLCisInteresting

Count Empty Cell in Array

2 posts in this topic

Hi, I got a project that need to use the count empty function in certain array set that I need use it to determine the gap between an object to another object. For example: Length of a conveyor is 1000mm and I use array of create a set of 10mm gap between each cell array[1..100]of bool and in front of a object detection sensor to indicate the object coming in. The next object come in and also detected by this sensor in line. Now I want to use this empty gap to identify the faulty object which mean if the 1st object and the 2nd object stick too near within the gap i set then this both object will be shown fault. Need help from expert. Thanks.

Share this post


Link to post
Share on other sites

I wrote a quick Function to do this.  The input to the function is the array of bools.  The output is to UINTs that report the location of the first two bits that are on in the array.

In this example, I have bits 8 and 15 on.  After executing the function, it returns an 8 and 15 in the two output variables as shown below:

BoolArray.jpg.db2eef945a26f29094859ee558

Then you could do a subtract between the two to determine the distance - you could put this inside the function if you so choose and have it return the length.  Hopefully this is what you are trying to do.

Here is the code:

FindBits.smc2

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