Skip to content

Arduino Wiring Notes

Ryan Fish edited this page Nov 17, 2016 · 7 revisions

Occupied Pins

The following pins are occupied on your robot's Arduino
0,1 - Serial communication
4 - Motor Driver Output Enable
5,6 - Encoder channel select pins
7,8 - Motor Driver Direction
9,10 - Motor Driver PWM
11,12,13 - SPI communication with Encoders
A0, A1 - Motor Current Feedback
12 - Motor Fault Signal (overlaps with SPI, a motor fault will likely knock encoders offline)

This means 2,3 and A2-5 are all fair game for GPIO. They should all be able to be used with the ServoTimer2 library to drive servos.

ServoTimer2 Library

The recommended servo library is https://github.com/mit212/ServoTimer2. The normal Arduino library conflicts with the motor driver shield, and will not work properly. This is due to both libraries needing to use one of the Arduino's timers, and both being hard-coded to use Timer1. ServoTimer2 however, as its name suggests, uses Timer2. It can handle up to 8 servos on generic pins (not just the PWM pins), and should function like a drop-in replacement for the ordinary Servo library.

Note that, just like using the Servo library tries to disable PWM ( analogWrite( ) ) on pins 9 and 10, using the ServoTimer2 library will disable PWM on pins 3 and 11.

##Servo Power Servos typically cannot run reliably at voltages above 7v. Unfortunately, this means that a 2S lipo is not suitable for direct connection to a servo. The servo may run for hours, it may run for days, but likely will not run for weeks, so using a voltage converter is highly recommended. Hobbyist have a nicely packaged converter, usually called a UBEC (Universal Battery Elimination Circuit), which is really just a small buck converter designed for mechanically active environments. Feel free to get any kind you wish, but I suggest this one https://www.amazon.com/dp/B01GHMW0C0/

The important parameters to consider are: Max input voltage (sometimes rated in the type of lipo battery you can plug into it) which for us needs to be >=26v or rated for a 6s lipo. Output voltage can be 5 or 6v, with 6v providing better performance. Output current should be a safety factor above the sum of all stall currents for all servos that will be connected.