SAR ADC streaming to USB UART

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello, 

   

I need to take samples from SAR ADC at constant rate of 100Ksps and resolution of 8 bits. I read the datasheet of the ADC and relevant ANs (Starting with DMA, ADC buffering using DMA, DMA advanced topics, etc...). For the samples logging I used the "Teraterm" software. Before starting the design, I wrote a small program which sends data via USB UART and saw that it rate is about 230 KBytes/sec, which enough for ADC with 100Ksps  of  8 bits/sample .

   

I saw a lot of examples, while most of them take some amount of samples from ADC, stop sampling and send the samples via DAC or serial interface. This kind of solution isn't good for me, I need a constant sampling rate, I can't lose samples. The only similar example to my case was EP8353 ("ADC to Filter – Dual Channel 16-Bit Streaming using DMA"), but there the author didn't sent the samples via USB UART.

   

My idea is using 2 DMA channels, while ADC writes to the one of them, I am reading from the second and vice versa (in my previous design I did the same trick using one common array and one DMA, the result was the same.. 😞 ). The data that I got wasn't as expected, it seems that there is overlaps..., and some missing writes to register (data that sent was from previous filling of the same register, please see attached picture). 

   

The results are better (but not perfect) at sample rate of 10 Ksps than 100Ksps.

   

I thought about few solutions (but I assume that there is more elegant solutions...)

   

1. I thought about using intermediate register as described  AN61102 ("ADC Data Buffering Using DMA", page 16), but I don't fully understand how this serial process can help, while I try to implement a parallel process (I try to live more time to USB UART if there will be any delay, due to flow control for example...?)

   

2. I afraid that the bit rate using USB UART with TeraTerm isn't constant (maybe average rate is sufficient but the momentary is not) and I need to use full USB part..?

   

3. Adding local memory..., too complicated.

   

If you can share some ideas how to implement streaming of  100Ksps, 8 bits/sample ADC's data via USB UART it will be great.

   

Thank you.

   

Alex.

0 Likes
1 Solution
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Alex, the issue might be on the PC side. 100k samples/sec is not a problem for PSOC, up to 1 million samples/sec (in bulk mode) has been reported. For  USBUART mode I see occasional freeze of data transfer at ~50k bytes/sec. I blame USB-UART driver and plotting update speed for that. 

View solution in original post

0 Likes
2 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Alex, the issue might be on the PC side. 100k samples/sec is not a problem for PSOC, up to 1 million samples/sec (in bulk mode) has been reported. For  USBUART mode I see occasional freeze of data transfer at ~50k bytes/sec. I blame USB-UART driver and plotting update speed for that. 

0 Likes
Anonymous
Not applicable

Odissey1,

   

Thank you for you reply. I think like you that the problem is on the pc side due to flow control. I the following test: I transmitted sampled data at 100Ksps (as planned) to pc and each time the corruption appeared after 8 packets, I changed the program, while I keep 10 packets in PSOC's RAM and after it send all the packets to pc and the data was as expected.

   

I am trying to get some pc software with better priority to USB port (some kind of data logger), I hope that my PSoc design is correct.

   

Thank you.

   

Alex.

0 Likes