B-48/B-168: PWM, debugWire support etc


I have a few thoughts about B-x8 boards which I want to share:

  1. According to the B-x8 controller schematic PWM pins of the motor driver connected to Vcc. I am wondering why do not we have an option to connect these pins to OCn pins of the AVR? PWM in AVR hardware is pretty convenient.

  2. It would be nice to have pin AIN1 connected to the same port of the AVR as AIN2, BIN1 and BIN2 in order to allow to set motors in “one go”.

  3. Soldering jumper which would allow to disconnect C6 might be helpful in connecting a debugger (debugWire).


Hello, Misha.

Thank you for your suggestions. The reason why the PWM pins on the motor driver are connected to VCC is because the AVR’s hardware PWMs are connected directly to the direction inputs on the driver. This allows you to do hardware PWM control of the motor driver with only two pins per channel rather than three. For more information on how to use hardware PWMs for motor control, take a look at our application note on controlling motors with the Baby Orangutan B.

Additionally, the OrangutanMotors library provides some functions for using hardware PWMs on the Baby Orangutan B to control motors.

The consequence of using the hardware PWM outputs of the two eight-bit timers (timers 0 and 2) as the direction inputs for both motor driver channels was that they could not all be on the same port. We feel the benfits of being able to use hardware PWMs for these inputs, however, outweighs the benefits of being able to set all of the direction pins in a single atomic operation (as do the benefits of being able to control two motors with four I/O lines instead of six).

Unfortunately, the Baby Orangutans are pretty much as compact as possible, leaving no space for a jumper connection to C6. This capacitor serves to smooth out any noise on the Vcc line that might unintentionally reset the Baby Orangutan, but it is an optional component that is definitely not required for operation. If you want to use debugWire, I recommend you either desolder the capacitor or cut the trace.

- Ben

Hi Ben,

Somehow I missed the Application Notes page mentioned in your post. Thanks for the link!

Well, in case of the same PWM frequency we have “two pins” against “one timer”. What is more preferable obviously depends on an application.

I probably was not clear with type of jumper I had in mind. I think about something like two small closely located pads on the board.

One more thing… I guess, there was a good reason to choose 20MHz crystal over 18.432MHz which is more “communication friendly”. :wink:



What do you mean by “communication friendly”? If you’re talking about asynchronous serial baud rates, you can get close enough to the standard ones with 20 MHz, and 20 MHz makes the calculations for other timing easier. Also, 20 MHz is almost 10% faster than the speed you suggest, and that speed can be handy.

- Jan

Hi Jan,

AVR provides “power of 2” based prescalers which allows, as you mentioned,
get close but not exact USART speeds. For example, 230400 bauds might be
problematic with 20MHz crystal:


We haven’t gone past 115.2 kbps. What are you doing that needs the fast data transfer?

- Jan


I have USART connected to a Bluetooth adapter with serial interface. Serial transfer time adds to inevitable Bluetooth latency.