LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to recive data every 200 us by SerialPort

Hello,

 

I need to desing a DAQ with high resolution and with high sampling ratio. So I am using a Arduino DUE for read 25 Sensors and for send this information via SerialUSB. I need 5ksps of sampling rate on each sensor so I am sending every 200us a data package of 75bytes (3bytes per sensor), but LabView doesn't read the buffer with this rate, that's generate the Serial port buffer fill.

I am using VISA library, I tried with and without interruption on serial port and anything works. I did some test and the sending data ratio that don't fill the SerialBuffer is more tha 10ms, but this is too much for what I need.

 

I don't know if exist any way to use USB interrup raw or another way to improve this. Or maybe the loop that I'm using to organizate the data is using the procesr power (I recive data in two's complement).

 

Thanks for help or coments, I am learning Labview and I could make roockie mistakes.
The principal VI is FourTry.

0 Kudos
Message 1 of 21
(2,150 Views)

Watch this video, I think it might help.

 

VIWeek 2020/Proper way to communicate over serial

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 21
(2,134 Views)

It sounds like you're using serial via USB, and I've had USB-serial adapters before that have had driver settings that you could change to get better response times.  Go to device manager, find the device, and see if you can find any settings for the device in question.  On mine, I got a lot better response times when I changed the latency timer from its default 16 ms down to 1 ms

Kyle97330_0-1665181715513.png

This isn't a guarantee you will have similar settings that you can change, but it's something to check.

0 Kudos
Message 3 of 21
(2,115 Views)

The Arduino DUE has a native USB peripheral on the chip that is used by the SerialUSB library. This makes the issue a bit more interesing - I'd recommend reviewing this article and accompanying video if this is news to you (and if you can abide the non-standard pronunciation of 'due'): https://hackaday.com/2021/03/20/arduino-serial-vs-serialusb/

 

0 Kudos
Message 4 of 21
(2,090 Views)

Let's also do some math here:

(75 Bytes*10bits/Byte)/200us = 3.75Mb/s.  So your Baud Rate needs to be 3750000.  That is way more than a normal serial port.  Are you sure your interface can handle that?  I honestly don't know what the Arduino Virtual Serial Port can do, so that is a serious question.

 

Note: The 10bits/Byte is from 8 data bits + 1 start bit + 1 stop bit in the UART protocol.


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 5 of 21
(2,068 Views)

@crossrulz wrote:

Let's also do some math here:

(75 Bytes*10bits/Byte)/200us = 3.75Mb/s.  So your Baud Rate needs to be 3750000.  That is way more than a normal serial port.  Are you sure your interface can handle that?  I honestly don't know what the Arduino Virtual Serial Port can do, so that is a serious question.

 

Note: The 10bits/Byte is from 8 data bits + 1 start bit + 1 stop bit in the UART protocol.


With native Serial-USB implementations, all UART parameters may be purely virtual and may or may not be handled at all. Start, Stop and Parity are almost certainly ignored, as their function in the Data Link layer is no longer needed. The same reasoning applies to the Baud Rate.

 

It seems that timing itself is a critical part of the question. With serial converters, the device is polled regularly to keep the buffers happy, the data moving and the physical lines busy. In native USB, the device just sends a chunk when it feels like it, including the packet overhead of roughly 20 Bytes.

 

The question here seems to involve some requirements on the timing. The latency setting, if present, might be used to set an upper limit on the time between flushes, but is 1ms fast enough here? That would be 5 samples arriving at the same time. Manually flushing the buffer on the DUE might do the trick but incurs the packet overhead each time.

 

Maybe the time critical part of data handling could be done on the DUE first? If this is just about timing information and not latency, maybe a timestamp could be added to the data set before sending it?

0 Kudos
Message 6 of 21
(2,042 Views)

@LLindenbauer wrote:

@crossrulz wrote:

Let's also do some math here:

(75 Bytes*10bits/Byte)/200us = 3.75Mb/s.  So your Baud Rate needs to be 3750000.  That is way more than a normal serial port.  Are you sure your interface can handle that?  I honestly don't know what the Arduino Virtual Serial Port can do, so that is a serious question.

 

Note: The 10bits/Byte is from 8 data bits + 1 start bit + 1 stop bit in the UART protocol.


With native Serial-USB implementations, all UART parameters may be purely virtual and may or may not be handled at all. Start, Stop and Parity are almost certainly ignored, as their function in the Data Link layer is no longer needed. The same reasoning applies to the Baud Rate.

 

It seems that timing itself is a critical part of the question. With serial converters, the device is polled regularly to keep the buffers happy, the data moving and the physical lines busy. In native USB, the device just sends a chunk when it feels like it, including the packet overhead of roughly 20 Bytes.

 

The question here seems to involve some requirements on the timing. The latency setting, if present, might be used to set an upper limit on the time between flushes, but is 1ms fast enough here? That would be 5 samples arriving at the same time. Manually flushing the buffer on the DUE might do the trick but incurs the packet overhead each time.

 

Maybe the time critical part of data handling could be done on the DUE first? If this is just about timing information and not latency, maybe a timestamp could be added to the data set before sending it?


You can't ignore things like parity and start/stop bits.  Baud rate certainly cannot be ignored.  How are you supposed to sync?  Just because a chip may be implemented virtually doesn't mean it can make up its own rules.

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.
Message 7 of 21
(2,026 Views)

@billko wrote:

You can't ignore things like parity and start/stop bits.  Baud rate certainly cannot be ignored.  How are you supposed to sync?  Just because a chip may be implemented virtually doesn't mean it can make up its own rules.


It is precisely the virtualization that allows that. That's the whole point. There are no physical RS-232 signals anywhere, so there is no need to negotiate their shape or timing.

 

This is the second time here on the forum that this comes up, so please allow me to elaborate. There are just two pieces of USB hardware that both talk  USB to each other and inform each other, using USB, about the state of their own UART. It just so happens that neither UART exists in physical reality. There are certainly are no native RS-232 signals, no DTR or RI anywhere on my machine. But I can still have my computer pretend to a USB device that there are, in fact, bauds and parities and CTSes and the whole works. Why should the device on the other end of the USB cable be unable to do the same in return?

 

It's just like dialing a number on the cell phone: Back in the days, when you dialed a number, your phone would send a pulse train or tones down a landline to let the switch know where it should route the call. You had to manually finish dialling in a timely manner before the switch would time out and hang up on you. Now, this is all done virtually. We still use numbers, but the dial timeout is gone and you don't concern yourself with the state of the signal line - the advantage of there not being one in the first place.

 

PS: You can check for yourself - the Arduino DUE firmware and SerialUSB library are open source. You can open it up and check for yourself if you don't believe me.

0 Kudos
Message 8 of 21
(2,010 Views)

@LLindenbauer wrote:

@billko wrote:

You can't ignore things like parity and start/stop bits.  Baud rate certainly cannot be ignored.  How are you supposed to sync?  Just because a chip may be implemented virtually doesn't mean it can make up its own rules.


It is precisely the virtualization that allows that. That's the whole point. There are no physical RS-232 signals anywhere, so there is no need to negotiate their shape or timing.

 

This is the second time here on the forum that this comes up, so please allow me to elaborate. There are just two pieces of USB hardware that both talk  USB to each other and inform each other, using USB, about the state of their own UART. It just so happens that neither UART exists in physical reality. There are certainly are no native RS-232 signals, no DTR or RI anywhere on my machine. But I can still have my computer pretend to a USB device that there are, in fact, bauds and parities and CTSes and the whole works. Why should the device on the other end of the USB cable be unable to do the same in return?

 

It's just like dialing a number on the cell phone: Back in the days, when you dialed a number, your phone would send a pulse train or tones down a landline to let the switch know where it should route the call. You had to manually finish dialling in a timely manner before the switch would time out and hang up on you. Now, this is all done virtually. We still use numbers, but the dial timeout is gone and you don't concern yourself with the state of the signal line - the advantage of there not being one in the first place.

 

PS: You can check for yourself - the Arduino DUE firmware and SerialUSB library are open source. You can open it up and check for yourself if you don't believe me.


You are confusing the physical layer (which may have hardware handshakes) with the packaging layer.  Oh yeah,  each byte still gets sync and error bits.  Or, it would not be a "Serial" port... it would be a parallel or perhaps a multidimensional quantum port.

 

Your phone still needs to transmit each number tone pair digit by digit IN ORDER or you "dialed" the wrong number.


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 21
(2,002 Views)

I will grant that I have not been explicit about wraping up the Physical and Link Layer up as one in my examples. This changes little, since both are handled over USB and simulated on both ends. This can be seen in the article I linked above from the wireshark traces. There are no Start, Stop, or Parity bits transmitted.

 

The Serial Line is a character device. It promises you that if you put bytes in you get the same bytes out, as long as everything is aligned. As it turns out, when you don't have a physical line, you can just assume that the non-existant line was correctly aligned and don't worry about it.

 

The Start/Stop 'Bits' are not part of the application data. You would be very lucky to be able to mangle and bit-bang your application data just so that it might correctly move over a misaligned physical UART pair and come out at the other end as intended.

 

In the end, all this is of little consequence for most users. The virtual UARTs I have seen didn't care if you messed up the settings and worked fine either way. It might be of consequence for the thread opener, though, given that they have some tight timing requirements to fulfill. Maybe they would be better served to post the question on an Arduino hardware forum instead?

0 Kudos
Message 10 of 21
(1,975 Views)