LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

buffer problem

Solved!
Go to solution

Hello, I am REALLY new to labview and probably a beginner to programming all together.

 

I have a problem that is probably already answered but I do not even know what to search for.

 

My problem:

 

I am getting data from an instrument once every second and I am reading it every second. For example it will read 1234 (not really) and the next second the instrument will send it again and I will read 1234... but occasionally (like once every 10 min give or take) it will read part of the old data I read and I will get something like 4123...

 

I read somewhere something about a handshake thing?? I don't know if thats the problem?

 

Sorry I am really new at this. I have been playing with the visa buffer things, but its all very new to me.

 

So if you could give me a few links or so and point me in the right direction that would be great! Thanks!!

0 Kudos
Message 1 of 5
(3,081 Views)

Can we assume you are getting serial data (via serial COM port / RS232) from your instrument?

 

There is a "bytes at port" propertly for the serial VISA functions. Try checking how many bytes are available at the port with this function before reading, and then read all of them.

 

That way you wont be leaving any bytes in the serial buffer. 

Message Edited by Troy K on 04-28-2010 10:53 AM
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Message 2 of 5
(3,077 Views)
Yes I am getting serial data from my instrument. I will try what you said once I can. Thanks!
0 Kudos
Message 3 of 5
(3,065 Views)

It could also be that you are using the default serial port configuration which is configured with a termination character of 0x0A.

If the data being sent from the device happens to contain 0x0A in it, the read function will stop and any remaining data will be left in the buffer until the next read.

If that is the case, you can just set the 'use termination character' input to the 'configure serial port.vi' to False.

Message Edited by Troy K on 04-28-2010 06:16 PM
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 4 of 5
(3,048 Views)
Solution
Accepted by topic author kjs356

So I fixed the problem. I tried putting the flow control to RTS/CTS. I don't know if this is supposed to be obvious or not but it works now. Thanks for the help!

 

The only other problem is it sometimes starts with 4123 and will stay that way... but if it starts with 1234 the first time then it will continue working. But I can live with this for now.

Message Edited by kjs356 on 04-28-2010 04:21 PM
0 Kudos
Message 5 of 5
(3,020 Views)