cancel
Showing results for 
Search instead for 
Did you mean: 

SD card write operation and spikes in analog ADC data.

prabhu
Associate II
Posted on January 08, 2014 at 16:43

Hi All,

I am using STM32F4Discovery board to log data from six analog channels at 50 KHz on micro SD card. Thanks to this forum for the help through various posts, particularly from Clive1. ADC operates in triple ADC regular simultaneous mode with DMA to transfer data in 98304 byte buffer.   The code works properly. SD card write operations are initiated on half transfer (HTIF) and transfer complete (TCIF) interrupt event (every 80msec). During the write operation large spikes as high as 50 to 70 counts are seen in analog data. For test purpose 1.5v battery is connected to analog channel.

Suspecting SD card write current might be influencing VDD, SD card was powered through a separate 3v regulator with bypass capacitor and ferrite bead in series. However this did not reduce spikes in measurements. I believe spikes might be feeding through ground or SDIO lines.

Most of the commercially available boards do not provide separate analog and digital grounds.  Is there any reference design for STM32f4 that address this kind of issue?  I would have liked to build STM32f427 based board as it has slightly better ADC performance and extra RAM. However, I am hesitant in view of the present problem. 

Any suggestions /comments would be useful in deciding whether to continue with internal ADC or to opt for external simultaneous sampling ADC.

Thanks

#board #sd-card #sd-card #adc #discovery #adc
15 REPLIES 15
chen
Associate II
Posted on January 08, 2014 at 16:59

Hi

''

During the write operation large spikes as high as 50 to 70 counts are seen in analog data. For test purpose 1.5v battery is connected to analog channel.

''

Even if you are using the internal Vref for the ADC - I doubt SD card writes could cause the supply voltage to wobble enough to be seen on the ADC.

Do you have an oscilloscope?

If you do - use it to look at the supply voltage (AC coupled if you are looking at noise) during SD write.

Is it really that noisy?

Personally, I suspect it is crosstalk between the digital lines to the SD card and the lines going to the analogue ADC.

You must keep the analogue lines away from the noisy digital lines.

You should be able to see this cross talk noise on an oscilloscope.

Also, heck the schematic for the Discovery board - does each supply pin of the processor have a decoupling capacitor?

If not - add one (0.1uF)

chen
Associate II
Posted on January 08, 2014 at 17:06

Hi Again

I do not believe any of the Discovery boards have built on board SD card sockets.

Is that right?

Did you add it yourself?

''I believe spikes might be feeding through ground

''

It is a possibility.

The key is to keep the return path as short as possible.

The 0V for the SD card should go to the nearest 0V of the STM32 port for the SDIO pins

The 0V from the battery should go the the nearest 0V of the STM32 analogue port pins.

Again - keep the wire as far away from each other as you can.

prabhu
Associate II
Posted on January 09, 2014 at 13:02

Thanks for your response. Having observed similar results on another board on which I was using Discovery, I decided to wire up SD card directly to Discovery with 47Kohm pull up on SDIO lines. The sample data plot is shown in attached figure. Data is written on SD card at sample number 4 Second figure shows data between 4000 to 5000 samples. SD card ground is connected by a 2�? long wire to the ground pin1 of connector P2. Analog signal, 1.5V battery connected across the ground pin and PA1 on connector P1 of Discovery Board. VDD spikes of around 20mv were seen on oscilloscope when SD card was powered from VDD. I would like to know if F4 ADC performance during SD write is better on any other platforms e.g. Olimex H-4

________________

Attachments :

plot.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzpB&d=%2Fa%2F0X0000000bQk%2F_NAGyTc1Ibo4J_dzrm1FJRcLPpwbeUrN45BcG4gHNEs&asPdf=false
chen
Associate II
Posted on January 09, 2014 at 13:38

Hi

Still not sure what is causing the supply voltage noise.

The Schematic for the Discovery board does not indicate if each Vdd has it's own decoupling capacitor (C30,24,31,32,34,35) or if they are just somewhere on the board.

2 possible remidies :

1 : offset the SD card write from the ADC sampling - ie do not do ADC sampling when doing SD card write.

2 : Buffer the SD card through something like 74HC243 and (possibly power the 74HC seperately)

