Guest Guest_MrJensen Posted June 10, 2005 Report Posted June 10, 2005 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? Quote
JesperMP Posted June 10, 2005 Report Posted June 10, 2005 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.