LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed UART Data

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?

Chris_Egan_0-1675283469265.png

Chris_Egan_1-1675283659709.png

 

 

0 Kudos
Message 1 of 8
(2,159 Views)

Hi Chris,

 


@Chris_Egan wrote:

  Is there something fundamental I'm missing? 


Fundamentals:

  • TimedLoops are intended to run on RTOS systems, not on Windows…
  • TimedLoops usually aren't needed to read COM ports…
  • Serial communication on COM ports usually is NOT that tightly timed…
  • Windows may hurt your timing accuracy…

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(2,145 Views)

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

0 Kudos
Message 3 of 8
(2,131 Views)

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.

0 Kudos
Message 4 of 8
(2,129 Views)

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.

0 Kudos
Message 5 of 8
(2,075 Views)

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.

0 Kudos
Message 6 of 8
(2,057 Views)

I highly recommend you watch this video: VIWeek 2020/Proper way to communicate over serial

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 8
(2,037 Views)

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.  

0 Kudos
Message 8 of 8
(1,927 Views)