Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending out in decimal, reading in hex

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)

0 Kudos
Message 31 of 47
(1,792 Views)

@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.



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 32 of 47
(1,788 Views)

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?

0 Kudos
Message 33 of 47
(1,784 Views)

@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.



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 34 of 47
(1,780 Views)

@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.

 

 

0 Kudos
Message 35 of 47
(1,775 Views)

Demetri90 wrote
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 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.



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 36 of 47
(1,767 Views)

@crossrulz wrote:

Demetri90 wrote
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 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 Smiley Frustrated

 

0 Kudos
Message 37 of 47
(1,759 Views)

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.



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 38 of 47
(1,752 Views)

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.

 

 

 

 

0 Kudos
Message 39 of 47
(1,744 Views)

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.



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 40 of 47
(1,740 Views)