Multiple outputs

We have 4 buttons and each button controls the directions of 2 motors.
We have a case structure for each button where true sends a value (0.5, or -0.5) to the “Motor Set Output” and false sends a value of 0. We have run into a problem when we have multiple outputs set to a motor.

Attached is an image of the case structure for Button 1. We have tested it and it works. But we get lost when we try to add case structures for the rest of the buttons.





One way I like to do this is to use multiple selects. See the attached picture. This assumes that only one button will be pressed at a time.

multiple_selects.png


multiple_selects.png

Read each button and put into a binary array. Then convert the array to a number. Your select case can then test for which number shows up. If you are watching four buttons, there would be a possible 16 cases. But since you probably only need to detect if one button is pressed, your test cases would be 1, 2, 4, 8. A very similar technique is being used in the sample line follower code that came with LabView this year.

If you need sample code, let me know. I will be at the lab tonight and can make it real quick.

If I really had to do something like this, I would make a subvi, using a typedef’ed enum. This enum would then be used on the case selector with the output options/code. This would allow future changes pretty easily.

I have to say that this would become hard to follow whenever extra code is added. It would also be very difficult to scale, and modify into the future. (Like on competition day)

Hey Jeff,

I was interested in seeing that code as a example that could learn from. Thanks!

Here is an example. The zip is just the subVIs.

JoyStickButtonToEnum.zip (14.8 KB)
JoyStickToEnum.png


JoyStickButtonToEnum.zip (14.8 KB)
JoyStickToEnum.png

This is the error code I get when tried to use the codes. Can you tell me what I did wrong?





  1. Your Motor Output needs to be told which motor you are talking about.
  2. You have not defined what to do with all the possible cases of joystick buttons. At the very least you need a “default” case to cover all uncovered bases.

Can you send me some screen examples? I’m new and I can’t visualize what you’re telling me. Thank you.

Here’s what you need:

  1. Add a Motor reference (this motor needs to be opened in Begin.vi)

  2. Put the cursor on the cases and right-click to choose “Add Case for Every Value”
    Then look for every new case that needs a motor value added to it.
    The output tunnel carrying the motor value will be solid when you have them all. It’ll have a white center if you haven’t fixed all the missing cases.

    AddMotorRef.jpg
    AddEveryCase.jpg


    AddMotorRef.jpg
    AddEveryCase.jpg

Thank you! Everything is working great now.

As an aside, here is how I would select between multiple joystick or custom DS buttons.





I would’ve broke both the motors up into two case structures and then have a boolean series hooked up to nested case structures.