LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Read reads wrong data only at the first applic.(start)????

Hi every body How do u do !? Thanks for last!
 
I've made a program that is suppose to read a data flow when I switch i button to start.
So If I starts the program for the first time (after the program application was shut down at all), the Serial read reads only 2 different data values from the serial port. It switches between these two data values all the time and do not reads the data from the flowmeter. So if i switch to stop and then to start again... it works normally again and the program measures the dataflow received at the serial port.
I'm not really shure if the program, when reading the two data values only, are reading the last two data values from the PC data buffer or it reads the two data values from the device connected to the serial port.
But if some one have a clue.. then please tell me..
Meaby I'm not configurating the device right. or meaby its something else.
HHeeeeeelp I've used a Hell lot of time on that..
 
PS. The bit rate and baudrate and stop bit and ect. are all correct.!
Regards
Zamzam
HFZ
0 Kudos
Message 1 of 6
(3,830 Views)

Try using the 'VISA Flush I/O Buffer' function before the first read.  You will find this under VISA >> VISA Advanced >> Interface Specific, on the Functions palette.

If that doesn't work, do a dummy read before the actual read.  That is, ignore the first read -- do this read outside your read-loop -- and do not error-chain this to the next function. 

Hope this helps.

-Khalid

Message 2 of 6
(3,822 Views)
Thank you Khalid.
 
I've tried with the flush before but no succes.
 
I also tried with the dummy variable, it works but i'll not use it  coz it takes time.
I need to run the flow, at least 3 seconds before I can get the a right flow when starting the application again.
 
I need some how to understand, from where the two data values are being read. 
The flow device, empties its buffer if it recieves a Return key after each data command sent to it from my program, so it not the device buffer that is the problem.
I've maked shure that my data commands to the flowmeter device are correct.
 
But meaby some one could tell me what that code do when sent to a device.
 
hex:                    <18><00><1E><7E><18><00> 
translated           CAN  NUL   RS     ~   CAN  NUL
 
I suppose I need to send this command to the flow device to set somthing up in it.
But in the device sheet  there is nothing about that but its important to send this command before configurating the device.
Meaby it some kind of handshaking between the device and the port.!?
 
Regards
 Zamzam
HFZ
0 Kudos
Message 3 of 6
(3,811 Views)

I agree with you that, ideally, we would like to get to the root of the problem and solve it. 

I am just curious why doing a dummy read would take time?  All you have to do is read the number of bytes at the port, do the read and ignore the results and errors.  Shouldn't take more than a few milliseconds.

Again, I agree with you that, ideally, we would like to get to the root of the problem and solve it....

-Khalid

0 Kudos
Message 4 of 6
(3,794 Views)
Morning everyone
I've once got that problem with the wrong data at  the first read when staring my application. 
I've made a dummy read in the background, but did not work!
 
I also used the flush I/O buffer, but no succes.
 
i'v tried to make a test to check where from the wrong data are being displayed and found out that they are coming from the device that are taking the measurements.
 
Meaby i'm configurering the device wrong. But how can I be shure that a device is configured  right.?
 
HFZ
0 Kudos
Message 5 of 6
(3,755 Views)

As per your earlier post, doing a dummy read did work.  Maybe not? 

In any case, what is the device that you're trying to talk to?  Does it come with a configuration software?  Can you test the communication with this software?  Does it come with documentation on the Serial port settings? 

If the device accepts simple string commands, try using HyperTerminal, or any other Serial port utility.  Also, you can use Portmon to monitor your Serial port activity. 

Thanks,

-Khalid

0 Kudos
Message 6 of 6
(3,742 Views)