LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Difficulty controlling COM instrument with VISA

I'm trying to control a syringe pump connected to a serial port using LabVIEW. It works fine when I run it with HyperTerminal. After configuring the serial port, when I type "run" into the string buffer for the write vi and click run program, the pump does not respond. But, when I "run continuously", it begins to pulse. The flow rate and volume that it pumps are changed and sometimes, it does something its not supposed to (like run backwards!!!). I've matched baud rates, parity etc. with that given by the manufacturer.

The termination character is a carriage return (\r) which I enable. When I type the string buffer, should I say \r? Typically, to run the pump, I need to input flow rate, volume, and then run and an optional stop. Do I need separate vis to do this or can I input one command after another in the same buffer? I think I might have number of bytes read issues, but I don't know how to confirm that.

The company that made this pump claims to have been working on a NI collaborated device driver to run it for the past 3 months. So, everytime I ask them LabVIEW help, they simply ask me to wait for the device driver.

If someone could kindly answer my questions, I'd much appreciate it.

Cheers
Micrograd
0 Kudos
Message 1 of 5
(2,433 Views)
One of many ways to comm with Serial Port is by using function VIs from within the serial.llb found here

..\Program Files\National Instruments\LabVIEW 7.0\vi.lib\instr\serial.llb


[Serial Port Init]
- Configure and Init the Serial Port with this VI (baud-rate etc)

[Serial Port Read/Write]
- Send/ Fetch

[Bytes at Serial port]
- Bytes count at Serial Port
- Use this VI to check no. of bytes available at the Port

[Close Serial Driver]
- Close the Serial Port when VI exits.

Note:
To be able to enter \r or \n at the end of command string (in String control), simply right-click on the String input control, select '\'Codes Display

hope this info helps you in one way or another!

Cheers!
ian.f koo
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 Kudos
Message 2 of 5
(2,424 Views)
I don't understand why your program only runs when hitting the "run continuous" button, do you have any loop structure in your code? If you have more than one command to send, you may want to use while/for loop in your code for the Write and Read functions.

To include a "\r" in your code, you can either type it into the write buffer or use the "\" code display mode as suggested by ian.f. For determine if you have the number of bytes to read, use the "VISA Bytes at Serial Port" property node will help you making sure how many bytes of data should be read.
0 Kudos
Message 3 of 5
(2,393 Views)
Thanx for your prompt responses. I'm relatively new to LabVIEW and have never used a VISA before, so kindly bear with my ignorance. I'm using LabVIEW 6.

1. I opened a "VISA configure serial port" vi. My VISA resource name was COM2. I made sure that the baud rates, parity etc. were equal to that specified by the pump manufacturer.
2. I opened a "VISA bytes at serial port" and connected "duplicate VISA resource name" from "configure" to "reference" in "bytes at serial port".
3. I created an indicator for Serial Settings:Number of bytes at serial port.

When I ran the program, the indicator said 0. Did I do this right?

I also tried to write to the pump using Serial.vi under Find Examples. Even there, I had to continuously run the program for the pump to move. I called NI and was told that the command should be executed without running continuously. Is it possible that the pump is not receiving the necessary bytes of data for a complete command?

There are two errors that the pump gives me. One is a serial error indicating that a command is too long for the input buffer, and the other is a serial overrun error indicating that a command has been sent before the prior command has been processed. Does this mean that the serial port is receiving lesser ports than it needs? How can I determine the size of my input buffer and change it? Please help.

Cheers
S
0 Kudos
Message 4 of 5
(2,384 Views)
The two errors you saw happen when you try to send different commands to the instrument all in one VISA Write, if the device has to take time to respond to certain commands before taking another command, you will see the overrun error.

If this is the case, use different VISA Writes to send multiple commands to the device and have a "wait" between writes so your device will have enough time to respond.

You can paste your code here so people can help you find the errors.
0 Kudos
Message 5 of 5
(2,361 Views)