jiexuan fan
/
ServoController
mit
Revision 5:75b5c24e36ad, committed 2018-12-24
- Comitter:
- coldplay
- Date:
- Mon Dec 24 03:46:36 2018 +0000
- Parent:
- 4:4e7b392ed0aa
- Commit message:
- mit
Changed in this revision
QEI_lib.lib | Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4e7b392ed0aa -r 75b5c24e36ad QEI_lib.lib --- a/QEI_lib.lib Wed Mar 18 17:17:58 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org \ No newline at end of file
diff -r 4e7b392ed0aa -r 75b5c24e36ad main.cpp --- a/main.cpp Wed Mar 18 17:17:58 2015 +0000 +++ b/main.cpp Mon Dec 24 03:46:36 2018 +0000 @@ -8,29 +8,28 @@ Serial pc(USBTX, USBRX); -AnalogIn p_pot (p15); -AnalogIn d_pot (p16); -AnalogIn a_pot (p17); +//AnalogIn p_pot (p15); +//AnalogIn d_pot (p16); +//AnalogIn a_pot (p17); -PwmOut Motor1(p21); //Ouput pin to h-bridge 1 -PwmOut Motor2 (p22); //Output pin to h-bridge 2 -AnalogIn Current (p20); //Current sense pin +PwmOut pwm(p21); //Ouput pin to h-bridge 1 +DigitalOut INA(p19); +DigitalOut INB(p20); +AnalogIn Current (p18); //Current sense pin int steps_per_rev = 1200; //Encoder CPR * gearbox ratio Timer timer; // Setup parameters -float volt2amp = 3.3 / .525; //(0-3.3V input) * (voltage divider muiltiplier) / (.525 V/A) +float volt2amp = 3.3 / .140; //(0-3.3V input) * (voltage divider muiltiplier) / (.525 V/A) float PWM_frequency = 20000.0; // MC33926 h-bridge limited 20 kHz (.00005 seconds) //Use X4 encoding. -QEI wheel(p13, p14, NC, steps_per_rev, QEI::X4_ENCODING); //(encoder channel 1, encoder channel 2, index (n/a here), counts per revolution, mode (X4, X2)) - +QEI wheel(p16, p17, NC, steps_per_rev, QEI::X4_ENCODING); //(encoder channel 1, encoder channel 2, index (n/a here), counts per revolution, mode (X4, X2)) -float pulsesToRadians(float pulses) //Encoder steps to revolutions of output shaft in radians -{ - return ((pulses/steps_per_rev)*(2*pi)); +void update_position(void) { + ); } float pulsesToDegrees(float pulses) //Encoder steps to revolutions of output shaft in degrees @@ -56,30 +55,6 @@ -void pulse_motor(float pulse_time, float pulse_interval) //Usefull for testing peak torque. - //pulse_time = motor on time. pulse_interval = motor off time -{ - timer.start(); - - while (timer.read() < pulse_time){ - Motor1.write(1); - Motor2.write(0); - //Prints current draw to PC - printf("%F", (Current.read())*volt2amp); //Arithmetic converts the analog input to Amps - printf("\n"); - } - - timer.stop(); - timer.reset(); - - wait(pulse_time); - - Motor1.write(0); - Motor2.write(0); - - wait(pulse_interval); - } - int main()