Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Mr. Ninja on May 16, 2012, 03:15:44 PM

Title: Microcontrollers
Post by: Mr. Ninja on May 16, 2012, 03:15:44 PM
     Hi, I'm trying to get into robotics, I want to build a four-legged robot that follows light, and auto adjusts for balancing the middle part (the board). I know mostly what to buy, but the micro controller I would need would have to have 21 (at least) output ports (I can't think of what they are called right now), and at least 14 input ports. The controller would be preferably in C++ or C (for the options I could use it for).

     Thanks,

      Mr. Ninja
Title: Re: Microcontrollers
Post by: Daanii on May 17, 2012, 02:42:44 PM
How about an Arduino Mega?

"The Arduino Mega is a microcontroller board based on the ATmega1280. It has 54 digital input/output pins (of which 14 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started."

UPDATE: I forgot to say that the Arduino has its own development environment that lets you program in C++. Also, if you want a similar but smaller version that lets you solder in all wiring rather than use headers, you can get a Teensy++ (although I see it only has 8 analog inputs, not 16).
Title: Re: Microcontrollers
Post by: Mr. Ninja on May 17, 2012, 03:16:28 PM
Thanks, for some reason I thought the Uno was the biggest... (I guess we all have those moments :P).

Exactly what is an oscillator? I've seen it mentioned in places, but don't know what it is.

Also, do you know any good C++ tutorials?
Title: Re: Microcontrollers
Post by: Daanii on May 17, 2012, 04:07:46 PM
Thanks, for some reason I thought the Uno was the biggest... (I guess we all have those moments :P).
Few people need something as big as a Mega, so we hear about it less. Projects like yours are quite ambitious.

Quote
Exactly what is an oscillator? I've seen it mentioned in places, but don't know what it is.
The oscillator is a crystal that gives the microcontroller its clock, or heartbeat. Typically, people use a 16 MHz crystal with the Arduino. If you want to use less power, you can drop that to 8 MHz. Then the microcontroller runs twice as slow.

Crystals cannot be put on the integrated circuit itself. I believe the Mega has an internal clock, but it is not based on a crystal and is not that accurate. That is, the clock speed will vary somewhat due to changing voltage and temperature. To be more accurate, most people want an external crystal for the clock.

Quote
Also, do you know any good C++ tutorials?
Unfortunately, I don't know any good C++ tutorials. However, if you are just starting out with the Arduino, a tutorial from Earthshine does a good job of leading you through both the electronics and the software for using the Arduino. www.earthshineelectronics.com/files/ASKManualRev5.pdf (http://www.earthshineelectronics.com/files/ASKManualRev5.pdf)

A tutorial like that will probably teach you most of the C/C++ that you will need. Most code for the Arduino is very simple in that it uses only the most basic parts of the language.
Title: Re: Microcontrollers
Post by: corrado33 on May 17, 2012, 07:37:13 PM

Crystals cannot be put on the integrated circuit itself. I believe the Mega has an internal clock, but it is not based on a crystal and is not that accurate. That is, the clock speed will vary somewhat due to changing voltage and temperature. To be more accurate, most people want an external crystal for the clock.

Quote

That's not exactly true.  You CAN use a crystal with the microcontroller used on that arduino, however, without looking at the arduino itself I can't tell you if you could or couldn't put on on.  If the pins used for external crystals are being used as an I/O port, you could technically hook up a crystal (although with the amount of PCB trace between it and the MCU it'd be very susceptible to noise.) 

Just some food for thought.  If you simply needs lots of simple I/O ports, you might want to look into multiplexers.  That way you can use a much smaller MCU. 

Gah, I keep forgetting you're referring to the arduino as the microcontroller, and not the microcontroller itself.  I guess a multiplexer would be a bit hard to hook up unless you made a PCB yourself. 
Title: Re: Microcontrollers
Post by: billhowl on May 17, 2012, 09:03:37 PM
Have a look on this, it use TLC5940 a 16 channel PWM unit to fan out to 16 output.
(http://www.instructables.com/files/orig/FYC/MK5T/H19RUXWA/FYCMK5TH19RUXWA.png) (http://www.instructables.com/image/FYCMK5TH19RUXWA)
If you need more PWM/Servo connections, you can chain the TLC5940s together.
Just connect another board’s input pins to the output pins of the first and you are good to go.
http://www.instructables.com/id/Arduino-Based-Four-Legged-Robot/step4/Schematic/ (http://www.instructables.com/id/Arduino-Based-Four-Legged-Robot/step4/Schematic/)
http://arduino.cc/playground/Learning/TLC5940 (http://arduino.cc/playground/Learning/TLC5940)
https://sites.google.com/site/artcfox/demystifying-the-tlc5940 (https://sites.google.com/site/artcfox/demystifying-the-tlc5940)
http://bildr.org/2012/03/servos-tlc5940-arduino/ (http://bildr.org/2012/03/servos-tlc5940-arduino/)
Title: Re: Microcontrollers
Post by: Mr. Ninja on May 21, 2012, 07:25:55 PM
Thanks for all the input. I think I will be sticking with the Mega (due to money, and I don't know want to experiment with PCB etching). And could anyone reccomend an accelerometre?
Title: Re: Microcontrollers
Post by: billhowl on May 22, 2012, 07:23:22 AM
You can get the MMA7361L XYZ-Triple-axis accelerometer sensitivity (±1.5 g or ±6 g) with or without Voltage Regulator
http://www.pololu.com/catalog/category/80 (http://www.pololu.com/catalog/category/80)
http://www.sparkfun.com/products/9652 (http://www.sparkfun.com/products/9652)
Accelerometer and Gyro Buying Guide (http://www.sparkfun.com/tutorials/167)
Title: Re: Microcontrollers
Post by: Wesley888 on May 23, 2012, 12:15:30 PM
Also, do you know any good C++ tutorials?

The Arduino site also have a tutorial page as well.  You can just copy and paste and learn how it works.  Lot of good examples there.

http://arduino.cc/en/Tutorial/HomePage (http://arduino.cc/en/Tutorial/HomePage)
Title: Re: Microcontrollers
Post by: Mr. Ninja on May 31, 2012, 11:13:07 AM
Thanks everybody. Now to get building, designing, and planning!

(This topic shall be considered dead!)