From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Solved!
Go to solution

Thanks to all who posted.  Omar II's reply was selected as the solution because he actually posted code that worked.  Johnsold got a kudo for proposing the correct property that made it work. 

 

I already knew how to read a joystick button in a loop; I really did need to know how to use that to trigger an event.

 

Thanks again,

 

Ed

Edward Motts
Certified LabVIEW Associate Developer
0 Kudos
Message 11 of 25
(2,543 Views)

Then you should mark Lynn's (johnsold) message as the solution to your question.

0 Kudos
Message 12 of 25
(2,539 Views)

Ravens Fan,

 

I felt that Omar II's response was the one that solved the problem for me--I already had the idea that the Value (Signaling) property was what I needed (it was in the subject of the post), but I didn't know how to apply it.  Omar II gave me that, so he got the Solution.  Lynn got a kudo for telling me I was on the right track, and that what I wanted to do wasn't impossible.

 

To my way of thinking, posting code is a more useful solution than telling me that I can read the Help.  I've been reading the Help for the past three days without learning what I wanted to know.

 

Anyhow, after more experimentation, I realized that Omar II's code, although showing me what I needed, had an undesirable behavior--it triggered the event on button down AND button up (if the time between pressing and releasing the button was longer than the Wait in the loop).  So I created a new version that only triggers the event on button down (attached below).

 

Once again, thank you all for your help.

 

Ed

Edward Motts
Certified LabVIEW Associate Developer
0 Kudos
Message 13 of 25
(2,528 Views)

Hi Ed,

 

no need to compare booleans to TRUE/FALSE constants - usually this results in RubeGoldbergs...

Try this:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 14 of 25
(2,517 Views)

GerdW,

 

I hate to display my ignorance (I don't why, I should be used to it by now Smiley Happy) but what is the symbol on the inverting input to the And gate?   I am happy to find any way to streamline the code, because my next step will be to expand this to read several buttons and an axis on the joystick.

 

Thanks,

 

Ed

Edward Motts
Certified LabVIEW Associate Developer
0 Kudos
Message 15 of 25
(2,502 Views)

It's a Feedback Node, which is like a shift register except it does not need to be contained inside a loop.  It's storing the previous value, making for a quick comparison to see if the value has changed.

Message 16 of 25
(2,508 Views)

OK, thanks.  I should have known that.  I'll try it with the joystick tonight.

 

Ed

Edward Motts
Certified LabVIEW Associate Developer
0 Kudos
Message 17 of 25
(2,493 Views)

OK, I still don't know why you need an event structure at all, because whatever you do in the event case could be done in the original case structure of the polling loop. Don't overcomplicate things!

 

To trigger on a TRUE->FALSE transition, use implies from the boolean palette.

 

Here's a quick rewrite.

 

 

Some extra comments to your original code:

 

  • You can eliminate the local variable of the stop button by placing the terminal in the upper loop. The event structure does not need a terminal. If you really need the boolean value, use the "newval" event terminal.
  • As mentioned, you boolean gymnasitcs are silly. A "=true" operation is just a wire because it does not change the input, a "=FALSE" is just an invert.
  • Your code has a 50ms delay, because you are comparing the n-1 and n-2 history values from a two-level shift register. Instead you should compare the current value and the n-1 value using a single-level shift register. Right?

 

Download All
Message 18 of 25
(2,489 Views)

altenbach,

 

I'll have to consider your extra comments this evening, when I can try them along with my hardware.  There are clearly a more elegant ways to compare the new value with the old value than what I posted, and I appreciate the recommendations.   I've never used Implies before, so I will need to look at that one.

 

As to why I need an event structure: the joystick capability is being added to an existing program which uses the Producer/Consumer (Events) architecture to control an ROV.  There are two Consumer loops, so that I can trigger each without waiting for the other to complete--for instance, I want to steer the vehicle without waiting for the last Drive Forward command to complete.  Or I want to Stop the vehicle without waiting for the Steer command to complete.  I wrote the original program using Producer/Consumer (Events) because I wanted to learn how to use that architecture and it seems ideal for the application.  I am studying (and gaining experience) toward the CLD exam, maybe next year, so I give myself assignments which use the architectures I might need for that exam. 

 

But I didn't want to post the entire ROV .vi just to ask a question about triggering an event.  I already knew how to read the joystick in a loop, and I can think of a few ways to read multiple buttons to control a State Machine, but my goal was to learn how to trigger events with non-UI inputs. 

 

Ed

Edward Motts
Certified LabVIEW Associate Developer
0 Kudos
Message 19 of 25
(2,478 Views)

Okay, I tried some of the recommended techniques.  I like the Feedback Node--it's a nice easy to read method that does what my two shift registers were doing.  I will use that.

 

I couldn't get the "Implies" function to work for me--I think because it is basically an Or function, it was continuously triggering the event, and the LED was blinking.  Not exactly what I wanted.  But I did relocate the Stop control to the joystick read loop; that is much cleaner.  

 

Thanks a lot to all; I've learned a lot.

 

Ed

Edward Motts
Certified LabVIEW Associate Developer
0 Kudos
Message 20 of 25
(2,453 Views)