This post starts a small (or larger?) series of tutorials using the Arduino Motor/Stepper/Servo Shield with the FRDM-KL25Z board. That motor shield is probably one of the most versatile on the market, and features 2 servo and 4 motor connectors for DC or stepper motors. That makes it a great shield for any robotic project
The series starts with a tutorial how to drive two servo motors. And if this is not what you are expecting to do with this shield, then you can vote and tell me what you want to see instead on this motor shield :-).
OEM or Original?
The original Arduino Motor/Stepper/Servo Shield is available from Adaftruit Industries and costs less than $20. I’m using a OEM version, see this link. The functionality is the same, except that the OEM version only runs with motors up to 16 VDC, while the original shield is for motors up to 25 VDC.
The board has two STMicroelectronics L293D Motor H-Bridge IC’s which can drive up to 4 DC motors (or up to 2 stepper motors) with 0.6 A per bridge (1.2 A peak). The 74HCT595N (my board has the SN74HC595 from Texas Instrument) is a shift register used for the H-Bridges to reduce the number of pins needed (more about this in a next post). A terminal block with jumper is providing power to the DC/stepper motor. The 5 VDC for the servos is taken from the FRDM board.
The FRDM-KL25Z can only give a few hundred mA on the 5V Arduino header. That works for small servos, but I recommend to cut the 5V supply to the servos and use a dedicated 5V (or 6V) for the servos.
Outline
In this tutorial, I’m creating a project with CodeWarrior for MCU10.4 for the FRDM-KL25Z board, and then add support for two servo motors.
Processor Expert Components
This tutorial uses added Processor Expert components which are not part of CodeWarrior distribution. The following other components are used:
- Wait: allows waiting for a given time
- Servo: high level driver for hobby servp motors
Make sure you have the latest and greatest components loaded from GitHub. Instructions how to download and install the additional components can be found here.
Creating CodeWarrior Project
To create a new project in CodeWarrior:
- File > New > Bareboard Project, give a project name
- Specify the device to be used: MKL25Z128
- OpenSDA as connection
- I/O support can be set to ‘No I/O’
- Processor Expert as Rapid Application Development option
This creates the starting point for my project:
Servo Motor
Servo motors are used in RC (Radio Control) or (hobby) robotics.
The motor has 3 connectors:
- GND (Black)
- Power (Red), typically 5V, but can be 6V or even higher
- PWM (White or Yellow), signal for position information
The PWM signal typically has frequency of 50 Hz (20 ms), with a duty (high duration) between 1 ms and 2 ms.