Program for testing the motor with SY202 connection from the application board to the L298 motor driver board.
SY202 Motor Test Program
This program exercises a DC motor driver using pins 23, 24, and 25 as (PWM, DIR1, DIR2 respectively) motor control signals on the mbed application board. These pins are also tied to the on-board RGB LED.
/media/uploads/jebradshaw/lab_05_-_actuation.pdf - PDF of the Actuator Lab
main.cpp
- Committer:
- jebradshaw
- Date:
- 2018-02-28
- Revision:
- 0:0da08bb74f7b
- Child:
- 1:78b320721b2d
File content as of revision 0:0da08bb74f7b:
// J. Bradshaw 20190228 // Program for testing Motor control port on SY202 application board to L293 interface #include "mbed.h" #include "MotCon.h" //uses the MotCon.h library for controlling the motor ports //PC serial connection Serial pc(USBTX, USBRX); //tx, rx via USB connection DigitalOut led(LED1); MotCon m1(p23, p24, p25); //uses p23 for pwm and p24 and 35 for direction (complimentary) //------------ Main ------------------------------ int main() { pc.baud(921600);//fast baud rate for USB PC connection while(1) { //iterate through 2*pi cycles in .01 increments for(float cycle=0;cycle<3.14159*2.0;cycle+=.01){ float m1_dc = .85*sin(cycle); m1.mot_control(m1_dc); pc.printf("cycle=%.3f m1_dc = %.2f \r\n", cycle, m1_dc); wait(.01); //determines period led = !led; //toggle LED1 to indicate activity } } }