NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Knight of NI
Dennis_Knutson
Posts: 29,306
0 Kudos

Re: Event Structure/Foot Switch

The VISA Open is in fact, optional.

 

Are you able to read the foot switch with your VI? Once it is detected, what do you want to do?

Member
Eric1977
Posts: 126
0 Kudos

Re: Event Structure/Foot Switch

Dennis - yes I am able to read the value when the foot switch is pressed in the MagnaMike.vi. What I'd like to do is detect when the foot switch is pressed and place the value in Excel. What I don't know how to do is to detect that the foot switch has been pressed in my Event Structure (MagnaMikeMain.vi).

Trusted Enthusiast
Albert.Geven
Posts: 3,142
0 Kudos

Re: Event Structure/Foot Switch

Read the switch again and again in a separate while loop. Compare each reading with the previous reading and if achange is detected signal it to a control ( write the new value in the control by a signal value write) This control then is in one of the eventcases detected for a value change. You eventually can read the new value an act accordingly on a low or high. So next toyour mainloop you have that footswitch reading loop.
greetings from the Netherlands
Member
Eric1977
Posts: 126
0 Kudos

Re: Event Structure/Foot Switch

Like this?

 

 

Test.png

Knight of NI
Dennis_Knutson
Posts: 29,306
0 Kudos

Re: Event Structure/Foot Switch

No, no, no.

 

Why are you even playing around with an event structure? Why don't you simply do the write to file in the loop where you are monitoring the serial port? It only makes sense to have an event structure if you want to have a front panel control do a file write. Then the Value(Signaling) would go into the while loop with the serial read - not the event you are trying to fire.

Member
Eric1977
Posts: 126
0 Kudos

Re: Event Structure/Foot Switch

OK, I got it. Now, how do I make my sub VI stop when the front panel stop button is pressed?

 

Image1.gif

Trusted Enthusiast
Albert.Geven
Posts: 3,142
0 Kudos

Re: Event Structure/Foot Switch

put the elements from your subvi in your main program.

The init before the loop after opening excel

the read inside the while

the cloase after the while.

 

good luck

greetings from the Netherlands
Member
Eric1977
Posts: 126
0 Kudos

Re: Event Structure/Foot Switch

Dennis & Albert, thanks for your solutions. I now have a working program but one thing eludes me. I have placed my "Quit" text button inside the While Loop but it does not quit my program. The VISA Read is waiting for a response from the Magna Mike. I have to terminate the program by using the abort button. How do I get around this? The VI is attached.

Trusted Enthusiast
Albert.Geven
Posts: 3,142
0 Kudos

Re: Event Structure/Foot Switch

remove the while from your subvi.

Just let it run once and handle the error or timeout in the higher level program.

Very good that you don't want to push the abort button.

greetings from the Netherlands
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page