Above is an improved version of the circuit, which is now PWM compatible.
PWM, coast mode, and the capability to avoid shoot-through are provided by adding a fifth MOSFET (labeled Q5)
to the source/ground connections of Q1 and Q3.
- By default at power-up, the circuit is in coast mode.
- To brake, set IN A to 0 V, IN B to 0 V, and Q5 to 5 V.
- To spin clockwise, set IN A to 5 V, IN B to 0 V, and Q5 to 5 V.
- To spin counterclockwise, set IN A to 0 V, IN B to 5 V, and Q5 to 5 V.
- At any time you can return to coast by applying 0 V to Q5.
- Or, you can apply pulses of 0 V/5 V/0 V/5 V (and so on) to control the speed.
The more time spent at 5 V, the faster the motor will spin.
- Whenever you change modes, if you set Q5 to 0 V before making changes to IN A and IN B
(and then set Q5 back to 5 V or pulsing) there will be no shoot-through.
The downsides of this circuit are:
- Increased resistance as power has to travel through three MOSFETs (added Q5) instead of two.
- Increased cost of adding Q5.
In the schematic above, I made a couple of other changes from the original Figure 10-13 circuit:
- Switched IC1 from a 4427 to an IXDN404 for increased performance and higher voltage rating.
- Switched Q1 and Q3 from an IRLU024N to an IRFU3704 for higher voltage rating and lower resistance
(thus this circuit actually performs better than the original Figure 10-13, even with the added resistance of Q5).
Also, IRFU3704 turns on at a lower voltage, meaning it performs better than the IRLU024N when driven from a logic-level (5 V) output.
Additional notes:
- Because Q5 is driven from a logic chip or microcontroller, it won't be turned on and off as quickly
as it could if it were driven by an IXDN404 chip.
That's because logic chips and microcontrollers can't provide a lot of current.
So, the MOSFET gate will be in-between on and off for longer periods during gate charge/discharge with every pulse.
If you really want to PWM this circuit above a few kHz, I highly recommend driving Q5 via an IXDN404 chip instead.
- For a performance improvement, you can add Schottky diodes. See page 185.
- The above circuit is limited by the maximum gate-source voltage of the power MOSFETs.
In fact, 20 V is their absolute maximum.
As long as you use plenty of capacitors and the current load isn't extreme, this circuit should work towards that limit.
However, I've seen about 20% overshoot from the MOSFET drivers, so it would seem safer to derate to 16 V maximum.
- When pulsed, this circuit switches between coast and spin. Some people prefer to PWM between brake and spin.
To accomplish that, you'll need the full control that Figure 10-15 (page 188) offers.
To avoid shoot-through in that circuit, be sure to turn off MOSFETs before turning on MOSFETs when changing modes.
Chapter 13, pages 256 and 269
(corrected in second printing)
Thank you, Claus, for reporting to me that
I am missing pi (π=about 3.1416) in the diameter-based formula for calculating linear speed:
linear speed in cm/s = wheel diameter in cm x π x (RPM / 60 seconds in a minute)
linear speed in cm/s = 3 cm x π x (25 RPM / 60)
linear speed in cm/s = 3.927 cm/s
Which means page 269 should read:
The linear speed changes from 3.927 cm/s to the hectic pace of almost 11.8 cm/s. Okay, that's still pretty slow.
This mistake occurred because I usually use the circumference-based formula as presented
on page 340 of Robot Building For Beginners.
Nonetheless, this is one of those mistakes that makes me cringe!
I carefully proofread each chapter four or five times throughout various stages (multiple times in the word processor and then two passes of PDFs).
My technical editor does the same.
So, I don't know how we missed this elementary error. Oh, well.
Appendix: Page 421
(corrected in second printing)
The “Errata, updates, resources for this book” link should be
”http://www.robotroom.com/IRBGoodies.html” but somehow you
still managed to find your way here!
(The correct links appear elsewhere on that page and on page xxii.)
Source Files

Roundabout Parts List

Here's a list of parts and prices for the electronics for Roundabout,
along with example supplier(s) for most items.
This doesn't include the price of the robot's body, mechanical parts (motors), tools,
or experiments from the book.
Circular Body and Motor Mounting Template

Here's the body template and motor mounting hole layouts for Roundabout.
The file is in Microsoft Visio format.
Roundabout Printed Circuit Boards

Here are the printed circuit board layouts for Roundabout.
This allows you to order boards from a professional manufacturer.
You can save a lot of money by buying 1 of each board (RNDMPCB, RNDDPCB, RNDFPCB, for a total $36 plus shipping)
from Solarbotics.
Additionally, the boards at Solarbotics have silk-screened part numbers and part outlines, as well as a solder mask, making soldering easier.
Alternatively, you can etch and drill your own PCBs at home.
Roundabout Daughterboard Schematic

The daughterboard schematic is presented as modules in the book.
Here is the complete connected schematic of the daughterboard.
Note that IC1 and IC62 have slightly different pin descriptions from the book.
These changes allow the LEDs to be driven somewhat independently from the motors.
Roundabout Source Code

This link contains the complete MC68HC908KX8 assembly language source code for Roundabout.
The project was built using P&E Microsystems ics08kxz v1.17 free assembler.
(Open Roundabout.asm in the WIN IDE and click the assemble/compile button.)
If you have the KX8 programming board and a chip, you can FLASH the microcontroller yourself.
If you don't have a KX8 programming board, you can obtain the pre-programmed microcontroller (KX8)
from Solarbotics for $12 (plus shipping).
An added benefit is that each pre-programmed chip has already been
hand-tuned (by me) for its unique internal oscillator frequency.
Musical Notes - Pitch Lookup Table

Based on a base PWM frequency, this spreadsheet calculates the values to be stored
in the KX8 PWM register to generate a particular musical note.
The spreadsheet is arranged so that it can be copied and pasted into the source code.
Power Resistor Pulse Rating

In this spreadsheet, select a row and modify any yellow-highlighted values as desired.
Theoretically, the formulas will indicate if the power resistor can handle the
one-time peak pulse.
|