LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Reading Using Property Nodes Skipping Data

Hi All, 

 

I am working on a project where I am reading data from an RS232 Serial port without using VISA. I have tried to use VISA but the serial device we are using is homemade and will not work with VISA for some reason. The code I have works for the most part however, after a few seconds of running it will randomly skip different data packets that are being sent in. For example, I have a code on my serial device that sends data packets which start at 0 then increment up by 32 each time they are sent up to 224 then then wrap back to 0 (the data stream is 0, 32 ,64, 96, 128, 160, 192, 224, 0, ...). After a few seconds of the data stream sending this it will start to skip data packets and look something like this: (0, 32, 64, 128, 160, 192,..). Because of this I suspect framing errors but my settings match between LabVIEW and my device and I am able to read the device using MATLAB with the same settings just fine. Is there something I am missing here?

 

Thank you in advance. I have attached my code below.

0 Kudos
Message 1 of 4
(1,810 Views)

@vrogers wrote:

I have tried to use VISA but the serial device we are using is homemade and will not work with VISA for some reason.


Probably because you are dealing with a binary/hex/raw format and you had the Termination Character turned on.  Also a possibility is you were using the Bytes At Port, which is a big problem (weird race conditions).

 

Then I see 2 issues with your code.  First, the building of the array without bounds will eat up memory and slow down your loop.  If the DLL does not allow for an additional buffer, you could be missing frames if this slows down enough.  Second, I do not know the DLL, but you could likely do without your wait.  This is what the timeout is for.  So let the reading of data determine your loop rate.

 

Attached is what your code should look like if you were using VISA.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 4
(1,798 Views)

Thank you for the response. I tried the code you made using VISA and I still get a framing error so I think that part of the problem is my serial device. I also tried my code without the wait and it had the same issues. How do you make an array with bounds? I think it makes sense that the array size could be the problem because the code works fine for the first few seconds and the framing errors only occur after a short amount of time. 

0 Kudos
Message 3 of 4
(1,775 Views)

@vrogers wrote:

How do you make an array with bounds?


You don't.  Typically, you will make this into a Producer/Consumer so that you process and/or log the data as it comes in.

 


@vrogers wrote:

I tried the code you made using VISA and I still get a framing error so I think that part of the problem is my serial device.


That is a hardware issue and nothing to do with your LabVIEW code.  But another thing I have seen is if you have no breaks/delays between the messages, it can be hard to sync up the hardware and UART framing errors are common.  So you may need to add some delay in your device.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 4
(1,753 Views)