02-01-2023 02:35 PM
Hello,
I am using a timed loop to acquire UART data from a jet engine controller. Its an oldie so its running at 9600 BAUD. I have reason to believe that the timed loop is not accurate. See below:
The first column should be toggling every 83mS +/- 8mS. The first one is close but it seems to vary based on how fast (or slow) the loop is updated. Is there something fundamental I'm missing? Pretty confident that I'm getting every read of the port (otherwise the check would fail and I would all FFs for data. Any ideas?
02-01-2023 03:33 PM - edited 02-01-2023 03:34 PM
Hi Chris,
@Chris_Egan wrote:
Is there something fundamental I'm missing?
Fundamentals:
What else do you want to know?
Why do you think you can improve timing on this UART communication where so many things will influence (sender, transceiver, data buffers, OS of both devices, maybe some USB involved?) the timing?
How long are the messages you want to receive? On 9600baud it takes about 1ms to receive one byte…
02-01-2023 03:48 PM
Hi GerdW,
I kinda had the same result with a regular loop where the timing varied based on how fast the loop updated. The controller spits out sets of bytes depending on how many parameters we are monitoring. For the example I sent I was monitoring 2 parameters (which is 4 bytes) then it leads off with a Sync byte (1 byte - 55 or AA) and checksum (4 bytes) for a total of 9 bytes before it cycles through again. Note how I am reading for the Sync and checksum, then reading the next 4 bytes. I should see that set of 9 bytes get updated at a rate of about 18mS. I just want to get this accurate so I can queue up the results and record them. Let me know if there is any more info you need. The hardware is NI PCIe-8431/8 (RS-485) Interface.
Thanks
Chris Egan
02-01-2023 03:52 PM
Hi Chris,
It seems your controller send you packets at constant rate.
Have you tried to use VISA Events in standart While loop?
Serial Character event for example.
02-01-2023 09:02 PM - edited 02-01-2023 09:02 PM
To me, it looks like the VISA Reads are throttling the real-time loop. Since the VISA Read VI's typically block until the specified number of bytes are received, the loop will iterate based on the timing of the incoming serial data. Is this your issue?
Perhaps I am misunderstanding something.
02-02-2023 12:20 AM
Chris what problem are you trying to solve?
Receive a given number of packets without loss and pass them further?
If so, you need to keep your loop in sync with the controller's send rate.
There is no need for a Timed loop, just a classic While loop.
02-02-2023 09:44 AM
I highly recommend you watch this video: VIWeek 2020/Proper way to communicate over serial
02-09-2023 09:11 AM
Thanks for all the responses. I actually found a good solution. I dropped using LabVIEW for the timing. If you don't have an RT system, LV is not really that good when it comes to accurate timing when we are considering milliseconds. So, since the controller sends out data at a specific time based on how much data it is transmitting, I just calculated the timing and added it to the recording data. Works like a champ now.