|
Boolean Logic Using Binary
I've seen a lot of posts asking how to turn motors using joystick buttons and limit switches and the like. So here's something I cooked up that I thought I'd share.
It's a vi that takes an array of booleans, converts it to 1's and 0's, then outputs the decimal value as if it was a binary number. What this allows you to do is build an array of booleans from joystick buttons and limit switches, wire it to the vi, then wire the decimal value into a case structure. Now you can add cases for different combinations of booleans and do different things for those cases.
An example: Say you want three joystick buttons to control a motor, one for forward, one for backward, and one for stop. Build these into an array, wire it into the vi, and wire the output into a case structure. Now add cases for 4, 2, 1, and 0, with 0 being default. 4 corresponds to the first button on and the others off, 2 corresponds to the second button on and the others off, 1 corresponds to the third button on and the others off, and 0 is what you want to do for all the cases you're not considering.
This might not make sense, but download the vi and try it, see what case is selected when you press different buttons. I hope this vi can help some people, as well as clean up some block diagram.
Thanks for reading and good luck!
Last edited by Luke Pike : 05-02-2009 at 23:11.
|