Jump to content

Pointer


Guest Guest_MrJensen

Recommended Posts

Guest Guest_MrJensen
Posted
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?
Posted
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.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...