LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Does Visa have any buffer/memory or similar?

Hi, I have a comunication with 2 radiomodems via RS232 port, and I get data with VISA in my laptop and have a Visual Basic program that controls the frames in the other embbedded PC that sends me frames of an electronic compass and a GPS. The thing is that in the VB application I can see the correct frame of the compass to be sent, but the one that I recive in my laptop is not the correct one, in fact is the one that was sent 30 secs ago so I can't allow that happen and I have no idea what could be the problem cause radiomodems transmit correctly and I made another VI program that only reads the frame and the same thing happened, so I have the thinking that it can be the VISA command that stores the frame or something similar. By the way, the compass samples twice per second, and the radiomodem sends that frame every 400ms. At the beggining, the compass sampled 8 times per second and I thought it could be the problem but it remains altough I changed that. What can be happening?

 

Thank you

0 Kudos
Message 1 of 48
(3,790 Views)

The VISA driver itself does not have a buffer.  You may be reading the buffer later than you think.  However, if that's the case, you should be dropping data (or eventually will).

 

Can you post your code so that we can see how you have implemented your solution? 

 

R

Message 2 of 48
(3,782 Views)
Well the code is a little extense because has a lot more things, but I make an application that only reads RS232 port and the same thing happens, and although the radiomodem that sends data is switched off, I am receiving frames for a while (the delay time). I have no delays on that application, but in my real one a 400ms delay. I don't know what should be the problem. Radiomodem does not have any kind of memory and it's "transparent" to the comunication, it should be like a wire.
0 Kudos
Message 3 of 48
(3,774 Views)
VISA does not have a buffer but the pc does. The default configuration for the VISA Configure Serial Port is to terminate a read whenever a termination character is detected. The default termination character is a LF and if you have multi-line strings you are trying to read, then with each read, you are not emptying the buffer. You really need to post some additional information about what exactly is being transmitted and how you are trying to read it.
Message 4 of 48
(3,763 Views)
Ok, I'm not doing any kind of <LP> to end the transmission so maybe that's the problem. I have 2 frames that I put togheter (one from a GPS and the other from an electronic compass) and I directly send them and read from a laptop with VISA read. I'll try tomorrow to put a LP and CR characters at the end of every frame that I send. By the other hand, I send from my laptop other frames to control some motors and I haven't that problem and I'm not sending those characters, but I recive that frames with VB.
0 Kudos
Message 5 of 48
(3,753 Views)
I don't know what LP is - I mentioned LF (Line Feed). If you aren't appending a termination character, then without seeing your code I can't say why your program does not work. If you ever get around to attaching your program, be sure to save it with some actual data.
Message 6 of 48
(3,747 Views)

Please post your code so that we can have a look at it.

 

R

0 Kudos
Message 7 of 48
(3,734 Views)

Sorry, I wanted to say LF not LP. I tried that and didn't do nothing, the same problem. The good new is that I finally found what was the problem. I have to put a delay of 400ms in my VI application and in the VB application. That did that somewhere, the frames were stored. Now I have changed the delay and put the VISA read inside a while with a condition of 400ms of time so now I recive the frames correctly. The problem I have now is that if I stop the VI application but not the VB one, and let the radiomodem send data, when then I run the program, I have a crazy frame showing that had been storing while the VI was stopped, and if that was for a long time, I get an error in VB because it recives a strange frame from my laptop. So, where could frames be storing while my VI application is sttoped???? Do I have to close the VISA port? I tried to do that, closing the serial port every time I sttopped reading and writing, but I only recive strange characters on frames, so it can't be the solution.

 

Thanks.

Mensaje editado por CarlosSp
0 Kudos
Message 8 of 48
(3,713 Views)

You should implement a graceful shutdown scheme, where a message is passed to / from both PC's to let the software know that communication is about to be cut.  After they both acknowledge it, they can stop the communication (read / flush the buffer) and close the port.

 

R

Message 9 of 48
(3,699 Views)

If yours is like the GPS I used it just spwes out data continually as long as it is running, so... 

 

When you stop your application, close the VISA port.

 

When you re-start it purge the serial port by checking the number of bytes waiting at the port then read and discard all that where waiting.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 48
(3,695 Views)