LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make program for RS-232

Solved!
Go to solution

Hi all.

I am a beginner to the Labview, and I have to build a program that can send commands via RS-232.

The RS-232 is connected to the computer and INSEK PSP-603.

I've been trying to use "Basic write and read.vi" that is already installed in Labview as an example.

But I do not know how to use it especially the meanings of "data bits" and "bytes read".

 

If anyone can explain it or can provide a vi, I will appreciate it.

 

Thank you.

0 Kudos
Message 1 of 37
(7,873 Views)

Hi mogusa,

i think there are all information in the Basic Write and Read.vi. You should also read the vi description.

The data to send as to be inserted into the "string to write" field. It should be a command for your "INSTEK PSP-603", you should find it in the device description, there should also be an information about how to connect it.

 

Mike

0 Kudos
Message 2 of 37
(7,863 Views)

Thank you for the quick reply, Mike.

 

Yes, for the "string to write" field, I put the commands that are specified on the device description.

But the vi got no response from the device and gave me error saying "time out".

 

Is it because I specify to read more bytes than the number of bytes actually read?

0 Kudos
Message 3 of 37
(7,857 Views)

Hi mogusa,

if you change nothing in the example, then you wait the "delay before read" time. You only read the number of available bytes. Did you enter the correct termination character?

 

Mike

0 Kudos
Message 4 of 37
(7,854 Views)

Hi mogusa.

I was a begginer, and I didn't found a tutorial for programm serial, because it doesn't exist.

You have to order manual for your hardware, to communicate with it. In this document you have to found the protocol, I mean those telegrams that you have to transmit and receive.

You find exemples in that document too.

For your help I give you my hardware identification:Circutor CVM-BD. You find manual on internet, and you will find exemples for telegrams....it's easy. Same for all. 

Good luck !

 

PS: If you write specific commands for your hardware in "Basic write and read.vi", you will receive a good response. That vi works, I used myself.

0 Kudos
Message 5 of 37
(7,843 Views)

Hi Mike,

Yeah, the delay time between Read and Write is about 500ms.

I believe I put the correct termination character for the device, which is <cr>, and "enable termination char" is set to False.

 

The program is all set to default. I want to see if the device response anything when I put the command in "string to write", but seems like the device is not getting any command.

 

I now understand what data bit is, but I still do not know what byte read is... It always returns 0.

0 Kudos
Message 6 of 37
(7,803 Views)

Hi dsasorin,

Thanks for replying my question.

 

I do have the manual for the device and it has those specific commands such as V<cr> for measring output voltage.

 

I am having trouble with communicating with that device via RS-232, the device give me no responce even though I type correct command...

 

Do you have any idea???

Thanks

0 Kudos
Message 7 of 37
(7,797 Views)

This is sounding a lot like a hardware problem.  Take a good look at your interface.

is CPU Tx connected to Device Rx?

Are the com port settings correct for your equipment? (baud rate, data bits, parity, stop bits, flow control )

"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 37
(7,791 Views)

Hello mogusa,

 

If you have 2 serial ports on your computer, I would suggest connecting them via a serial cable and use the "Basic 2 Port Serial Write and Read.vi" shipping example. You should be able to specify the COM ports of each and easily read and write this way.

 

For your application, be sure that your COM port settings match those of the device, and that you are using a null-modem serial cable. A straight-through serial cable will not work when connecting 2 standard serial ports. If you are able to successfully run the above loopback test, then you can be sure you are using a null-modem cable.

 

There are many serial communication resources located at NI's Developer Zone. A search for serial communication brings up a couple of really good articles and examples for starting out.

---

Peter Flores
Applications Engineer
Message 9 of 37
(7,782 Views)
Solution
Accepted by mogusa

If you are sending <cr>, then you are not sending the carriage return correctly. In LabVIEW, the simplest way to do this is to have '\' Codes display turned on for the string control/constant and send \r. The default termination characters in the Basic Serial Write and Read have \r\n (CR\LF) and if you deleted those, that was a mistake. Also, you want to enable termination character is your instrument sends one with a response.

 

Serial communication is a common problem for beginners and there are thousands of posts related to the subject. Have you looked at any of these ealrier posts?

Message 10 of 37
(7,776 Views)