# Yet another "help me pick a microcontroller"-thread

#### johan

Joined Oct 25, 2008
12
I am a guitar player who has recently started doing DIY stuff and now that I've built a few basic effect pedals, I want to do something bigger.

My new project is going to be a tremolo pedal which is basically an effect that makes the volume go up and down in time with an LFO. I've seen a few 555 oscillators for this purpose but they don't look that attractive to me (sine wave requires a million parts for example) so when I got introduced to the world of microcontrollers, they really caught my interest.

However, I know nothing about the different families. I can't tell you what makes AVRs different from PICs or what advantage PSoCs has over ARMs. I had a quick look at sparkfun electronics and the specs don't tell me anything.

So I hope that you guys can help.

I want the following:

• Something that can be programmed in C
• Something with free software tools and cheap hardware tools available. I'm a hobbyist so I don't want to spend more than $50 on a programmer. Hardware-wise, my needs are as follows • 3 or 4 analog inputs for potentiometers • 2 or 3 analog outputs for the LFO as well as output of the LFO to a two-color LED (as high resolution as possible) • 3 binary inputs for buttons • 3 binary outputs for an RGB LED and 1 for a relay (maybe I have to run the relay with a transistor?) • 2 analog outputs • Something to keep track of the time (as accurately as possible) • I don't know what speed I need but something that can run at maybe at least 10mhz with an external crystal would be great • Some sort of flash memory or similar that I can use to save and load user data I don't mind doing my own research but I'd appreciate if maybe you could tell me what family of microcontrollers I should take a look at because right know I'm completely lost. *edit* I also forgot to say that interrupts would be really useful since that would save some CPU cycles which would be a good way to give the LFO higher resolution. #### mik3 Joined Feb 4, 2008 4,843 If you want a free software tools you have to search for AVR's because ATMEL gives the software for free while Microchip (PIC's) does not. Unless you know how to hack them, choose AVR to get free software from the internt. Visit www.atmel.com to see the various microcontrollers they have. If you want take a look at microchip too www.microchip.com If you want a cheap programmer search for one in ebay but take care that it is capable of programming the microcontrollers you will buy. #### hgmjr Joined Jan 28, 2005 9,029 Here is a programmer for the ATMEL AVR family. Digikey has this programmer for under$40. It plugs into a USB on a PC. It uses the free AVRSTUDIO4 software that you can download from www.atmel.com. You will need to download the free WINAVR software plug-in to program in C-Language.

The programmer can be used with over 90 different AVR microcontrollers.

hgmjr

#### steveb

Joined Jul 3, 2008
2,436
I like the Texas Instruments MSP430 series. Very low power for battery applications. Low cost parts and everything built on one tiny chip (power monitoring, memory flash etc). You can have multiple clocks. RISC based and >10MHz for processing power, and watch crystal for ultra low power draw. Free software, if you can live with some memory size restrictions. Hardware multiplier built in. The programmer may be about $100. #### atferrari Joined Jan 6, 2004 4,069 Pickit2 IS cheap, well below 50 USD. Thread Starter #### johan Joined Oct 25, 2008 12 Thank you. So it seems like etiher of those families would work for my needs. Which family has got the best PWM? (as in best resolution and frequency) What do you think of the arduino? I am not interested in their pre-made boards but there are ATmega168 (and maybe soon 328) chips available with the arduino bootloader. The arduino programming language does look great and the documentation is huge. Also, do all of these families have EEPROM? #### hgmjr Joined Jan 28, 2005 9,029 I can only speak from firsthand experience with ATMEL AVR devices. Their PWM can be based off their 16-bit timer port. I think you will find that whatever you chose, PIC or AVR, you will open up a whole new world of design ideas once you familiarize yourself with microcontrollers. Oh yeah, the AVR family of devices all have EEPROM memory inside. I think that is also true of PICs. hgmjr #### John Luciani Joined Apr 3, 2007 477 Some of your specifications are vague so it is difficult to recommend a uC. You want the analog outputs as "high resolution as possible". You will not get the highest resoltuion analog outputs on a uC. What resolution and accuracy do you need? If you want a resolution greater than 10 or 12 bits you will probably need an external DAC (Analog Devices, Maxim, etc). How accurately do you need to track time? Since this sounds like a music application I would be surprised if most uCs wouldn't meet your needs. Since the analog inputs are for POTs the ADCs in most uCs should be fine. You should use a transistor for the relay. I would take a look at Atmel chips and plan on using an external DAC (SPI port). The ATmega168 in a DIP package (apx$3 IC) may work depending
on how much computing power you need. In a typical ATmega168 system that
has a XTAL, reset button, serial I/O you end up with the following
resources

* SPI port (or three digital I/O lines)
* nine digital I/O lines

You can program in GCC. You can also use the Arduino tools as a
front-end to GCC. The software tools are free.

Information about my ATmega168 boards is at http://tinyurl.com/5lnhtj
Pictures of my MSP430 boards are at http://tinyurl.com/6jm8tu

(* jcl *)

#### johan

Joined Oct 25, 2008
12
Wow, you guys know a lot! I recently asked the same question at a general DIY forum and no one knew anything. I'm glad i found this page.

