Discussions au sujet de NI LabVIEW

annuler
Affichage des résultats de 
Rechercher plutôt 
Vouliez-vous dire : 

Multiple Serial Write/Read (RS232)

Hello,

 

I am using LabView 2014 and I want to communicate with one device via RS-232, the configuration of the serial port given by the manufacturer is as below : 

 

Byte structure : START-BIP -- 8 BIT DATA -- STOP BIT

Baud rate : 4800

 

I have to send four commands through the RS-232 port (for example, FRQ? or ERR?) and then read the responses. The termination character is CR(0xD) LF(0xA). 

 

Now I am able to send maximum two commands and read the responses. When I write more than two commands and try to read them at the same time, I get wrong responses (Please see attachment).

 

Do you have any idea how you should proceed?

 

Thanks.

 

Best regards,

0 Compliments
Message 1 sur 4
3 520 Visites

Hi lucdu39,

 

You're not exactly at the right place to ask this question : here is "le forum francophone", it means most of people speaks... French here !
Nevertheless, I'll try to answer your problem.

 

First of all, as a matter of form:
1. Your code... doesn't really fit for what you want to do. Using a structure event would be much more adapted than a while loop.
2. Besides, if you want to write some comments (which is a very good idea by the way), you can double-click on your diagram and open a commentary box, or (much more elegant) click right on the structure, then "visible items", then "label". This is better than create a string constant.
3. If you really want to keep the while loop : You can also open and close your serial port only one time, at the beggining and at the end of your program ! You can put out the while loop the first VI (VISA Configure Serial port) and the last one (VISA Close).

Thus, for your problem :
a. When you configure the serial port (first subVI), you didn't plug the termination character variable. By default, it is "LF" (0xA), and not "CR-LF".
b. You could try to "Clean" the VISA Buffer after each command with the "VISA Clean" VI, just before a "VISA Write" VI. The reason why you don't read what you want after the third command may is that the buffer is full.

Bilsix.
0 Compliments
Message 2 sur 4
3 479 Visites

Hello Bilsix,

 

Thank you for your reply and for your remarks.

 

The addition of the function "clean" does not solve the problem. I will try with the structure Event, it seems more appropriate.

 

Best regards,

0 Compliments
Message 3 sur 4
3 460 Visites

Hi Lucdu39,

I think first that it's better to open (init) the RS232 port before starting the while structure. Next, dialog whit your equipment (send commands and receive answers and do what you want with it) in the while structure and finally, close the RS232 port.

In your Vi, you open and close your port every 100ms, it's probably a source of failing.
I join your Vi modified

0 Compliments
Message 4 sur 4
3 400 Visites