Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Labview Joystick Buttons... (http://www.chiefdelphi.com/forums/showthread.php?t=72304)

TotalChaos 18-01-2009 19:04

Re: Labview Joystick Buttons...
 
EDIT 2 - I just went back and checked out a previous post which led me to the programming manual. (Which I havent read :p ... I'm more of a learn through experiance person) Anyways, using -1 and 1 may not work. But seeing as I don't have a way to test it I added on more to the bottom explaining how to do it so that it's at least in-line with the manual.

Ok, maybe I jumped ahead and went a little too fast with my last example.

Lets build on what you have and start with something simple. First off, I think it would be a good idea to clean up your code. When I'm testing things out I find it easier to test for one thing at a time to avoid clutter. I took your picture and marked some of the things I think you should take out in red. (The box with the question mark you could keep, I wasn't really sure what you were doing with it so I would just say delete it unless its important to you.) The blue box signifies what I want you to change.

EDIT - And don't forget, for EVERY Open function you need a matching Close function.



As a first step we'll set this up to go one way when the button is pressed and another way when then button is released (unpressed).

In the blue box go ahead and get rid of the "boolean to num" function and instead add a case statement. To get that open up your palette and go to: Programming > Structures and select "Case Structure".

In the True case of the case structure and a numerical constant (Function palette > Mathematics > Numeric and select "Numeric Constant") and enter in 1 as its value. Then click one of the little arrows next to where it says "True" on the case structure to switch it to the false case. In the false case add a numerical constant and enter in -1 as its value. Wire up both of the numeric constants to the right wall of the case structure and then wire the new tunnel output to the Set Relay function. Here's what it look like:

(True case shown)


(False case shown)


Let me know how this works and then we can work from there.

EDIT 2:
In the blue box go ahead and get rid of the "boolean to num" function and instead add a case statement. To get that open up your palette and go to: Programming > Structures and select "Case Structure".

In the True case of the case structure and a enum constant (Function palette > Mathematics > Numeric and select "Enum Constant") and enter in "Forward" as its value. Then click one of the little arrows next to where it says "True" on the case structure to switch it to the false case. In the false case add a enum constant and enter in "Reverse" as its value. Wire up both of the numeric constants to the right wall of the case structure and then wire the new tunnel output to the Set Relay function. Here's what it look like:

(True case shown)
http://img261.imageshack.us/img261/9...onhelp5if7.gif

(False case shown)
http://img504.imageshack.us/img504/8...onhelp4kk1.gif
(^^^ There's a max amount of images per post, so I linked these instead)

- Austin

Greg McKaskle 19-01-2009 08:33

Re: Labview Joystick Buttons...
 
If the case with two constants works for you, then may I suggest looking at the ternary assignment -- a fancy name for the ? : operator in C. It is actually called the Select operator. LV puts it in the Comparison palette, and it is handy for selecting one of two values without the space and hidden constant of the case structure.

Of course this is just for readability, it is equivalent at runtime.
Greg McKaskle

domoarigato 20-01-2009 17:25

Re: Labview Joystick Buttons...
 
1 Attachment(s)
...Yeah.... okay... Trying to program the joysticks' buttons... More specifically, trying to get a spike/relay to be able to be controlled by a button. (Forward/Reverse would be nice for one, Forward/Neutral/Reverse for the other) so I've looked at just about every tutorial/help guide thing that I could find... At the moment, we have two spikes on our electrical board, one of which, when attached to any of the DIO things it will stay a constant red (reverse) which does run a motor, albeit all the time and only in reverse. Code-wise, here's what I have so far (In attachments). [In the inner-most case structure, the false case is set to a constant of 'Reverse' as I believe you have said to do. Also tried 1 and -1, but to no avail.] Any help or advice would be greatly appreciated. Thank you~

IceStorm 28-01-2009 23:04

Re: Labview Joystick Buttons...
 
Were trying to do something very similar but with out the relay.

We want to have a button that on one press it turns on our traction control code, and when you press the button again it turns off our traction control code and turns on our manual speed control code. we have our two pieces of code in a case structure where true is traction control and false is manual speed control. we then wired this to a joystick button and it works other than you have to continue to hold the button down to get it to stay engaged.

is there an easy way to make the joystick buttons into on/off buttons rather than momentary buttons.

TotalChaos 28-01-2009 23:18

Re: Labview Joystick Buttons...
 
Quote:

Originally Posted by IceStorm (Post 810153)
is there an easy way to make the joystick buttons into on/off buttons rather than momentary buttons.

So it sounds like you're trying to turn it into a button that toggles from on to off (and the other way around) when you press it? If so you can check out the VI posted in THIS THREAD. (I know you said you don't want to use relays, but it will give a a general direction as far as how to set up the case structures)

- Austin

IceStorm 29-01-2009 10:08

Re: Labview Joystick Buttons...
 
TotalChaos,

Yup. That is exactly what we are trying to do. we want to take the momentary button and make it a toggle. i opened that vi and it looks like what i need i just need to pull out the extra items for the buttons 2 and 3.

Thanks.

chinckley 17-02-2009 19:23

Re: Labview Joystick Buttons...
 
Quote:

Originally Posted by TotalChaos (Post 802671)
I know it's a little late, but here's my crudely done diagram:


(Sorry, I did it in paint without a mouse :p )

Give me about 15 minutes or so and I'll get a picture of some way to hook a motor to a button. (It might not be the best way, but I do know a way)

- Austin

Thanks Austin. That answers a very large question for us!!!!!!!


All times are GMT -5. The time now is 10:57.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi