Software Overview  |  Sitemap  |  Downloads  |  Developers  |  Forums
Small_clear_logo_llc

Adafruit Devices on Arduinos

Here we describe the Adafruit devices we support. There are many devices on the Adafruit website (switches, relays, LEDs) which require only the standard pin configurations. To learn more about Adafruit and their devices, see http://www.adafruit.com. If you are interested in using an Adafruit device which is not in this list, you may be able to support it using standard pin configurations.

The Adafruit devices we support explicitly are:

Motor/Stepper/Servo Shield V2
PWM/Servo Shield

Both these shields are useful for robotics projects. The Motor Shield can control a robot's drive unit, and the Servo Shield can position the robot arms, head, cameras, etc.

The Adafruit Scripts are in the Arduino/Devices Scripts directory in the Adafruit subdirectory.

The Motor/Stepper/Servo Shield V2

Adafruit Motor/Stepper/Servo Shield V2
motor shield

The Adafruit Motor/Stepper/Servo Shield is a small board which plugs onto an Arduino (an Arduino shield). The shield controls up to 4 motors and an additional 4 individual pulse width modulators (PWMs). The 4 sets of motor controller outputs can drive high currents. Each set of motor controller outputs is controlled by 3 dedicated PWMs. One of the 3 controls the motor speed, and the other 2 control motor direction (see the Adafruit specification for details).

Note: the Adafruit design supports both standard electric motors as well as stepper motors. Our Motor Shield Script supports standard electric motors, but not stepper motors.

The Motor Shield uses the Arduino's I2C bus for configuration and control. The bus lets you set the overall PWM frequency for all the PWMs as well as the duty cycle of individual PWMs.

Configuring the Shield

To configure the Adafruit Motor Shield, run the MotorShieldV2 Script in the Adafruit subdirectory. The Script adds 16 input terminals to your Arduino Device. 12 of the terminals are for controlling 4 motors, and the remaining 4 control 4 dedicated PWMS. Each of the inputs takes a duty cycle value from 0-100, or the values "on" or "off" ("on" is the same as a duty cycle value of 100, and "off" is the same as a duty cycle value of 0).

Each motor is controlled by a set of 3 motor terminals: the "pwm", "in1", and "in2" terminals. The "pwm" terminal is used to set the pwm value for a motor (the speed), and the "in1" and "in2" set the motor's direction ( in1, in2 = on, off would spin a motor in one direction, and in1, in2 = off, on would spin the motor in the other direction). All of the terminal names are user definable.

The MotorShieldV2 Script takes the following parameters:

  • arduino_id : the ID of the Arduino which is connected to the Motor Shield. This is the same as the ID supplied by the "id" parameter when adding an Arduino to the system.
  • i2c_address : the I2C address of the motor shield (default is 0x60)
  • pwm_frequency : the PWM frequency of all the PWM outputs. The maximum value is 1600. Setting the frequency to a lower value will lower the PWM frequency of all the PWMs.
  • m1_pwm_name : the name for motor 1's pwm input terminal
  • m1_in1_name : the name for motor 1's in1 input terminal
  • m1_in2_name : the name for motor 1's in2 input terminal
  • m2_pwm_name : the name for motor 2's pwm input terminal
  • m2_in1_name : the name for motor 2's in1 input terminal
  • m2_in2_name : the name for motor 2's in2 input terminal
  • m3_pwm_name : the name for motor 3's pwm input terminal
  • m3_in1_name : the name for motor 3's in1 input terminal
  • m3_in2_name : the name for motor 3's in2 input terminal
  • m4_pwm_name : the name for motor 4's pwm input terminal
  • m4_in1_name : the name for motor 4's in1 input terminal
  • m4_in2_name : the name for motor 4's in2 input terminal
  • pwm0_name : the name for the first dedicated PWM (board PWM 0)
  • pwm1_name : the name for the 2nd dedicated PWM (board PWM 1)
  • pwm14_name : the name for the 3rd dedicated PWM (board PWM 14)
  • pwm15_name : the name for the 4th dedicated PWM (board PWM 15)

If you want to leave a terminal off of your Arduino, define its name as the empty string ("").

Here's an example using the PWMServoShield Script. It adds a Motor Shield with motors connected to the shield's 1 and 2 motor outputs. It's running at 1600Hz and is plugged into an Arduino with ID "arduino". Motor 1's terminals are named "m1_pwm", "m1_in1" and "m1_in2"; motor 2's terminals are named "m2_pwm", "m2_in1" and "m2_in2".

arduino_id: "arduino"
i2c_address: 0x60
pwm_frequency: 1600
m1_pwm_name: "m1_pwm"
m1_in1_name: "m1_in1"
m1_in2_name: "m1_in2"
m2_pwm_name: "m2_pwm"
m2_in1_name: "m2_in1"
m2_in2_name: "m2_in2"
m3_pwm_name: ""
m3_in1_name: ""
m3_in2_name: ""
m4_pwm_name: ""
m4_in1_name: ""
m4_in2_name: ""
pwm0_name: ""
pwm1_name: ""
pwm14_name: ""
pwm15_name: ""

The PWM/Servo Shield

Adafruit PWM/Servo Shield
PWM & Servo Shield

The Adafruit PWM/Servo Shield is a small board which plugs onto an Arduino (an Arduino shield). The shield has 16 pulse width modulators (PWMs) for controlling up to 16 servos. The board comes with 16 servo-compatible headers. The 16 PWMs are numbered from 0-15 (see the Adafruit specification for details).

The PWM/Servo Shield uses the Arduino's I2C bus for configuration and control. The bus lets you set the overall PWM frequency for all the PWMs as well as the duty cycle of individual PWMs.

Note: if you use this board to control servos, you should know that servos operate over a constrained duty cycle. As a ballpark number, our servos rotated from 0-180 degrees when operated over a ~5-14% duty cycle and a 60Hz frequency. The Servo Shield Device takes non-whole numbers at its terminals, so your duty cycles can be quite precise (e.g. you could move your servo a hair by going from a duty cycle of 6.1 to 6.11).

Configuring the Shield

To configure the Adafruit PWM/Servo Shield, run the PWMServoShield Script in the Adafruit subdirectory. The Script adds 16 input terminals to your Arduino Device, one for each PWM. Each of the inputs takes a duty cycle value from 0-100, or the values "on" or "off" ("on" is the same as a duty cycle value of 100, and "off" is the same as a duty cycle value of 0). The PWMServoShield Device's terminal names are user definable.

Note: if you wish to have your servos operate over a 0-180 value range instead of the ~4-15 (duty cycle) range, consider creating a Mapper Device to map degrees to duty cycle. Wire the "out" output of the Mapper to a PWM terminal on your PWMServoShield Device and use the Mapper's "in" input for your 0-180 values. Your Mapper will look something like:

run_script("Scripts/Device/Virtual/Mapper", id:"mapper", from:"0..180", to:"5.5..13.00")

The PWMServoShield Script takes the following parameters:

  • arduino_id : the ID of the Arduino which is connected to the PWM/Servo shield. This is the same as the ID supplied by the "id" parameter when adding an Arduino to the system.
  • i2c_address : the I2C address of the motor shield (default is 0x40)
  • pwm_frequency : the PWM frequency of all the PWM outputs. The default is 60.
  • pwm0_name : the name for PWM 0's input terminal
  • pwm1_name : the name for PWM 1's input terminal
  • pwm2_name : the name for PWM 2's input terminal
  • pwm3_name : the name for PWM 3's input terminal
  • pwm4_name : the name for PWM 4's input terminal
  • pwm5_name : the name for PWM 5's input terminal
  • pwm6_name : the name for PWM 6's input terminal
  • pwm7_name : the name for PWM 7's input terminal
  • pwm8_name : the name for PWM 8's input terminal
  • pwm9_name : the name for PWM 9's input terminal
  • pwm10_name : the name for PWM 10's input terminal
  • pwm11_name : the name for PWM 11's input terminal
  • pwm12_name : the name for PWM 12's input terminal
  • pwm13_name : the name for PWM 13's input terminal
  • pwm14_name : the name for PWM 14's input terminal
  • pwm15_name : the name for PWM 15's input terminal

If you want to leave a terminal off of your Arduino, define its name as the empty string ("").

Here's an example using the PWMServoShield Script. It adds a Servo Shield with servos connected to the shield's 2, 3, and 4 servo outputs. It's running at 60Hz and is plugged into an Arduino with ID "arduino". The servo terminals are named "pwm2", "pwm3" and "pwm4".

arduino_id: "arduino"
i2c_address: 0x40
pwm_frequency: 60
pwm0_name: ""
pwm1_name: ""
pwm2_name: "pwm2"
pwm3_name: "pwm3"
pwm4_name: "pwm4"
pwm5_name: ""
pwm6_name: ""
pwm7_name: ""
pwm8_name: ""
pwm9_name: ""
pwm10_name: ""
pwm11_name: ""
pwm12_name: ""
pwm13_name: ""
pwm14_name: ""
pwm15_name: ""

Catalina Computing, LLC.

Copyright © Catalina Computing, LLC. (2013-2018)




Page last updated: Tue Oct 7 17:58:21 2014 (UTC)