Modular Music Box – Adafruit motor/stepper/servo control

I bought a small 3-4.5V DC motor to start testing for the rotary magnetic sequencer I’m planning as part of the Modular Music Box for the Analogue is the new Digital exhibition as part of AND Festival…

Todbot’s Bionic Arduino: Introduction to Microcontrollers with Arduino: Class 3 has a section on Controlling a Motor using a 1N4001 ‘kickback’ diode and TIP120 transistor to “control speed of motor with analogWrite() just like controlling brightness of LED” which I still need to try out.

Then there’s a fairly thorough post at Lucky Larry’s ARDUINO, MAINLY ARDUINO PROJECTS, TUTORIALS… AND A FEW OTHER THINGS blog – Control a DC motor with Arduino and L293D chip… but (sigh)… I think I’ll just buy a shield kit.
Most immediately useful and affordable via freeduino.org and Arduino: Playground: Interfacing with Hardware: Physical/Mechanical: Motor Control are the:

In the end I plumped for the Adafruit Motor Shield which seemed most full-featured and best value for money per number of motors/steppers/servos it can actually drive simultaneously:

  • 2 connections for 5V ‘hobby’ servos connected to the Arduino’s high-resolution dedicated timer – no jitter!
  • Up to 4 bi-directional DC motors with individual 8-bit speed selection (so, about 0.5% resolution)
  • Up to 2 stepper motors (unipolar or bipolar) with single coil, double coil, interleaved or micro-stepping.

Though I had a fairly cursory look over the specs and admit to a bit of a ‘suck it and see’ approach… Adafruit’s documentation, FAQs, make it guides and forums turned out to be thorough and a really useful resource…

It came as a kit which I managed to solder up easily enough… though I wish I’d incorporated at least some shield stacking headers instead of just the standard male headers so I can get access to those pins not used by the shield – all 6 analog input pins (can also be used as digital pins – #14 thru 19) and digital pins 2 and 13 (+ more if motors/steppers aren’t being driven). While my Screwshield makes these available for testing it does make it all a bit too bulky for the Modular Music Box so I reckon I’ll have a go at replacing some of the headers – which means I can try out my new ‘solder sucker’ tool too 😉

I installed the library and got the Solarbotics GM17 motor I’d bought working easily enough – and with 38mA unloaded current and 738mA stall current at 9V it’s well within the L293D chipset’s 0.6A per bridge (1.2A peak) 4.5V to 36V specs. Initially I powered both the Arduino and shield from a single 9V 300ma PSU… though subsequently from various power combinations including the shield from an external 9V 1100ma PSU and the Arduino from USB or a 4AA NiM-H battery pack… all with relative success…

And the GM17 behaves as expected – approx 45RPM at 9V – and down to about 12% speed (30 out of a 255 scale) before it failed to turn – though at this power it has very little torque… I’ve since discovered from the FAQs that the shield is meant for 6V+ motors – and the GM17 operates between 3-9V – so I’m not really surprised…

While the Solarbotics site also lists a useful looking Motor Bracket, Encoder – incorporating driver and 51:1 and 104:1 Rome Gears for the GM17 I now suspect it will not actually be the motor for the rotary sequencer though it may well do the job for the praxinoscope style animation.

And I hadn’t considered the amount of noise it makes – an issue Elliot Woods of Kimchi & Chips raised…

I’m now also wondering whether it’s going to be possible to deliver sufficient power to the motor(s) without using an external power supply – having conceived this project as modular but ‘self-contained’…

Next step is to fabricate a simple mount and develop the control code – perhaps using a hall effect sensor and a couple of magnets, the 12 step rotary encoder I bought and a couple of the seven-segment LED displays to display the RPM?

And test alternative DC and stepper motors from Fab Lab Manchester…

And look for alternatives online…

Posted January 2nd, 2011

Comments are closed.