Using 4 joystick buttons with Case Statement

Dear CD,

I am trying to use 4 joystick buttons in conjunction with a case statement in order to select one motor speed but am not being successful.

My guess is that the execution order impacts the design and does not effectively allow me to select some options.

Can you recommend a design solution?

Dear CD,

Yeah, it helps to post a picture in the initial email.





I’m on the road so I cannot offer up examples, but I can comment on what you have.

The code you posted has a chicken/egg issue.
None of the Latches are guaranteed to have been set by the loops on the left, before being used in the case statement to the right.
The case statement code on the right happens simultaneously with the checks you are performing on the left.

As far as using joystick buttons to select a motor speed, you can do something like this. Add more buttons (one speed and one Select per new button) for more variations in speed.
It just remembers (latches) the speed associated with the last button pushed.
I can’t tell if this is in line with how you are trying to employ the buttons.

Could you be a little more specific, I’m a bit confused as to where some of the values are coming from. Also wouldn’t it be easier to use a case structure with a choice of each value? Sorry if I’m not much help.

Dear CD,

I can’t figure out for the life of me why I cannot see the third button case while seeing cases 1, 2, and 4?

Please see pdf attachment.

My next set of experiments will use Mark’s example above but I really think my latching button method using RS Bistable vi should work.

Thanks,

4 button Joystick Latch.pdf (154 KB)

4 button Joystick Latch.pdf (154 KB)


4 button Joystick Latch.pdf (154 KB)

You still have the race condition that Mark pointed out. Putting the latches in a sequence helps some, but doesn’t keep the case statement from executing before or after the sequence.

I think you can implement the whole thing using wires and feedback nodes, and then you would have no race conditions.

As for any specific debugging, that’s almost impossible to do with a PDF of a portion of the code, and hardly any description of what the code is supposed to do. Post the VI and a detailed description and maybe someone can help. To me, it looks overly complicated, but since I don’t know what its supposed to do, I can’t say for sure.

There’s an awful lot of complicated stuff going on there. I suspect LabVIEW provides a much simpler way to do what you want, but without knowing what you want to do, I don’t want to risk giving inappropriate advice.

What exactly are you trying to do here?

If you are looking to create a latch on a variable, you can use this method:

It works very well for us and it only updates the variable when something changes. We use this method for almost all inputs from the driver station.

Shift.jpg


Shift.jpg

I wonder if the third button is generating a a value of 4 and your fourth button generates a value of 8?

When you convert a binary array to a number, each bit takes a power of 2 value. To get three, you’d need 1 and 2 simultaneously.

Doc Wu,

That’s it! I haven’t tested it yet but I know that’s the solution.

When I get a chance, I will post the problem and solution for CD reference.

Thanks,