LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 problem

Hi

Im working in a RS232 communciation through LABVIEW, everything is fine but I want to activate the Function Read Visa only when the PIC (microcotroller) is going to send the message. I have already used a simple control sending a number to the PIC to activate it when it reads the message from LABVIEW it send the temperature measurement; though, isn't there a simpler way?. The VI is attach...
0 Kudos
Message 1 of 5
(3,161 Views)
I'm not sure exactly what you're asking, so here are some observations:

  • Simpler way? Not really. You open a port, transmit a message, wait a while, see how many characters came back, read that many, close the port and decode the reply. Not much room to simplify that, although you might be able to make it perform better.
  • Waiting a specific amount of time for an RS232 reply is generally avoided, since all kinds of things can stall the process. It's usually better to wait for the right number of bytes to be received, even if that means you have to poll the BYTES AT PORT function several times. That lets your program adjust to the speed (or slowness) of the reply.
  • If the exchange takes place more than once, then don't run the CONFIGURE SERIAL PORT more than once. Save the VISA SESSION ID and use it again. Only CLOSE it when you quit exchanging messages.
  • If you use the default values for BAUD RATE, PARITY, etc., you don't need to have constants to define them. The CONFIGURE SERIAL PORT will default to the way you have it, even without the constants you provide.
Hope that helps.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 5
(3,115 Views)
Thanks for the advice
How can I wait for the right number of bytes to be received? I only have to assign a certanly BYTE COUNT, right?. The new VI is attach..


0 Kudos
Message 3 of 5
(3,091 Views)
Any idea?
0 Kudos
Message 4 of 5
(3,050 Views)
I'm not sure what you are asking either. If the message returned is terminated with the character you specified with the VISA Configure Serial Port, you can use a high number for the byte count for the VISA Read. The VISA Read will automatically stop when the termination character is detected. If there is no termination character, you use the VISA Bytes at Serial Port to determine how many bytes are available and wire the result of that to the byte count input of the VISA Read. To get a little fancier, you can put the VISA Bytes at Serial Port inside a while loop and exit the loop when the byte count is greater than 0. Then, in another loop, you have another VSIA Bytes at Serial Port wired to the VISA Read and this time, exit the while loop when the byte count is equal to 0.
0 Kudos
Message 5 of 5
(3,046 Views)