This controller has built in, reverse polarity protection so that if you accidentally connect your battery or power supply the wrong way then the board will not be damaged. To make everything as easy as possible for beginners, a library of useful functions has been written for the controller.
A robot can be built by simply plugging in a few motors, servos and sensors. Using the Arduino IDE and supplied library, relatively little code is required to make a functional robot.
- Small PCB size (30mm x 60mm).
- Reverse polarity protection and built in power switch.
- Atmega168 or ATmega328 running at 3.3V, 8MHz.
- Built in miniature USB interface usingCP2102 interface IC.
- IR receiver provides 128 virtual buttons via universal TV remote.
- 3-axis accelerometer detects angle, impact and free fall.
- Dual 1A "H" bridge with electronic braking and stall detection.
- 8x servo outputs with selectable voltage.
- ISP and Serial communications headers.
- Indication LEDs for Power, TX, RX, D13 and IR signal detection.
- Arduino Pro (3.3V @ 8MHz) bootloader pre-installed.
The Micro Magician is fully compatible with the Arduino IDE.
The supplied MicroM library provides functions and sample code for the following:-
- Dual DC brushed motor: Speed, direction and braking.
- Single stepper motor: Full step, half step, direction, low power.
- 3-axis accelerometer: Impact detection, direction and magnitude - eliminates the need for bumper switches.
- SONY IR decoder (SIRC): Provides up to 128 virtual buttons using SONY compatible IR remote controls.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Power
The use of 4x NiMh rechargeable batteries is recommended as this combination will power 5V sensors if required and can supply high currents for servos and motors.
The Micro magician can be powered directly from the USB cable for programming and testing however servos and motors will not be powered from the USB cable.
There is a 4 pin male header that is your power IN and a 4 pin female header that is your power OUT for external circuits. The input pins from top to bottom are:
- GND (battery -V)
- VIN (battery +V)
The power OUT header pins from left to right are:
- GND (battery -V)
- GND (battery -V)
- VCC (3.3V regulated)
- VIN (battery +V)
Step 2: Dual 1A Motor Driver
Most small robots move about using two DC brushed motors. The processors output pins cannot supply enough power to drive motors directly so the Micro Magician has a small motor driver IC to control the motors. Despite it's small size this motor control IC is very efficient and can deliver up to 1.2A to each motor.
The Micro Magician has been designed to limit the maximum motor current to about 910mA to ensure that beginners cannot damage the board by accidentally shorting the motor outputs or connecting a motor that is too big for this controller.
When a motor does draw too much current (for example, the robot becomes stuck and cannot move) an output pin called a "stall flag" will go from high to low to indicate that motor has stalled. If you wish to use these stall flags then you must use jumper wires to connect them to the inputs of your choice.
This motor controller can also drive a single small stepper motor. There are many different types of stepper motors. With different numbers of wires. The simplest is a bi-polar stepper motor and has 2 windings or coils with 4 wires. These motors are connected with one winding connected to each motor output.
If your project does not require DC motors then putting a jumper on the "sleep" pins will disable the motor driver IC. The motor drivers control pins (D5,D6,D7,D8) can then be used for other purposes. Pins D5 and D6 are capable of PWM output.
It should be noted that the motor outputs can be used to drive other devices besides motors. For example, high intensity LEDs, Bi-coloured LEDs and small relays can all be driven from the motor outputs.
Step 3: 3-axis Accelerometer
The accelerometer is a really cool sensor that can do a lot of things. It's most basic function is to tell the processor which way is up. This allows a mobile robot to tell if it is going to fall over or if it has fallen over then it can help the robot get up again. The MicroM library uses this sensor to detect impact direction and magnitude eliminating the need for bumper switches.
This sensor provides 3 analog outputs (X, Y, Z axis) which are read by analog inputs A0,A1 and A2 of the processor. It also has a digital input (G select) and a digital output (0G detect). These digital pins are not connected to the processor. They are optionally accessed using jumper wires.
G select is set by default to a sensitivity of +/- 1.5G. By pulling this input high you can change the accelerometer sensitivity to +/- 6G which could be useful for high speed projects.
0Gdetect is normally output low. If your robot falls (off the edge of a table for example) then the output will go high. By using a jumper wire to connect this pin to an external interrupt (D2 or D3) your robot can cut power to motors and servos (effectively "going limp") in an attempt to reduce the strain on the gears when the robot hits the floor.
Step 4: Servos
The Micro Magician can drive up to 8 miniature servos directly. This is ideal for small Quadruped robots. Larger servos can be used but the maximum current drawn by the servos should not exceed 3A otherwise the reverse polarity protection diode could be permanently damaged.
When driving servos directly from the controller, the V+ select jumper should be changed from 3.3V to VB. This will allow the servos to be powered by battery voltage rather than the 3.3V regulator. Make sure your battery voltage is suitable.
If you are using a 7.4V LiPo battery then replace the jumper with two 3A diodes connected in series. This will drop the battery voltage by about 1.3V so as not to damage the servos which usually have a 6V rating.
Note that D1 is also the processors TX pin used in serial communications, program uploads and serial monitor debugging. You can still use it for a servo but the servo connected to this pin will jitter uncontrollably during serial communications. My QuadBot gets a nervous tick when I upload new code. Once the program uploads then everything is fine.
Step 5: Infrared Receiver
The IR receiver is commonly found in TV's and DVD players. It allows our controller to receive commands from any IR remote that uses the Sony IRCode (SIRC). Aside from receiving commands via remote, the sensor can also be used for robot navigation and communication.
This receiver is hardwired to D4 and has an indication LED behind it that can be very useful for debugging. The LED is hardwired to the receiver and will flash when the receiver is detecting a 38KHz carrier wave. This will help you determine if there is a fault in your code or just flat batteries in the remote.
The MicroM library includes a decoding function (and sample code) that reads the pulse widths of a Sony IR Command to give you a value from 0-127. Although the function defaults to the receiver on D4, you can add additional receivers on other I/O pins and read them as well.
Warning! D4 should never be changed to a digital output as this can permanently damage the IR receiver.
Step 6: Serial Communications Header
The serial communications header allows your project to communicate via Xbee module or BlueTooth. If you are using this header then make sure you do not have a servo attached to D1 otherwise it will twitch uncontrollably during communications.
As the RX and TX lines are shared by the USB interface you may need to disconnect devices from the header during program uploads.
Warning! Only uses 3.3V devices with this header otherwise the processor may be damaged.
Step 7: Digital I/O Pins
The Micro Magician has all digital I/O pins except D4 terminated in both a male and female header pin for easier interfacing. Digital pins D1, D2, D3, D9, D10, D11, D12 and D13 also have V+ and Gnd pins. Unless you are using servos it is recommended to leave the V+ select jumper on 3.3V. If a higher voltage is applied to a digital I/O pin then the processor will be permanently damaged.
D0, D1 are used for Serial communications including program uploads so be careful how you use them. You may need to disconnect devices attached to D0 before you can upload a new program. D5, D6, D7 and D8 are normally used for the motor driver IC. Set the motor driver IC to sleep mode in order to use these pins.
D3, D5, D6, D9, D10 and D11 are capable of PWM outputs.
D2 and D3 are external interrupt pins.
Interfacing to 5V:
3.3V digital outputs are high enough for 5V devices to read them. 5V digital outputs can be divided down to 3.3V signals using a simple voltage divider.
The supplied instruction manual provides sample schematics for interfacing to 5V sensors. If in doubt, put a 4K7 resistor in series with the I/O pin to limit fault current through the processors internal protection diodes.
Step 8: Analog Inputs
The Micro Magician analog inputs A0,A1,A2 are used internally by the accelerometer. A3, A4, A5, A6 and A7 are all terminated in both a male and female header pin as well as 3.3V and Gnd male header pins. This allows 3.3V devices to plug in directly.
A4 and A5 are also used as the I²C interface pins with A4 being SDA and A5 being SCL. The original Arduino Wire library does not work with an 8MHz clock but there is now a new I2C library that does as well as offering more options such as fast mode and repeated start conditions for better compatibility with I2C devices.
All analog pins can be used as digital I/O pins. A0-A7 are digital pins D14-D21.
Warning! A0, A1 and A2 should never be changed to digital outputs as this could damage the accelerometer permanently.
Interfacing to 5V devices:
The analog inputs should never be connected to voltages higher than 3.3V. A 5V analog output should be fed through a suitable voltage divider to limit it to 3.3V or less. The supplied instruction manual provides sample schematics for interfacing to 5V sensors.
Step 9: The MicroM Library
The Micro Magician comes with the MicroM library to help simplify some of the more complex function. Sample code is included with the library to show how these functions work.
The library creates several global variables that allow the user to modify the behavior of a function. For example, the variable microM.irpin is used to specify which digital pin to read the IR receiver from. Changing this value allows additional receivers to be read from other digital inputs.
In order for the IR receiver or impact detection functions to work an interrupt on Timer 2 must be initialized first using the microM.Setup() function.
At the time this article was written (July 2012) the library was compatible with the Arduino IDE versions 0018 through to V1.0. The latest version of the library and manual can be downloaded from my product support site: https://sites.google.com/site/daguproducts/