Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Read serial port when new data comes in

Hello all,

 

I have a very basic understanding of LabVIEW, and have just recently acquired the project that a masters student was working on. The part of the project I am having trouble is with the serial connection that the laser roughness machine is connected to. The issue isn't reading the data, it's that I am only getting about 80-90% of the data that is being measured. I know that laser system itself is collecting all the measurements, but they are not all received on LabVIEWs end. The way the connection is setup is that the serial port is configured, and then a hex string is written to the port which I assume is a request for data (again I apologize for my ignorance, this was all setup by the grad student). Then the data string is then read from the serial port and sent into an array, so on and so forth. The read and write functions both have delays around them. Currently, these values are adjusted to determine the rate at which data is pulled from the serial port. Of course, trying to get these delays just right so that all of the data is read and not read in twice or skipped all together is virtually impossible due to the setup. My question is, is there a way to read data from the serial port only when there is a change in the data string, rather than having to use timing delays?

 

I hope this is all not too vague, and if any additional info is needed I can try and clarify.

0 Kudos
Message 1 of 2
(2,609 Views)

Well, you have to read the data in order to determine if it has changed. You can't configure the serial port driver to only return data if it has changed, since it doesn't know things at that level. You could set up VISA events so that you perform a read when you actually have a character in the serial port buffer. But I don't think that's what you'd want to do in this case. What do you mean by the write and read both having delays around them? I can see why there would be a delay after the write, but I don't understand what this other delay around the read would be for. Can you upload the code? Do you have any programming documentation on the instrument itself?

0 Kudos
Message 2 of 2
(2,594 Views)