Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MotorDrive.cpp
00001 #include "MotorDrive.h" 00002 #include "mbed.h" 00003 00004 PwmOut pwm[3] = {PwmOut(PB_2),PwmOut(PB_15),PwmOut(PA_1)}; 00005 DigitalOut cw[3] = {DigitalOut(PB_12),DigitalOut(PA_12),DigitalOut(PH_1)}; 00006 DigitalOut ccw[3] = {DigitalOut(PB_1),DigitalOut(PB_14),DigitalOut(PA_4)}; 00007 DigitalOut dis[3] = {DigitalOut(PA_11),DigitalOut(PB_13),DigitalOut(PC_2)}; 00008 //DigitalOut led(D6); 00009 00010 //void motor_init(); 00011 //void motor(int,char,float); 00012 00013 void motor_init(){ 00014 for(int i=0;i<3;i++){ 00015 cw[i]=0; 00016 ccw[i]=0; 00017 dis[i]=0; 00018 pwm[i].period_us(100); 00019 } 00020 } 00021 00022 void motor(int motor_num,char direction_of_rotation,float PWM_WRITE){ 00023 pwm[motor_num].write(PWM_WRITE); 00024 switch(direction_of_rotation){ 00025 case CW: 00026 ccw[motor_num]=0; 00027 cw[motor_num]=1; 00028 break; 00029 case CCW: 00030 cw[motor_num]=0; 00031 ccw[motor_num]=1; 00032 break; 00033 case STOP: 00034 cw[motor_num]=0; 00035 ccw[motor_num]=0; 00036 break; 00037 default:break; 00038 } 00039 }
Generated on Wed Jul 13 2022 04:06:48 by
1.7.2