LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Acquisition over UART -- having problems

Hello,

 

I am transmitting 80 bytes of data from my board to Labview every 300ms over UART. The board will also sometimes transmit messages if there is an Interrupt on the board. For this purpose, I have two While loops in LabView, One to process the 80 Bytes of data every 300ms, and the other to process the data, if there is an interrupt on the board. 

 

How can I efficiently handle both the loops, so that I don't miss any data from the UART port. 

 

Lets say, i am processing the 80 bytes of data in the first loop, and an Interrupt happens on the board and it sends a message over UART to LabView. I don't want to  stop the processing of the 80 bytes or corrupt it, but I still want to read the Interrupt message.

 

I am attaching my VI for reference. 

 

 

Thanks, 

 

birapxi

 

Message Edited by BIRA_PXI on 09-05-2008 03:29 PM
0 Kudos
Message 1 of 10
(4,245 Views)

If the two loops are running in parallel, there should be no reason that the first loop would stop running, even temporarily.

If the two are in sequence however, then you will run into problems. 

Cory K
0 Kudos
Message 2 of 10
(4,242 Views)

Hello Cory,

 

yes, the two loops are running in parallel with different millisecond delay. Since the first loop is just taking in value every 300ms, I have set it to about 900ms. But for the second loop, I don't know when the data will come from the board, so I don't know what millisecond delay should I set it to. Also If I set the loop delay to too fast ( 10ms), weird things happen, if I set it too slow (200-300ms), I might miss the Interrupt data in the second loop.. 

 

Is there any way in LabView to run these while loops based on interrupt from UART ??

 

Thanks, 

 

birapxi

0 Kudos
Message 3 of 10
(4,238 Views)

I can see the Interrupt values on the Logic analyser hooked up to the RX pin of the microcontroller, but cannot see it in LabView. Since both loops are referencing the same VISA Name, it is causing problems.

 

Any help will be appreciated. 

 

Thanks,

 

birapxi

0 Kudos
Message 4 of 10
(4,218 Views)
From looking at your VI, I think your logic is deeply flawed. It would appear that if an interupt occurs on the micro, it sends either a INT-FP, INT-RP, or INT-LOCAL message over the serial port. The middle loop is just as likely to read these messages as your bottom loop. It would seem to me that the simple solution would be to have a single loop doing the reading and first test to see if it is one of the interupt messages instead of blindly assuming that it is data.
Message 5 of 10
(4,210 Views)

Ok I changed the Entire program and made it in a single loop with Asynchronous UART setting. Now the problem is I am sending 83 bytes of data, which I can see on a Serial Port monitor , but LabView sometimes break the data stream into 3 or 4 pieces. The return Count on the VISA READ is not stable at 83 bytes, it changes every now and then.

 

Why is that happening. 

 

Thanks, 

 

birapxi

0 Kudos
Message 6 of 10
(4,171 Views)
In your original program, I don't see anyplace where you are asking for 83 bytes to be read. You are asking for how many bytes are in the buffer. It could be any number at all depending on how often you poll and how often the write occurs. If you are appending a term character to each string that you send, with the VISA Configure Serial Port to terminate the read when the character is detected. Specify a high byte count and low timeout value. Otherwise, you will have to get a little fancier. Check until byte count is greater than 0, read and check byte count again. Continue reading until byte count is equal to 0. Use the Concantanate String function and you should have a complete string.  
Message 7 of 10
(4,164 Views)

Hello Dennis,

 

I have attached the modified program. The VISA READ sometimes reads the 83 bytes send from the microcontroller every 300ms and sometimes it reads 7 bytes, sometimes 13 bytes, sometimes another random value. 

I get this count from the return count output of the VISA READ. 

Is the Timeout in the VISA configure causing this problem or the 5 ms delay in the first loop causing it. 

 

I checked the UART stream in a  Serial PORT monitor program and it shows 83 bytes all the time. 

 

I also used the Highlight execution button to see what's happening, but it doesnt help much. Is there a utility, which shows execution of loops against time on a graph. 

 

Thanks, 

 

birapxi

0 Kudos
Message 8 of 10
(4,159 Views)
Is there only one LF in the string you send or are there multiple? You have not included the subVI that does the parsing so I can't tell. If there are multiple, then that would be a reason you are getting inconsistent reads.
Message 9 of 10
(4,157 Views)

Hi Dennis,

 

The upper loop just sends different commands to the Microcontrollerwhenever the user wants.

 

The 2nd loop should read 83 bytes of data which includes a CR-LF combination at the end to notify the end of transmission from the microcontroller.

The 2nd loop does not read whatever the first loop is sending. Even if I don't send any command to the microcontroller, the microcontroller will still send 83 bytes of garbage to LabView. The microcontroller has a loop which runs every 300ms to send the data to LabView.

 

I have confirmed that the microcontroller is indeed sending 83 bytes by both hooking a Logic Analyzer and using a serial port monitor software. 

 

The Labview code on the other hand, sometimes shows me 13 bytes of data read, sometimes 7, sometimes 29 etc.... 

I wonder if it has anything to do with the Buffer settings of the COM port. 

 

Thanks, 

 

birapxi

 

 

Message Edited by BIRA_PXI on 09-08-2008 04:52 PM
0 Kudos
Message 10 of 10
(4,150 Views)