I can only speak from firsthand experience with ATMEL AVR devices. Their PWM can be based off their 16-bit timer port.

I think you will find that whatever you chose, PIC or AVR, you will open up a whole new world of design ideas once you familiarize yourself with microcontrollers.

Oh yeah, the AVR family of devices all have EEPROM memory inside. I think that is also true of PICs.

hgmjr
Great. I think I'm slowly starting to "prefer" AVRs. I like the fact that you can use the Arduino bootloader, the documentation for Arduino is great so it could help getting me started.

I agree that the possibilities seem endless. I started doing a schematic in Eagle today and I'm amazed by how simple it is hardware-wise to do stuff that would either require a million parts or be impossible if you tried to do it all-analog. Being able to tap in a tempo for the LFO with a footswitch for example, that just requires a resistor, a button and some use of the built in timer.

I also like the fact that you can still have an analog signal path. My signal will never be converted to digital and then back to analog, it'll be analog all the way.

Some of your specifications are vague so it is difficult to recommend
a uC. You want the analog outputs as "high resolution as possible".
You will not get the highest resoltuion analog outputs on a uC. What
resolution and accuracy do you need? If you want a resolution greater
than 10 or 12 bits you will probably need an external DAC (Analog
Devices, Maxim, etc).

How accurately do you need to track time? Since this sounds like a music
application I would be surprised if most uCs wouldn't meet your needs.

You should use a transistor for the relay.

I would take a look at Atmel chips and plan on using an external DAC (SPI
port). The ATmega168 in a DIP package (apx \$3 IC) may work depending
on how much computing power you need. In a typical ATmega168 system that
has a XTAL, reset button, serial I/O you end up with the following
resources

* SPI port (or three digital I/O lines)
* nine digital I/O lines

You can program in GCC. You can also use the Arduino tools as a
front-end to GCC. The software tools are free.

Information about my ATmega168 boards is at http://tinyurl.com/5lnhtj
Pictures of my MSP430 boards are at http://tinyurl.com/6jm8tu

(* jcl *)
I don't know what resolution I need since I haven't done this before. I'm sure 10- or 12-bit is perfectly fine though.

Basically I want to be able to produce smooth sounding sine waves in low frequencies but I'm sure the stuff in regular microcontrollers will work just fine. If not then I'm sure I can update later. This is not high-quality studio equipment either so I don't need anything extreme.

How accurately can your average microcontroller keep track of the time? I've seen in the arduino documentation that you can read milliseconds accurately and you can also delay things in microseconds and that sounds perfectly fine to me.

The ATmega168 seems like a great board. I think that is what I'll end up with, or the 328 if it's in stock anywhere. I've started doing a schematic in Eagle and I'm not running out of pins anytime soon. I've also seen some smart ways of running multiple things from the same pin so I think I'll manage.

Thanks a lot to all of you, I think AVR is the way to go.

#### hgmjr

Joined Jan 28, 2005
9,029

Atmel website has an application note that gives you all the details on how to add the programming header into your design. I recommmend you look at that app-note closely.

hgmjr

#### John Luciani

Joined Apr 3, 2007
477
The ATmega168 seems like a great board. I think that is what I'll end up with, or the 328 if it's in stock anywhere. I've started doing a schematic in Eagle and I'm not running out of pins anytime soon. I've also seen some smart ways of running multiple things from the same pin so I think I'll manage.

Thanks a lot to all of you, I think AVR is the way to go.
The DIP ATmega328 is pin compatible with the ATmega168. Production of the 328
just started. First shipments of REV C parts is suppose to start in December.
REV B parts have an instability in the 32KHz oscillator. If you find parts online they
are probably REV B samples. I would use the ATmega168 in your design now and
change to the 328 when the parts start shipping. The 168 is only a few dollars.

(* jcl *)

#### johan

Joined Oct 25, 2008
12
My requirements have changed slightly so I just need to check, can the analog pins on the ATmega also be used as digital pins?

#### hgmjr

Joined Jan 28, 2005
9,029
My requirements have changed slightly so I just need to check, can the analog pins on the ATmega also be used as digital pins?
Absolutely, they can be used as digital IO.

hgmjr

#### johan

Joined Oct 25, 2008
12
I have decided to go with the ATmega32 instead as I need more pins. Does anyone know which pins are PWM pins? I've had a look in the datasheet and I haven't been able to find that information.

#### hgmjr

Joined Jan 28, 2005
9,029
I have decided to go with the ATmega32 instead as I need more pins. Does anyone know which pins are PWM pins? I've had a look in the datasheet and I haven't been able to find that information.
The PWM signals out of the ATMEGA32A as follows:

Timer0 based PWM signal is output on OC0.
Timer1 based PWM signals are output on OC1A and/or OC1B pins.
Timer2 based PWM signal is output on OC2.

hgmjr

#### johan

Joined Oct 25, 2008
12
Thank you.

#### avinash_g

Joined Nov 4, 2008
7
Hi,

I recommend you see my tutorial series of AVR. As you are a beginner they will help you a lot!

http://extremeelectronics.co.in/category/avr-tutorials/

All the software are free!

I have given step by step guide to set up every thing.
You can easily make a serial port based programmer (if your PC has a serial Port, if u have a laptop then forget it)

Hope this helps.