LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Value (signaling) property for event--button press on joystick

Solved!
Go to solution

I have been trying to use the buttons on my Logitech joystick to trigger events.  I've read several posts and LV Help about how to Register for Events, and I haven't found exactly what I need.

 

I understand that usually events are not triggered by non-UI inputs, but I keep reading posts that make it sound possible.  The LV Basics II book says, "NOTE  Clusters are the only container objects for which you can generate events.  LabVIEW generates Control events for clusters, before it generates events for the objects they contain, except in the case of the Value Change event.  They Value Change event generates the event on an element in the cluster, then on the cluster itself."

 

So, the joystick buttons and axes are in clusters, and I am trying to detect a Value Change in the elements of a cluster (see the .VI attached below) but the event isn't trigger.  If I press button 9 on the joystick, the LED should light up and the string indicator should say the event was triggered.  This is a simplification of what I'm trying to do, but I think if I can make this simple case work, I can do the rest.

 

This was created in LV10.

 

So what am I doing wrong?

 

Thanks,  Ed 

 

Edward Motts
Certified LabVIEW Associate Developer
0 Kudos
Message 1 of 25
(5,775 Views)

Save the VI in LV 8.6 and post.....

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 25
(5,762 Views)

Here it is in LV 8.6.

 

Thanks,  Ed

Edward Motts
Certified LabVIEW Associate Developer
0 Kudos
Message 3 of 25
(5,734 Views)

@EMotts wrote:

...

 "NOTE  Clusters are the only container objects for which you can generate events.  LabVIEW generates Control events for clusters, before it generates events for the objects they contain, except in the case of the Value Change event.  They Value Change event generates the event on an element in the cluster, then on the cluster itself." 


 

I beleive what they are talking about is a cluster control on the front panel.

In a cluster control you can create an event for a single object or element inside the cluster without have to create an event for the cluster as a whole. This would be different from a front panel array where you can NOT create an event for a single element but must create an event for the whole array and then test old value with new value to see which element has changed.

 

Joy sticks buttons will need to polled inside a loop to detect any change. 

 

Omar
0 Kudos
Message 4 of 25
(5,712 Views)

 


EMotts wrote: 

I understand that usually events are not triggered by non-UI inputs, but I keep reading posts that make it sound possible.  The LV Basics II book says, "NOTE  Clusters are the only container objects for which you can generate events.  LabVIEW generates Control events for clusters, before it generates events for the objects they contain, except in the case of the Value Change event.  They Value Change event generates the event on an element in the cluster, then on the cluster itself."

 

So, the joystick buttons and axes are in clusters, and I am trying to detect a Value Change in the elements of a cluster (see the .VI attached below) but the event isn't trigger.  If I press button 9 on the joystick, the LED should light up and the string indicator should say the event was triggered.  This is a simplification of what I'm trying to do, but I think if I can make this simple case work, I can do the rest.


Unfortunately, there is no native way to get a joystick to trigger an event.  Your quotation from the LV Basics book doesn't apply here; it's referring to a cluster as a user interface element on a front panel.  Setting the value of an indicator (as you're doing) does not cause a value change event to fire for that indicator.  Your best bet is to poll the joystick.  If you really need it to look like an event, poll the joystick continuously (with a minimal delay) in a separate loop, and have it fire a user event to which your event structure can respond.

 

0 Kudos
Message 5 of 25
(5,710 Views)

You seem to have some misconception about events and are implementing circular logic.

When button 9 is pressed you want to read button 9 and display its value. How is LabVIEW supposed to know you have pressed the button before you even read it and update it's indicator tied to the event?

 

Get rid of the event structure and use a case structure instead. Read the stick at regular intervals and switch the case accordingly.

 

 

0 Kudos
Message 6 of 25
(5,706 Views)

altenbach,

 

Thanks for the reply, but I think you misunderstood my post and my sample program.  When button 9 on the joystick is pressed, I want it to illuminate an LED (with the label "button 9) on the FP and trigger a case in the event structure.  That seems pretty straightforward to me.

 

Nathand,

 

How can I cause the event to be triggered as you describe?  Using a local to change a control won't do it.

 

Ed

Edward Motts
Certified LabVIEW Associate Developer
0 Kudos
Message 7 of 25
(5,691 Views)

Ed,

 

Use the Value Changed (Signaling) property node in place of the local.  The help files will explain the differences between Value Changed and ...(Signaling).  This is one of the few places where changing an indicator via a Property Node is appropriate.  By this I mean that when your input device reports the button has been pressed, you use the Value (Signaling) to change the LED.  The Input signal does not trigger the event directly.

 

Lynn

Message 8 of 25
(5,681 Views)
Solution
Accepted by topic author EMotts

 

Oh, I think we understood what you where asking. We all said that you needed to POLL the joystick in a LOOP

Omar
0 Kudos
Message 9 of 25
(5,678 Views)

Yes, we have events for keys and mouse buttons, but I don't think there is the same OS/LabVIEW integration for random joystick buttons.

(there are events for .NET, activeX or even DAQ but I have no experience with those...)

 

It's probably something that could be done if the need really exists. To see if there is interest, please post it as an Idea in the LabVIEW idea exchange. See if you get any kudos. 😄

0 Kudos
Message 10 of 25
(5,669 Views)