If that does not work - you will have to talk to a proper electronics engineer (I just do it as a hobby)

prabhu
Associate II
Posted on January 09, 2014 at 15:33

Thanks again for suggestions. First option is not feasible as I my requirement is to log data continuously for couple of minutes at certain intervals. I will definitely examine the second option as I may have to use them even if I opt for external simultaneous sampling ADC.

frankmeyer9
Associate II
Posted on January 09, 2014 at 17:01

You might try to measure those EMI noise with a scope, perhaps using SD card events as trigger. Keep the leads to the probe on the ADC input as short as possible, else you will catch lots of phantom noise.

Not knowing your bandwith requirements, you could add a lowpass filter to your ADC inputs as remedy.

chen
Associate II
Posted on January 10, 2014 at 10:07

Hi

I slept on it and I had some more thoughts!

1. What power supply are you using to the Discovery board?

(If the answer is through the USB/debug port - then this could be a problem

Especially if it is going through an unpowered USB HUB.

The Discovery board should have some pins on the header for power - use a seperate PSU!)

2. You did not actually say where you measured the noise - power or on the ADC input?

If the noise is on the ADC input - then we have to work out where it is coming from!

(Remember I said I think it could be cross coupled noise)

3.  Some ADC peripherals allow you to supply external power OR Vref - Check the datasheet for this particular processor. If the ADC allows separate power (and the noise is on the power) - then you could cut the power line to the ADC and run power to the ADC through an inductor (ferrite ring with wire loops) to filter the DC supply.

Not sure this would fix issue with internal Vref but give it a try.

4. If noise is due to cross coupling - could try putting in line resistors for the SD card (try values between 10ohms to 50lhms). This reduces the current being driven down the line - should reduce the induced noise (a bit)

Just some more things to look at/try/think about.

prabhu
Associate II
Posted on January 10, 2014 at 17:09

Your suggestion -  2 : Buffer the SD card through something like 74HC243 and (possibly power the 74HC seperately)

- It is difficult to drive external bidirectional buffer in the absence of control signal for such purpose.

. What power supply are you using to the Discovery board?

(If the answer is through the USB/debug port - then this could be a problem  Especially if it is going through an unpowered USB HUB.The Discovery board should have some pins on the header for power - use a seperate PSU!)

- 5V (LDO-MIC5209) derived from 12volt battery.

2. You did not actually say where you measured the noise - power or on the ADC input? If the noise is on the ADC input - then we have to work out where it is coming from!(Remember I said I think it could be cross coupled noise)

 - It was on VDD line and not on ADC input.

3.  Some ADC peripherals allow you to supply external power OR Vref - Check the datasheet for this particular processor. If the ADC allows separate power (and the noise is on the power) - then you could cut the power line to the ADC and run power to the ADC through an inductor (ferrite ring with wire loops) to filter the DC supply. Not sure this would fix issue with internal Vref but give it a try.

- VDDA - ADC power on Discovery is derived from VDD using LC filter & Vref using RC filter on VDDA. This is the case with most commercially available boards. I would not like to cut tracks on Discovery board and experiment.  I will wait till my new board gets ready to see if separate supplies and ground planes makes any difference.

4. If noise is due to cross coupling - could try putting in line resistors for the SD card (try values between 10ohms to 50lhms). This reduces the current being driven down the line - should reduce the induced noise (a bit)

- I do have 22ohm in series and 47k pull ups on sdio lines.

Thanks!

chen
Associate II
Posted on January 10, 2014 at 18:12

Hi

''

It is difficult to drive external bidirectional buffer in the absence of control signal for such purpose.

''

I thought one of the SD card lines was a read/write signal. This could be used to control the buffer direction (and also goes to the SD card). The other signals just go through the buffer.

''

 - It was on VDD line and not on ADC input.

''

Have you looked at the ADC input during the noise? If there is noise when sampling - that is a different problem to noise on the supply rails.

''

I do have 22ohm in series and 47k pull ups on sdio lines.

''

47K pull ups - is that the recommended value for the pull up? Seems a bit large for a pull up (though thinking about it - it reduces the pull up current and therefore should reduce switching fluctuations?!?).

Have you tried a different SD card?

Are there any app notes for SD card interface?

Does it need a cap on the power to the SD card?