09-05-2008 03:28 PM - edited 09-05-2008 03:29 PM
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
09-05-2008 03:32 PM
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.
09-05-2008 03:40 PM
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
09-05-2008 05:40 PM
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
09-05-2008 10:02 PM
09-08-2008 03:20 PM
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
09-08-2008 03:32 PM
09-08-2008 03:57 PM
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
09-08-2008 04:30 PM
09-08-2008 04:51 PM - edited 09-08-2008 04:52 PM
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