Sign in to follow this  
Followers 0
Guest Guest_MrJensen

Pointer

2 posts in this topic

Hey, I have 5 bytes i a DB which I have to evaluate. They are updated each 20 MS. They bits are representing each one grid on an advanced light grid. The ligth grid is used to check when an object i in front of it. How do I evaluate each bit to test which grid is the lowest covered? I guess i have to use some kind of pointer to run through the bits? Any ideas?

Share this post


Link to post
Share on other sites
You dont have to use pointers. Make a small FC to do the job. Pass the Bytes via an input pin on the FC. Inside the FC transfer the byte value to a dummy Merker (i.e. MB10). Then you can evaluate the bits like this: L #Inputbyte T MB10 L 0 //"0" means no bit is set. T #outputval A M10.0 JCN nxt1 L 1 T #outputval JU end nxt1: NOP 0 A M10.1 JCN nxt2 L 2 T #outputval JU end nxt2: NOP 0 A M10.2 JCN nxt3 L 3 T #outputval JU end etc.. nxt7: NOP 0 A M10.7 JCN end L 8 T #outputval end: NOP 0 There are many other ways to do it. The above example is very simple. A more elegant method would be using a loop.

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