LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

About sending a string to serial monitor once every time button is clicked

Sorry for asking this simple question, but I have an arduino program which receive serial input, I want a case where I can press a button in labview and the string "g","s" etc. is sent to the serial monitor for arduino to read. I am stuck in the process of creating such a vi. I would appreciate if there is any help, here is my vi for attachment, thanks.

0 Kudos
Message 1 of 6
(1,033 Views)

Is the Arduino also sending data out through this serial connection?  If not, a simple look with an Event Structure would suffice.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 6
(974 Views)

No, the arduino serial monitor is just receiving strings (Serial read) from labview, no two way communication is needed

0 Kudos
Message 3 of 6
(971 Views)

Use a while loop, put an event structure, add an case to handle value change event for the button, implement the VISA write to send the string.

 

Note: do initialize and close the VISA session outside the loop and do only VISA write inside the event handler.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 4 of 6
(959 Views)

Thank for the help, but I come up with an event structure with a button for different string to send, such as GO for "g", STOP for "s", but it seems like the arduino does not receive the string when the button is latched. Any support would be appreciated. 

labv8.jpg

0 Kudos
Message 5 of 6
(947 Views)

Move that "Close" outside of the While loop. Remember that the event structure will execute exactly one state each time it's called. The While loop will then repeat "stuff inside it". Basically, you enter the While loop and wait on a button event. When that event happens, the Event structure executes that case and is done. In your case, you call the VISA Close function, then the While loop executes again, which lets your Event structure respond to a new event, then you repeat.

 

Either put the VISA Open and Close inside each frame of the Event structure (so each Event will open the function, send the data, then close the port), or put both *outside* the Event structure so it opens the port, handles all the data, then closes it when you're done. Either method has its own use case, but for your situation I'd do the latter (put VISA Open and Close outside the structure).

0 Kudos
Message 6 of 6
(940 Views)