LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Alternating writing to two serial channels

Solved!
Go to solution

I've got a single LabVIEW program that acquires data from up to 24 VISA devices (as it happens, they are connected via a multi-port TCP/IP concentrator, but I deal with them with VISA Reads and Writes).  The instruments I'm monitoring output characters 10 times/second, so I have multiple loops running in parallel (one per instrument) doing VISA Reads of 1000 characters (which works out to 10 reads/second, since the strings are only 15-20 characters).  Not a problem.  Of course, I can trace the data flow path for each device and see that I'm not mixing things up ...

 

Bob Schor

0 Kudos
Message 11 of 16
(574 Views)

Serial connections are single devices. There's no concept of multiple devices in a serial connection, it's just the one device. If your device can interpret different commands on different channels then that's a different "layer" than the serial connection.

 

Click Help -> Find Examples, then go to Hardware Input and Output -> Serial -> Simple Serial or Continuous Serial Write and Read.

 

(Note that, in general, Bytes at Port is a poor way to do serial comms. A termination character/termchar is a much better way to do things, but the example will show you how to open and close a serial port)

0 Kudos
Message 12 of 16
(574 Views)

@EricaK wrote:

I tried that, but it does not seem to do anything.  I wonder if I'm using the function incorrectly.  Do you have any sample vi's that show how to use this function correctly?  Also, does the close function apply to a channel as a whole, or do you have to specify a specific device?  My hardware contains functionality for controlling multiple devices through one channel, so I need to make sure that I'm closing every device in that channel.   Thanks very much!


When I deal with multiple (up to 24) VISA Devices, I treat them identically, but independently.  Suppose I have 3.  I call three Open VISA (specifying an identifier that selects the 3 I want), and get three VISA References, call them VRef1, VRef2, and VRef3.  To do anything with VISA Device 1, I use VRef1 and write VISA commands or do VISA Reads using that Reference.  When I need VISA Device 2, I use VRef2, and so on.  I typically open all VISA References at the beginning, keep them alive in Shift Registers, and close them all when I'm done with them.

 

I couldn't manage them if I was using a Stacked Sequence Structure, but it is a piece of cake with a State Machine Design (I'm using a version of the Queued Message Handler).

 

Bob Schor

0 Kudos
Message 13 of 16
(570 Views)

Back to basic troubleshoot...

Get this code to work on your system. If this does not work, then the problem is in your sub vi that you cannot share (hence, we cannot help any further.)

image.png

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 14 of 16
(566 Views)

Thanks for the simple test vi.  Ugh, it does not work.  Same problem-- signal is sent correctly to the first pump but not the second.  I guess there's something about the low-level pump driver where you can't send signals to multiple channels.  I guess I will have to figure out how to write my own version.  It would be a lot easier to replicate if the entire vi weren't in German :-(.

0 Kudos
Message 15 of 16
(558 Views)
Solution
Accepted by EricaK

Thanks to all of you for your help.  I was just able to turn on both pumps in the same vi by completely removing the pump driver and instead manually sending my own serial commands.  Now I have to replace every instance of that sub-vi in my main program.  What a pain!  I really appreciate all the advice, I likely couldn't have figured it out on my own.

0 Kudos
Message 16 of 16
(553 Views)