07-11-2012 09:58 AM
I believe I see where this is going. However I'm not sure what code to place in there. Would this event structure somehow be connected with the code we wrote earlier? (the command packet)
07-11-2012 10:44 AM
@Demetri90 wrote:
I believe I see where this is going. However I'm not sure what code to place in there. Would this event structure somehow be connected with the code we wrote earlier? (the command packet)
It should be exactly the code we wrote earlier. You hit the button and inside the event structure you build the packet and send it.
07-11-2012 11:04 AM
I see, how would you connect it to the VISA Write? I can't connect it since the other code is connected to the Write function, says wire is connected to an undirected tunnel.
Also, since I just want to turn an LED on and off, which requires a couple commands being sent, how would I go about sending multiple commands with one click?
07-11-2012 12:10 PM
@Demetri90 wrote:
I see, how would you connect it to the VISA Write? I can't connect it since the other code is connected to the Write function, says wire is connected to an undirected tunnel.
Also, since I just want to turn an LED on and off, which requires a couple commands being sent, how would I go about sending multiple commands with one click?
Disclaimer: This advice is based on knowing nothing of your current architecture. Recommendations may change based on what you already have.
There are many ways to accomplish this. I would recommend making the build packet code into a subVI. Use constants for the commands you want to send, build up the packets and send them either in one call or separate calls. It depends on the reciever (if it needs any delay between commands).
As far as the VISA COM port is concerned, you initialize the port before entering the main loop, pass the reference into the loop, send the data inside the event structure (pass the VISA reference through), and close out the port either in the stop event or outside of the loop.
07-11-2012 12:35 PM - edited 07-11-2012 12:37 PM
@crossrulz wrote:
@Demetri90 wrote:
I see, how would you connect it to the VISA Write? I can't connect it since the other code is connected to the Write function, says wire is connected to an undirected tunnel.
Also, since I just want to turn an LED on and off, which requires a couple commands being sent, how would I go about sending multiple commands with one click?
Disclaimer: This advice is based on knowing nothing of your current architecture. Recommendations may change based on what you already have.
There are many ways to accomplish this. I would recommend making the build packet code into a subVI. Use constants for the commands you want to send, build up the packets and send them either in one call or separate calls. It depends on the reciever (if it needs any delay between commands).
As far as the VISA COM port is concerned, you initialize the port before entering the main loop, pass the reference into the loop, send the data inside the event structure (pass the VISA reference through), and close out the port either in the stop event or outside of the loop.
Ok, so instead of the user entering commands, I can have an event structure with a button or switch send it out to the subVI. I would take this code shown below and create it into a subVI? From what I'm reading I'd have to make a connector pane.

07-11-2012 12:39 PM
Demetri90 wroteOk, so instead of the user entering commands, I can have an event structure with a button or switch send it out to the subVI. I would take this could shown below and create it into a subVI? From what I'm reading I'd have to make a connector pane.
Yep. And you can reuse that VI wherever you need to build up a packet. The beauty of subVIs is the reuse aspect.
07-11-2012 01:37 PM - edited 07-11-2012 01:37 PM
@crossrulz wrote:
Demetri90 wroteOk, so instead of the user entering commands, I can have an event structure with a button or switch send it out to the subVI. I would take this could shown below and create it into a subVI? From what I'm reading I'd have to make a connector pane.Yep. And you can reuse that VI wherever you need to build up a packet. The beauty of subVIs is the reuse aspect.
So something like shown below? I created the subVI with two terminals, data in, command out. You completely lost me on trying to wire these various commands into the VISA Write function ![]()

07-11-2012 02:12 PM - edited 07-11-2012 02:13 PM
Demetri90 wrote:So something like shown below? I created the subVI with two terminals, data in, command out.
You should probably edit the icon so you know what the VI is when you reuse it. I also put the byte array to string inside the VI to make life a little easier.
Demetri90 wrote:You completely lost me on trying to wire these various commands into the VISA Write function
I was thinking something along these lines. Notice that I have a different button for each command.

07-11-2012 03:06 PM
Ok, I'm having a baud rate issue when using the event structure. I have the baud rate control connected to both the manual entry part, and also to the event structure part. The correct baud rate is used when I use the manual entering, however the event structure is using some other baud rate. I have the control connected to both VISA Serials.
I can't create a snippet for some reason it keeps crashing.
07-11-2012 03:29 PM
That's because you are closing the port on it via the lower portion of the code before you send a command. You also only need to setup the port once. Remove the Close Port at the end of the "manual" and wire the VISA session out from the Setup Port to both portions of code.