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.
Dependencies: mbed-rtos mbed QEI BNO055 MPU6050_DMP_Nucleo-I2Cdev virgo3_imuHandler_Orion_PCB MAX17048 Servo
Fork of Orion_newPCB_test by
motorDriver.cpp
00001 #include "motorDriver.h" 00002 /* 00003 motorDriver::motorDriver(PinName mPlus, PinName mMinus, int freq_khz): motor_P(mPlus), motor_M(mMinus) 00004 { 00005 motor_P.period_us(1000/freq_khz); 00006 motor_M.period_us(1000/freq_khz); 00007 } 00008 */ 00009 00010 /* 00011 void motorDriver::setPWM(float val) 00012 { 00013 val = generalFunctions::constrain_f(val, minPWM, maxPWM); //check if input pwm value is between -100% to 100% 00014 00015 if(val >= 0) { 00016 motor_P = generalFunctions::abs_f(val); 00017 motor_M = 0; 00018 } else { 00019 motor_P = 0; 00020 motor_M = generalFunctions::abs_f(val); 00021 } 00022 } 00023 */ 00024 00025 motorDriver::motorDriver(): motorL_P(mot_LM), motorL_M(mot_LP), motorR_P(mot_RP), motorR_M(mot_RM) 00026 { 00027 motorL_P.period_us(1000/PWMfreq_khz); 00028 motorL_M.period_us(1000/PWMfreq_khz); 00029 00030 motorR_P.period_us(1000/PWMfreq_khz); 00031 motorR_M.period_us(1000/PWMfreq_khz); 00032 } 00033 00034 void motorDriver::setPWM_L(float val) 00035 { 00036 val = generalFunctions::constrain_f(val, minPWM, maxPWM); //check if input pwm value is between -100% to 100% 00037 00038 if(val >= 0) { 00039 motorL_P = generalFunctions::abs_f(val); 00040 motorL_M = 0; 00041 } else { 00042 motorL_P = 0; 00043 motorL_M = generalFunctions::abs_f(val); 00044 } 00045 } 00046 00047 void motorDriver::setPWM_R(float val) 00048 { 00049 val = generalFunctions::constrain_f(val, minPWM, maxPWM); //check if input pwm value is between -100% to 100% 00050 00051 if(val >= 0) { 00052 motorR_P = generalFunctions::abs_f(val); 00053 motorR_M = 0; 00054 } else { 00055 motorR_P = 0; 00056 motorR_M = generalFunctions::abs_f(val); 00057 } 00058 }
Generated on Tue Jul 12 2022 20:53:07 by
