Simple motor controller library, using DIR, PWM, nSLP pin like pololu.
Diff: MotorControler.cpp
- Branch:
- use_base
- Revision:
- 10:4413d4830297
- Parent:
- 9:a5d6835f7168
--- a/MotorControler.cpp Sun Feb 21 09:23:01 2021 +0000 +++ b/MotorControler.cpp Sun Feb 21 09:28:35 2021 +0000 @@ -1,5 +1,34 @@ #include "MotorControler.h" +/*example******************************************************************* + +#include "mbed.h" +#include <math.h> +#include "MotorControler.h" + +int main() { + TEXNITISControler MOTOR(D8,D6,D7); + Serial PC(USBTX, USBRX); + + MOTOR.setPwmFrequency(20000); + MOTOR.enableDriver(); + + for(int i = 0; i < 360; i++) + { + float speed = MOTOR = sin((float)i * 3.14/180); + wait_ms(20); + PC.printf("%f\r\n", speed); + } + + MOTOR = 0; + + while(1) + { + } +} + +********************************************************************/ + MotorControler::MotorControler(PinName DIR, PinName PWM, PinName nSLP, ControlType control_type) : DIR_(DIR), PWM_(PWM), nSLP_(nSLP)