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.
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
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
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
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
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
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
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
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 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/