Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

C++ project ADC and PWM setup suggestions

PWM ADC setup c++ native code input output

  • Please log in to reply
4 replies to this topic

#1 knutolai

knutolai

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 03 May 2013 - 12:39 PM

Hi 

Im designing my first C++ based project. I'm using the STM32F205 MCU (Netduino 2) and need some suggestion on ADC-input and PWM-output config/setup. I noticed both ADC and PWM has many different possible configurations and I'm having a hard time deciding how to configure them. I've found project examples that to some extent cover both, but again, a lot of different config options.

 

Hopefully someone can point me in the right direction for the config as I find the amount of options quite overwhelming (for ADC interrupt generation, interleaved more, dual/triple mode, continuous conversion mode etc., for PWM edge-aligned mode, center-aligned mode, 6-step PWM gen., one pulse mode etc.). 

 

STM32F2xx manual can be found here: http://www.st.com/st.../CD00225773.pdf

 

What I'm building is a digital guitar effect pedal, that does real-time DSP. 

The project I'm building will have four ADC channels. The ADC will read input data continuously, and the data is not meant to be saved, as the system does real-time processing only. 

Three of the ADC channels will read control-signals (potentiometers), meaning they do not require a high samplerate (ADC reading speed). I'm thinking 1kHz or more. Full ADC bit-depth (12-bit) is necessary. 

The last ADC channel is meant to read a input audio-stream. This channel will need to have a high samplerate (Im thinking 96kHz or higher). Full bit-depth is necessary.

The four input signals are connected to PC1, PC3, PC4 and PC5 of the chip, PC1 being the audio input. I was thinking I could use ADC1 or ADC2 for all four inputs, and multiplex between the different ADC channels using "Channel-wise programmable sampling time" (p. 212) to give PC1 a higher samplerate than the others. 

 

The project will have one PWM output. I'll be using Timer 8 (TIM8), assigned to PC7. The PWM output is meant to generate waveshapes. The PWM should be configured for a bit-depth of 12 or 16 and the samplerate of the PWM stream should be equal and in sync with the samplerate of the ADC channel connected to PC1. I would achieve this with one of the basic timers (TIM6 or TIM7 p. 463) or a interrupt routine (any suggestions on this?)

 

Hopefully this says something about the mode to which I should configure the ADC and PWM. 

Any and all response is greatly appreciated! 



#2 ziggurat29

ziggurat29

    Advanced Member

  • Members
  • PipPipPip
  • 244 posts

Posted 04 May 2013 - 04:21 PM

thats an exciting project; I'll have to do some reading to say much useful to your questions, but a couple things come to mind:

*  you know the Netduino 2 has an M3 core, and the Netduino Plus 2 has an M4.  You might like the M4 better, since you'll get the DSP instructions, and a floating point processor.  Maybe those will be useful depending on what kind of processing your effects will involve.

*  both of those chips have a DAC.  maybe that will be more handy than the PWM, which would would need to pass through an integrator to make it analog anyway.



#3 knutolai

knutolai

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 06 May 2013 - 01:11 PM

 

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]*  you know the Netduino 2 has an M3 core, and the Netduino Plus 2 has an M4.  You might like the M4 better, since you'll get the DSP instructions, and a floating point processor.  Maybe those will be useful depending on what kind of processing your effects will involve.[/color]

I'll have to look into that in the future! However the timeschedule for my project woun't let me sit around and wait for a Netduino Plus 2 board. 

 

 

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]*  both of those chips have a DAC.  maybe that will be more handy than the PWM, which would would need to pass through an integrator to make it analog anyway.[/color]

I'd really like to use the DAC however the pins where it can be accessed is not connected to the Netduino 2 boards shield pins (the blue junctions around the edge of the board). Honestly I think the PWM should work fine as long as I manage to set it up right. I've already built the analog circuit to accommodate the Netduino board with a integrator for the PWM-stream. I'll share the schematic if people are interested. It's not a perfect design however. 



#4 ziggurat29

ziggurat29

    Advanced Member

  • Members
  • PipPipPip
  • 244 posts

Posted 07 May 2013 - 12:06 AM

...timeschedule for my project woun't let me sit around and wait for a Netduino Plus 2 board....

Wow!  Pressure's on!  Well good luck; it's definitely an interesting project.

 

 

...I'd really like to use the DAC however the pins where it can be accessed is not connected to the Netduino 2 boards shield... 

OMG right you are.  Those pins are used for the ethernet on NP2, and they're NC on the N2.  Pity, because the DAC can be run from DMA (as can the ADC), leaving your processor free to...  Process!

 

 

... I'll share the schematic if people are interested. It's not a perfect design however...

few things in life are perfect but many are instructive.  it will be interesting to read all about the project -- even mundane things like setting up your toolchain will be helpful to someone, as well as the interface circuit design, and the software implementation.  so be sure to journal it as you go and blog it if you can!



#5 knutolai

knutolai

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 10 May 2013 - 12:43 AM

 

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]OMG right you are.  Those pins are used for the ethernet on NP2, and they're NC on the N2.  Pity, because the DAC can be run from DMA (as can the ADC), leaving your processor free to...  Process![/color]

Have you made any such applications? This is my first project and what I have to back me up codewise is a set of example codes showing different functionality. In the case of ADC input run from DMA. where and how do I read the input data? Im feeling rather incompetent :S

 

 

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]be sure to journal it as you go and blog it if you can![/color]

Hopefully the project will end as a rapport and demonstration. Ill try have a English version online sometime this summer I get stuff working. I'll be sure to post a link in this thread. 







Also tagged with one or more of these keywords: PWM, ADC, setup, c++, native code, input, output

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.