You are here

ADC with DMA | Cypress Semiconductor

ADC with DMA

Summary: 15 Replies, Latest post by danaaknight on 21 Apr 2014 02:52 PM PDT
Verified Answers: 0
Last post
Log in to post new comments.
maxdamage's picture
User
47 posts
Attachments: 
H L
user_460349's picture
User
1362 posts

Can you explain what is your problem? and show us what you've done so far?

hli
user_78878863's picture
User
2759 posts

Oh, and please write your question in the text box, don't append it as attachement. That makes it easier to help you. (Pasting in the question below)

-------------------------

Hello everybody! i am new to PSoC and i am trying to do a similar project i want to read the analog output of a two
strain gauge sensor using an anlog multiplexer and and ADC and transfer them to a USB for further analisis i want to have a conversion of about 4000 SPS from
the 2 sensors for 10 seconds and ican't get this kind of conversion. i googled this and i found some information about the DMA
so i try to use it to get the data from the ADC and buffer it in the memory and thensend it through the USB.

Please help i am losing faith in this project !!

hli
user_78878863's picture
User
2759 posts

First, there is a set of application notes describing exactly what you need, for example AN61102. Did you read them? AN61102 has an example project, which might be a good starting point for your project.

Second, retrieving 4000 samples per second, for 10 seconds, means you have 40000 samples. This fits into the PSoC3 sRAM (64k max) only when doing 8byte sampling - and even then you need to be careful with memory management. What is that you want to do?

user_1377889's picture
User
10803 posts

Buffering 4000 smpl/s * 10s * 2 bytes would burst your sram memory - limit, so what you want is a bit complicated to acquire.

Your dataflow goes

ADC -> Transfer -> SRAM -> Transfer -> USB -> Out of PSoC

ADC  to SRAM "COULD" be done with CPU, but my experiences are with PSoC5, so we have the first candidate for DMA here.

SRAM to USB can probably made with DMA too, but the tranfer rate of the USB might be smaller than that of the ADC. So you might use a double or quad- buffer.

I would suggest you to start with a 1000 byte transfer from SRam to USB, then try to adapt it to 4 buffers of 1000 bytes each and measure the needed transfer time. Then you can see how that fits for your desired sample rate.

In the Keyword Search at top of this page you may search for "DMA buffer" and looke here www.cypress.com/ as well.

 

Bob

user_14586677's picture
User
7648 posts

"4000 SPS from the 2 sensors for 10 seconds"

 

1) Is that 4000 SPS from each sensor for 10 secs for a total of 80,000 samples ? You are limited to

8 KB SRAM.

 

2) Being a strain gauge I assume your conversion is > 8 bits ? If so the problem in 1) is effectively

doubled. eg. it would be 160,000 bytes to handle.

 

3) If you buffer out 16 bit samples, say 1000 samples at a time, you may experience lost samples

due to time it takes to transmit the samples. You shoud examine this, unless dropped samples irrelevent

to application. Note DMA rates pretty fast, so maybe this point is moot. At 4000 SPS sample to sample

time is 250 uS, that translates (using buffer size of 16 bits, 1000 samples) to a 25 nS transfer rate to get the

whole buffer transmitted during 1 sample time, a tad aggressive, to not drop any samples. Can you just

consider no buffer and transmit at the ADC rate to external system ? Then you would have a continuous

stream of samples, none dropped. Plenty of room for stack etc..

 

Regards, Dana.

maxdamage's picture
User
47 posts

 hello everyone thank you very much for your attention really appreciate it,,

 
I get the idea from using the dma from AN61102 and I literallary copied what they do in it.all I want is to get 2000 sps from each sensor for lets say 6 second and transfer them using usb to the computer for further analysis. Itryed to do this without the dma to get the analog signal -> convert  to digital-> send it using usb and then do the same for the second sensor but I cant get the transfer I want I get about 800 sample so I tryed  the dma I cant understand some of its code like #if (defined (_C51_))  I am really really novice I get my psoc 3 last weak so please help me iam stucked
user_1377889's picture
User
10803 posts

The #if(defined _C51_) is used to distinguish between Keil and GCC compiler which are different in some places. So for you and your PSoC3 this will be TRUE (defined) and that code will be compiled.

First question is: Are the 6-second-samples to take from all your channels interleaving or are it 6 seconds channel0, then 6 seconds channel1 and so on (which would make the solution much more easier)?

 

DMA can be a fast helpful approach, but it can be a nuisance to set it up and get it working. As usual take the approach of "divide et conquera": Get the first of your needed channels working and then expand to the others.

Next question is the number of bytes your ADC has to deliver. 8 bytes would make it easy, all others can turn out to be a bit difficult.

 

First step: Set up the ADC to put the desired values into memory.

Second step: Transfer an area of memory via usb to your PC

Third step: Combine both steps.

Fourth step: Expand to two channels

Fith step: Expand to your desired number of channnels.

 

When you get stuck with any of these steps, post your complete project here (use the "Create Workspace Bundle"-function) and when the documentation is in english language we probably can help you.

 

Bob

user_14586677's picture
User
7648 posts

If you use "File", "Example Projects", there are several DMA projects you

can extract from, as well as the DMA Wizard tool, to set up DMA.

 

user_14586677's picture
User
7648 posts

Pic that did not post, attached.

user_14586677's picture
User
7648 posts

"2000 sps from each sensor for lets say 6 seconds"

 

Again, you have 8 KB of SRAM in PSOC 3  to hold byte sized samples, if resolution is

> 8 bits, then word sized samples. This is 12KB / 24KB respectively/channel. The only viable

method is a sample stream being transmitted not as a group, but one by one, from

each channel. That way you could move 2,000 samples to client and not have any

concern about limited SRAM. Further possibly chain TDs so that sample gets moved

to SRAM, then out over USB. The client side would have to assemble the samples into

group, at minimum store them, and then you process the group however you want.

 

Or use PSOC 5LP which has up to 64 KB SRAM.

 

Regards, Dana.

Log in to post new comments.