STM32 ADC kickstart example

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32 ADC kickstart example

Postby Giovanni » Sun Jan 13, 2013 8:21 am

It is most likely effect of noise. You should work on wiring ad shielding.

Giovanni

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: STM32 ADC kickstart example

Postby Tectu » Sun Jan 13, 2013 12:09 pm

In general, as Giovanni said, It's never the ADC itself but noise problems on the signal traces to the MCU pin. When you are measuring so slow signals like you do, you can also use the not used CPU time to perform software noise filtering.


~ Tectu

Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: STM32 ADC kickstart example

Postby Rick Burnett » Sun Jan 13, 2013 3:40 pm

Ahhh, okay. Well in this case since it's breadboarded up I can totally understand where the noise is coming from. The wires are probably longer than they need to be. Since I am measuring such slow changes coming into the ADC, I would imagine I could also just add a cap across the input as well? Just get rid of those high frequency changes right off the bat?

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: STM32 ADC kickstart example

Postby Tectu » Sun Jan 13, 2013 5:52 pm

A single capacitor won't fix your problem at all. You'd need to create a lowpass filter. The easiest form of this is an RC combination. You can find plenty of informations about this on the internet. The next better thing is an active lowpass which is build from an R, a C and an OpAmp.
However, ADC input noise filtering is a very serious topic and you can find many many great PDF files published by companies such as TexasInstruments, AnalogDevices and many many more. I'd suggest you reading through them - they are pretty interesting :P
Are you doing this just for fun or will this become some serious enduser device? You really might want to bother with software side filtering. When your MCU is idling half the time, this is a nice way to make something really useful with the free CPU time. Software filters are always way more accurate than every RC combination. Of course they also give you a lot more fexibility. For example, the RC lowpass filter depends on the base frequency you are working with. When you change it - you have to change the components as well.


~ Tectu

Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: STM32 ADC kickstart example

Postby Rick Burnett » Sun Jan 13, 2013 7:13 pm

I did have one other interesting observation, ever since turning on the ADC as I've posted, I have to use the BOOT pin to allow me to write to flash. I hook up BOOT to 3V, reset, write with st-link, remove BOOT, then reset and then put 'run' in GDB.

Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: STM32 ADC kickstart example

Postby Rick Burnett » Sun Jan 13, 2013 8:33 pm

Tectu, thanks for all the information! This is going to be a product at some point I hope. It's funny, I am a microelectronics engineer and I design ARM chips (backend design) but I never use them at this level, so that knowledge really does not help me. I will definitely start looking at different solutions. My wires were REALLY long so I can definitely see how the noise would be a problem. The market that I am pushing for with this, other people are using the Arduino chips, PIC controllers and even FPGA to do audio processing (and even low frequency work). Given the lack of processing power on some of the implementations I have purchased (synth hardware) I cannot imagine they are doing software filtering, and yet, their devices work REALLY well. I figured trying RC at first would be the easiest. I've got to get my head out of the micro world and back into macro electronics :)

ChibiOS is just simply awesome. Granted, STM32F4 development is A LOT harder than when I bought the Arduino MEGA, and then went to the DUE, but wow, performance is great.

In any case, thanks seriously for the help. Normally I don't ask as many questions but I figured if I cannot find the answer on here, others would benefit from the same information.

Also, once I get a good reference design down, I am going to build a board so a lot of the noise issues will be reduces and I will design the board to shield as much as possible on the ADC lines. Knowing I could also do stuff in code is definitely something to keep on the back burner.

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: STM32 ADC kickstart example

Postby Tectu » Sun Jan 13, 2013 8:46 pm

Feel free to ask any further questions. The ChibiOS community is full of people which like to help where they can ;-)

I'm an electronics engineer myself and a good friend of mine is in the world of digital synths and stuff. He tells me stories about audio processing and also the analog part before and after the CPU - man, this is nothing we can do alone at home at all :D
However, for simple applications I guess some standard analog electronics will do fine.

Might you give some more informations about your project at some point? This sounds really interesting.


~ Tectu

Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: STM32 ADC kickstart example

Postby Rick Burnett » Sun Jan 13, 2013 9:09 pm

Definitely! Given that I am using ChibiOS I want to show others what you do with it. Obviously, when the time comes I will have to seek licenses to be able to sell my product, but the hardware interface stuff (ADC, DAC, LCD, etc) I only feel right that I need to contribute back. Basically, I am making a Eurorack module. The first design I am doing is an oscillator.

I bought this board:

http://www.wvshare.com/product/Open407V-D-Standard.htm

As well with a bunch of the modules, specifically the DAC/ADC board that does stereo in/out. Though, that said, for my OSC design, I want to do the LCD over SPI now because I really don't have a lot writing to it, mostly just static information (for now).

I started this project on the Mega which was WAY TOO SLOW for what I needed. Then I went to the Due which was better, but no FP processor meant I was really stuck on some things I want to do. Then I saw the DSP library for the STM32F4 and I was sold. Which is funny, because a coworker told me to go with the STM32F4 from the beginning and I didn't. And here I am. But, maybe I wouldn't have been prepared to put together the toolchain and everything else had I gone that route. There was A LOT of overhead.

All that said, I am much happier right now where things are. I've still a few things to design, but I should be in software only mode soon. The LCD was the last big hurdle.

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: STM32 ADC kickstart example

Postby Tectu » Sun Jan 13, 2013 9:11 pm

I know what you mean about giving something back / contribute to the community. That's mainly the reason why I keep the ChibiOS/GFX project going. I mean I don't know how I can thank Giovanni otherwise (since I don't have too much money :P)

However, that project sounds quite awesome. It might happen that I want to contribute to it. Maybe I could bother with the LCD and SD or what ever stuff?
This project would look great in the user projects section of ChibiOS/GFX :P


~ Tectu

Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: STM32 ADC kickstart example

Postby Rick Burnett » Sun Jan 13, 2013 9:26 pm

Definitely! Let me get a little bit further along and then I'll drop some information in there. As for the LCD, hopefully I can get it working tonight at some point. Then, I'll take a look at the GFX library before implementing more and try to port this over using one of the examples.

Right now I am just trying to draw a red line on the screen! :) Haha. I figure, once that succeeds then I will be much further along!


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 4 guests