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-03-01
- Revision:
- 1:78b320721b2d
- Parent:
- 0:0da08bb74f7b
File content as of revision 1:78b320721b2d:
// 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 #include "C12832_lcd.h" //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 p25 for direction (complimentary) C12832_LCD lcd; //------------ Main ------------------------------ int main() { wait(.2); //short delay lcd.cls(); lcd.locate(0,0); lcd.printf("SY202 Motor Test"); 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); lcd.locate(0,8); lcd.printf("cycle=%.2f dc=%7.2f \n", cycle, m1_dc); lcd.locate(0,16); if(m1_dc > 0.001) lcd.printf("Forward\n"); else if(m1_dc < 0.001) lcd.printf("Reverse\n"); pc.printf("cycle=%.3f m1_dc = %.2f \r\n", cycle, m1_dc); wait(.01); //determines period led = !led; //toggle LED1 to indicate activity } } }