| Running MD22 in RC Mode Example Last Modified: 2007-02-22 | | |
| Acroname Robotics | PDF webpage version | ||
| ![]() Overview The Devantech MD22 can operate in a number of different operational modes. One useful operational mode is the RC control mode. A RC duty cycle signal (10msec to 20msec) controls the output motor speed. The MD22 decodes the incoming duty cycle and sends the appropriate commands to the H-bridges. This example demonstrates using a BrainStem GP 1.0 module's servo motor ports to send a RC control signal to the MD22 to spin a motor. Circuit Schematic - RC Control Mode In the following schematic, a BrainStem GP is connected to the Devantech MD22. A decoupling capacitor is attached to the motor terminals to reduce the amount of system noise. For this example, a 10nF ceramic capacitor is adequate. RC servo pulses are sequential in nature and the same MD22 timer is used to measure both pulses. Pulses to the two MD22 channels should not occur at the same time, or overlap. If only a single channel is required as shown in this example, the motor should be wired into channel 1 (SCL) and SDA connected to ground. SDA is connected to any Ground pin on the BrainStem. The mode switches on the MD22 are configured to ON, OFF, ON, OFF (switches 1:4 respectively). For this example, a dedicated power supply was used for the motors and another for the logic power. The Grounds are connected internally on MD22 board. ![]() Wiring diagram for interfacing a BrainStem GP to a MD22 in RC mode. Source Code - TEA Program for RC Control This code uses the TEA language which is very similar to ANSI C. It is compiled using the BrainStem Console with the steep command. The example code slowly ramps up the motor velocity by increasing the duty cycle of the BrainStem channel 0 servo output. Halfway through execution, the motor velocity is ramped back down to a stop. The number of iterations is defined as a macro. /*
Filename: md22rcmode.tea
*/
#include <aCore.tea>
#include <aServo.tea>
#define MD22SRV 0 // Define what channel the MD22 is hooked to
#define DELAY 1000 // Macro for time step delay
#define UP 1
#define DOWN 0
#define STEPS 50 // Number of iterations to do
int main()
{
unsigned char val = 127;
char step = -STEPS;
char direction = UP;
while (step < STEPS)
{
// Apply the servo PWM duty cycle to the MD22
aServo_SetAbsolute(MD22SRV,val);
if (step == 0) direction = DOWN;
if (direction == UP) val++;
else val--;
step++;
aCore_Sleep(DELAY);
} // End of while loop
return 0;
} // End of main
Additional Information Supplemental information about using the MD22 in it's various operational modes can be found on the MD22 product page. Also, detailed information can also be found at the Devantech MD22 product page. Revision History:
| |||||||
| voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy © Copyright 1994-2008 Acroname, Inc., Boulder, Colorado. All rights reserved. |