04-30-2017 08:07 AM
Hello everyone,
please can someone help me with following problem?
I´m using my own DAQ electronics for fast data sampling from magnetic probe and sending data over UART (using fast FT232H UART->USB converter IC). (Samplerate is now 64kSa/s, the goal is to get as high as 128kSa/s). DAQ digital resolution is 24 bit, so I need to send at least 3 Bytes of data (to synchronize packets I'm sending 5 Bytes ... 3 Bytes of data constrained to 7bit, then residue 3 bits + 8th bit, and just 0xAA value....).. All this together it means 64000x5x11 bites per second = 3,6Mbit/s... UART speed is now 6 Mbit/s (maximum is 12Mbit/s) ...so should be enough..
After troubleshooting slow UART reading (UART buffer always overflowed), now with fast timedloop, I'm reading data fast enough from UART and append them to queue. But I'm not able to do something with them so fast... (I'd like to calculate and see realtime spectrum - PSD and maybe Y-t plot... it would be needed to add some averaging or triggering - update rate of Y-t plot is uncomfortable high...)
Any ideas, why it is so slow, that it can not handle such samplerate? (queue size is increasing fastly with on time - it is possible to see increasing delay between real data and Y-t plot or PSD)
And one another (little) problem is that timedloop sometimes don't run as fast as it should (and then even UART reading is overflowing..), it seems to be about 1/4 cases... timed loop priority is set to maximum and VI execution priority seems to don't affect that (but it is on almost maximum, maximum don't support timed loops)...
I´m also attaching LV2015 project
Best Regards,
David N.
Solved! Go to Solution.
04-30-2017 09:33 AM
David,
Here are some suggestions.
Bob Schor
05-01-2017 10:13 AM
Hello Bob,
thank you very much for such a fast respond and many advices,
one (little embarrassing) mistake I have made - termination character should be OFF! (my 5 Bytes chunk did not contain 0x0A - sometimes it did, but not purposely - just randomly - but in most cases yes, so it behaved like it worked..) - with only this change, it works pretty good - except writing to file - that make some trouble with lagging - Y-t chart and PSD works properly until I add path to file to write... (too slow access to file?)
Purpose of timed-loop is reading data as fast at it can - while loop that read data from UART everytime when termination character arrive is too slow. After loop execute each one iteration, Windows take processor time from labview thread and assign it back after some time (about 10ms), and in this time UART (probably HW/driver) buffer overrun (0.01s x 5 x 64000 = 3200 Byte)... (Well, probably.. I don't understand OS very much...)
I'v tried to use structure "producer-consumer" as you suggested, but I came across slow reading problem again... I'm attaching that modification (I have also changed byte chunk to that you recommended - all bytes have MSB=1, only last byte is just 0x0A)..
I´m attaching new version with "producer-consumer" idea... "Average datarate" should be 64kS/s x 5B = 320kByte/s, but is about only 100kB/s.. wich indicates too slow reading)...
Thank you!
Best Regard,
David
05-01-2017 11:08 AM
Are you insane?
seriously, 3 bytes at 7 bits = 21 much less than the 24bit ADC value. Then you actually set up the VISA port for 8 bits. OK
Then you have a ridiculous rate of 6Mbaud ( i hope the phy layer is really short) a 10 second timeout and a 100k buffer. and expect it to not overflow the buffer? with 1 start bit 1 stop bit, 1 parity bit and 8 data bits a 100K buffer gets filled a lot faster than 10 seconds.
6MBaud, I still can't quite wrap my head around that. 0ne 24 bit ADC value every 16.7n (Nano)-Seconds ?
I gotta get me one of those.
05-01-2017 03:46 PM
Hello Jeff,
I really don't understand your little bit aggressive tone, I wrote, that I have 24bit@64kSa/s, not every 11,7n... if I would have 85MSa/s@24bit, then I would be a millionaire or something 🙂
And I do not have 3x7bit=21bit.. I wrote that I have 3x 8bit + rest of 24bit (3 bits) in another byte = 4x8bit (all have MSB=1) and then 1 byte with MSB=0 (0x10) to synchronizing packets... so... I really don't think that 6Mbaud is ridiculous... (5 Bytes @ 64k/s @ 11bit/Byte = 3,54 MBaud as theoretical minimum!)
100k buffer is just random big value (I suppose that HAL layer will constrain it to its maximum, 4k or 32k.. I don't know)...
10s timeout is just again a random number, it means that if device will stop do anything, then after 10s VISA will timeout... Data are readed in timed loop every 1ms = 320 byte - HW buffer is 1k, SW buffer (maybe) 100k...
Best Regards,
David
05-01-2017 06:56 PM
I wasn't trying to be offensive. 6 mega baud is crazy fast. Most hardware cannot work with that speed over any distance.
I mearly meant for you to help clarify the real requirements.
Seriously,what are you attached to? How fast does the measurement change?
05-01-2017 08:38 PM
Jeff is right. 6Mb to 12 Mb/sec is crazy fast for a serial port. If you think about it, that is the speed of low speed ethernet ports, and they rely on special hardware and twisted pair, low capacitance wire to achieve that. Normal serial ports (are you talking RS-232 or RS-485) and wiring weren't designed for that.
Take a look at this.
http://digital.ni.com/public.nsf/allkb/D37754FFA24F7C3F86256706005B9BE7
You can see that NI-VISA can handle up to about 1 Mbit/sec on special hardware. You're looking for 6-12 times faster.
05-01-2017 09:38 PM - edited 05-01-2017 09:40 PM
Kudos for anyone
I think it was John Candy that had a great line in Spaceballs the Movie.
We've gone to plaid.
As I recall plaid is faster than "ludicrous speed"
05-02-2017 03:53 AM
Hello,
ok, althought HW works properly, let me explain the HW part... I have a tiny (about 4x8cm) DAQ board with ADC+MCU+FT232H ... MCU reads data from ADC over SPI (clocked to 12 Mb/s), then immediately sends them over UART (TTL, not RS232 levels) to FT232H IC (~2cm traces), I realy don't see problem with such speed for the distance... (If it would use RS232 levels and we talk about meters of distance, then ok.. 6M is really insane...)
And speed of VISA is limited by driver, right? Well, FT232H is designed for such purpose (supports 12Mbaud/s UART), so we can call it "specialized" HW 🙂
Best Regards,
David
05-02-2017 04:56 AM