LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

the "enter" key has to be pressed twice to trigger the event

Hello everyone
I have an acquisition setup and i want to log measurements only when i hit a certain key (this case "enter"). The problem is that I have to hit twice the key in order to proceed with the log and also that the event is triggered with any ascii key (e.g space) but you have to hit it twice..

It is my first attempt to use the event structures so it is something trivial i guess.
any help will be appreciated..

I attach an example of what i am trying to do.
Lots of thanx in advance

Giannis
0 Kudos
Message 1 of 11
(4,406 Views)
Hi Giannis,

to use the event structure is a good idea Smiley Wink

I made some changes in your vi. I hope it does what you want to achieve!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(4,388 Views)
Your code looks fine - and seems to work fine too. I run the VI and the first time I press any key the upper displays update. The lower ones never show plots because there is no data going to them.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 11
(4,384 Views)

Dear GerdW

thanx for the response. I tried your version but the same thing happens.. You have to hit the "enter"key twice and the "space" key also triggers the event...

regards

Giannis

 

0 Kudos
Message 4 of 11
(4,385 Views)
Hi Giannis,

at the moment I only implied the logic to check for a double-pressed ENTER key.
When your code should only run on this event you have to put a case structure inside the event and wire the boolean 'Enter Key?' to the selector of the case structure... (see attachment).

I thought you wanted to learn instead of getting finished projects from the forum Smiley Wink
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 11
(4,378 Views)
Ok, things are now officially wierd...

I just tried Gerd's version and I get the same results as with your original code. Hit a key once and it updates once. Hit a key twice rapidly and it updates twice. One thing, you keep talking about "logging" results. By that you do mean updating the FP displays right?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 11
(4,376 Views)
@ GerdW : This is not a work project this is a self teaching project. I got stuck and I know that this forum is full of LV experts who can guide me to a solution. I never meant that I want you to finish my project. Thanks for your help anyway.
 
@mikeporter:Yes that is what i mean. When I run my code the graph and the fft window are empty. The amplitude control is set to "1". I press the enter key and the signal appears in the graph and to the fft window. Set the amplitude value to 2. Press enter and nothing happens. If you press enter again the signal in the window is updated. I can't understand why I have to press the enter key twice. Also despite the fact that I set the Enter key to trigger the event, it gets triggered by "space " also...
 
Thank you both for your responses.
0 Kudos
Message 7 of 11
(4,370 Views)
Hi Giannis,

your event is set to ANY keypress and ANY key repeat event!
Just because you check for an ENTER key doesn't mean the event itself only reacts to this special key...

To see signal on channel 2 you have to provide data for two channels! You only calculated one signal... (see attachment!)

What do you want exactly? I'm not sure anymore...
Should the next data be processed after double-pressing ENTER key? Or on any ENTER key-press? Or on any key-press?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 11
(4,364 Views)

Hi GerdW, thanks for the reply

you are absolutely right about that :"your event is set to ANY keypress and ANY key repeat event!
Just because you check for an ENTER key doesn't mean the event itself only reacts to this special key..."

I now see it.  So I guess that if I want only the "enter" key to trigger the event then I'll have to use a case structure after the "equal" sign...or there is a way of configuring the event to react only at the "enter" key?

Regards

Giannis


 

 

0 Kudos
Message 9 of 11
(4,359 Views)
Hi Giannis,

no, you cannot set an event that only reacts on the ENTER key.

But you can 'bind' a key to a control (right-click -> advanced -> key navigation).
In your case you can make a boolean control 'new values' with key navigation=ENTER. Now you will get a 'value changed' event when the user clicks this control or presses ENTER...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 11
(4,354 Views)