After discounting the transistor based H-Bridges in the original car, I started experimenting with the TB6612FNG module. Despite its small size, it should be able to easily to take the few hundred mA needed for the motors.
My first experiments with this were not successful, every time I hooked up the motor supply connector the current shot up and the supply voltage collapsed causing the Edison to reset. After a few hours of double checking all the wiring and general frustration, I swapped to using LEDs to determine if my code or wiring was at fault. This worked fine with the direction LEDs turning on and off, and the PWM one fading on and off. I did get caught out by the fact that not all pins support PWM but you can swap those with the "swizzler", a set of header connectors that I've not quite worked out yet.
var mraa = require('mraa'); console.log('MRAA Version: ' + mraa.getVersion()); var pwm = new mraa.Pwm(6); //PWM available on default swizzler positions. (3,5,6,9) var forwards = new mraa.Gpio(7); var backwards = new mraa.Gpio(8); forwards.dir(mraa.DIR_OUT); backwards.dir(mraa.DIR_OUT); var dir = true; var value = 0.0; var step = 0.01; pwm.period_us(700); pwm.enable(true); toggleDirection(); setInterval(function () { value = value + step; if (value <= 0 || value >= 1) { if (step <= 0) { toggleDirection(); } step = -step; } pwm.write(value); } , 50); function toggleDirection() { forwards.write(dir?1:0); backwards.write(dir?0:1); dir = !dir; } process.on('SIGINT', function () { console.log("Shutting down SIGINT (Ctrl-C)"); pwm.write(0); forwards.write(0); backwards.write(0); process.exit(); });
After success with the LEDs, I tried a second H-Bridge module (from a different supplier). That did not have the same issue so I concluded the problem was with the first board which is now discarded.
Power supply
Given the motors are the main power drain being about 300mA each, I was looking for a supply that could supply about 1A, was light, easily recharged, had capacity for a few hours play and was in around the 5v - 9v range. Despite having a range of different battery boxes and rechargable batteries I did not have anything that met those requirements. I also had a small 6v lead-acid battery but that was very heavy. Finally, I looked at buying some RC car batteries but these were very expensive and I'd need a charger too.
Then I realised that I did have a phone "power bank" that I'd won in a prize draw the previous year.
Capacity: 4000 mAh Output: 1A Input/Output Voltage: 5V Battery Type: Rechargeable Li-Ion Charging time (to charge power bank): Up to 4 hours Standby Time: Up to 4 months |
That should be perfect, so I doctored a USB cable so I could attach it to my breadboard. Unfortunately my cables were not coloured coded as per "standard" but I worked it out with a multimeter. The battery box happily powered my test LED and also the motors.
Reference
Power Consumption for Intel Edison Board for Arduino*
Previous Posts
[Upcycle It] Interactive Race Car Driver - Plan of action
[Upcycle It] Interactive Race Car Driver - Software
[Upcycle It] Interactive Race Car Driver - Lights
[Upcycle It] Interactive Race Car Driver - Detailed Plan
[Upcycle It] Interactive Race Car Driver - Edison
[Upcycle It] Interactive Race Car Driver - Drive Motor Testing
Top Comments