LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA in LILO Mode?

Solved!
Go to solution

Hello everyone,

 

i reduced the VISA Serial buffer size to 1 byte. I have an ADC-Board that sends 3 bytes in 3ms to the PC over Serial.

When i read the VISA after 3ms i get the first received byte, but not the last one, although i changed the buffer size to 1 byte. Is its possible to get the last received byte? Do i overlook a setting?

 

Thanks!

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

Hi ER,

 

don't fiddle with buffer size!

Read all 3 bytes, then only process the 3rd one…

 

(You should get a warning/error because of not reading the buffer before new data was received!)

Best regards,
GerdW


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

Thanks GerdW,

 

you'r right with the buffer size. But if I use "bytes at port" and try to send my data faster, then I have the problem that I get data pakets of 32 bytes or something like that and sometimes i get nothing.

 

The following methodes i have tried:

 

1) I send a sign to my ADC board to instruct him to send me a measured value (2 bytes) back => It takes 4-5ms. This ist unfortunately much too slow.

 

2) When my ADC board has completed a conversion, then it automatically sends me 2 bytes using Serial (around 6-10 bytes/ms). This is fast enough.

At a certain point in my loop, nearly every 1ms, I want to read only the last two received bytes to synchronize it with a position value of a stepmotor, but then I have often wait to long and get 16 or 32 bytes at once or I get no bytes at port.

 

I will use LIFO (last in first out) method without using "bytes at port". Is it possible to change the buffer to a stack data structure with a variable size of two byte?

 

LabVIEW uses a queue structure to save received data via serial, like FIFO principle, right?

 

 

Thanks!  Best regards.

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

Something doesn't make sense about your scenario.

 

Your restriction is on the "device" side in that it can only sends a byte or two at a time relatively slowly.  Trying to make the buffer on your PC serial port small isn't going to  make that situation any better.  It is actually going to make it worse because now you've created a bottleneck at the PC as well.

 

Have a standard buffer at the PC.  Go ahead and use bytes at port to read whenever you are ready to read and read that number of bytes.  If your loop rate is fast enough, and that the sending device is slow enough, you'll be reading only the 1 or 2 bytes every loop iteration.  If by some chance there is a delay on your PC and the device has had a chance to send several bytes, you'll have plenty of room in the buffer to receive them all.  If you only want the last, then just read them all and ignore the first bytes in the buffer.

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

Can you even do anything other than FIFO on a UART?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 8
(2,802 Views)

I've never heard of it.  It kind of kills the thought of "serial" which implies keeping things in series.

 

And what is the technical difference between FIFO and LILO.  Aren't they just opposite ways of saying the same thing?

Message 6 of 8
(2,794 Views)

Oftentimes when you are trying to do something unusual like this, the better question to ask is "why?" and not "how?"

 

The whole system seems very fragile.  It would seem that just about anything could make you lose sync.  The system, as described, also seems also very prone to jitter because you really don't know when the conversions are being done, plus you are relying on Windows to time everything for you.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 8
(2,785 Views)
Solution
Accepted by topic author E.R.

Hi,

 

now I have a solution. At first: If I use in every loop "bytes at port" then I always get 32 bytes, followed by 4 times zero bytes.

So, I changed my method:

 

1) I start my step motor

2) I start my ADC-Modul: Its send me now continuously values, using serial.

3) I'm in loop and wait until my motor is finished, then I stop the measurement.

4) I use "bytes at port" to get all values at once

 

Now I can assign my measured values relative to my position (using 1D Interpolation)

This is possible because I detect with each measurement the same number of values. So all times/delays within my loop are almost constant. With 1000 measured values, a measured value more or less no longer plays a role.

 

So, thanks for the suggestions!

My graph and the compute results look promising.

0 Kudos
Message 8 of 8
(2,749 Views)