From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

question from a beginner

I want to control a pump using RS-232 connection (com1) with Labview 7.0. The com 1 is configured and the pump-computer communicate. However, when i run my Labview program i cannot control the pump. Could you help me?

RS-232 command set
cldinf = clear infusion volume
cldwdr = clear withdrawn volume
dirinf = set pump direction
rat = set the rate
run = start the pump

Message Edited by aurelia on 04-12-2005 09:01 AM

Message Edited by aurelia on 04-12-2005 09:01 AM

0 Kudos
Message 1 of 108
(4,791 Views)
Are you setting an end Termination string? Most serial communications need to be terminated with either \n or \r\n (Otherwise known as LF and CRLF respectively).

You can set this option when configuting the serial port in VISA. Use a property node to access the option. It's under "Properties-> Message-based settings -> Termination character" and "Termination character enable".

You should also check to see if your pump control works in Hyperterminal or some other program which can write to the COM port. This way you can exclude wiring or hardware problems.

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 2 of 108
(4,759 Views)
The Properties Shane mentioned will set the end mode for reads. The "Termination Character" property will take the decimal value of the ASCII character your device requires. This is 10 for \n (LF) and 13 for \r (CR).

If you want to automatically append a termination character on the ends of your writes you will need to use the Properties-> Serial settings -> Serial End Mode for Writes, and set it to TermChar. It will then automatically append the character you specified in the Termination Character Property Shane mentioned.

Shawn B.
National Instruments
Use NI products on Linux? Come join the NI Linux Users Community
0 Kudos
Message 3 of 108
(4,748 Views)
Hey Shoneill,

Thank you very much. Using Hyperterminal I get a communication with the serial prt. However, Labview program still does not work. I attached the file with the serial configuration to this message. Do you mind to have a look at it?
0 Kudos
Message 4 of 108
(4,708 Views)
Thanks
0 Kudos
Message 5 of 108
(4,706 Views)


@Shawn B. wrote:
The Properties Shane mentioned will set the end mode for reads. The "Termination Character" property will take the decimal value of the ASCII character your device requires. This is 10 for \n (LF) and 13 for \r (CR).

If you want to automatically append a termination character on the ends of your writes you will need to use the Properties-> Serial settings -> Serial End Mode for Writes, and set it to TermChar. It will then automatically append the character you specified in the Termination Character Property Shane mentioned.

Shawn B.
National Instruments




Hey Shawn,

Thank you very much. Using Hyperterminal I get a communication with the serial prt. However, Labview program still does not work. I attached the file with the serial configuration to this message. Do you mind to have a look at it?

Thanks
0 Kudos
Message 6 of 108
(4,699 Views)


@shoneill wrote:
Are you setting an end Termination string? Most serial communications need to be terminated with either \n or \r\n (Otherwise known as LF and CRLF respectively).

You can set this option when configuting the serial port in VISA. Use a property node to access the option. It's under "Properties-> Message-based settings -> Termination character" and "Termination character enable".

You should also check to see if your pump control works in Hyperterminal or some other program which can write to the COM port. This way you can exclude wiring or hardware problems.

Hope this helps

Shane.




Hey Shoneill,

Thank you very much. Using Hyperterminal I get a communication with the serial prt. However, Labview program still does not work. I attached the file with the serial configuration to this message. Do you mind to have a look at it?

Thanks
0 Kudos
Message 7 of 108
(4,698 Views)
Aurelia,

What you did (twice) was simply attach LabVIEW 6.0 functions and not any code that you wrote with saved configuration or commands. Even if you really have 6.0 as opposed to 7.0 as you state in your original post, you should not be using these old serial functions. You should be using the VISA functions (i.e. VISA Configure Serial Port, VISA Bytes at Serial Port, VISA Write, VISA Read). There are a couple of shipping examples. Just opne the examples and do a search for "Serial". When you open one of the examples, you should have a string controller for sending commands to the instrument. Right click on it and select '\' Codes Display. Now, when you type the command, end it with a termination character like Shane mentioned. Use \r for a carriage return and \n for a line feed. The instrument manual should tell you which one or both that you need. If you still can't get anything to work, save the example you use with the configuration and command string by selecting Operate>Make Current Values Default and then post that VI.
0 Kudos
Message 8 of 108
(4,697 Views)


@Dennis Knutson wrote:
Aurelia,

What you did (twice) was simply attach LabVIEW 6.0 functions and not any code that you wrote with saved configuration or commands. Even if you really have 6.0 as opposed to 7.0 as you state in your original post, you should not be using these old serial functions. You should be using the VISA functions (i.e. VISA Configure Serial Port, VISA Bytes at Serial Port, VISA Write, VISA Read). There are a couple of shipping examples. Just opne the examples and do a search for "Serial". When you open one of the examples, you should have a string controller for sending commands to the instrument. Right click on it and select '\' Codes Display. Now, when you type the command, end it with a termination character like Shane mentioned. Use \r for a carriage return and \n for a line feed. The instrument manual should tell you which one or both that you need. If you still can't get anything to work, save the example you use with the configuration and command string by selecting Operate>Make Current Values Default and then post that VI.





Thank you. It still does not work. I post the VI.
0 Kudos
Message 9 of 108
(4,686 Views)
Have you tried it with \r\n or \r and \n by itself? Does the instrument manual have a section on remote control that says what the terminator should be? since there is information being read back, it would seem like the problem is that the instrument is not recognizing "run" as a valid command and this almost always is the result of an incorrect termination character.
0 Kudos
Message 10 of 108
(4,682 Views)