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.
Motor.h
00001 #include "mbed.h" 00002 #include "QEI.h" 00003 #include "Encoder.h" 00004 #include "HBridge.h" 00005 #include "CurrentSense.h" 00006 #include "PID.h" 00007 00008 #ifndef MOTOR_H 00009 #define MOTOR_H 00010 00011 class Motor { 00012 public: 00013 Motor( 00014 PinName pwm_pin, PinName min_1_pin, PinName min_2_pin, float pwm_period, 00015 PinName current_pin, 00016 PinName enc_a_pin, PinName enc_b_pin, 00017 float pid_cur_p_gain, float pid_cur_d_gain, float pid_cur_i_gain 00018 ); 00019 00020 float position; 00021 float velocity; 00022 float current; 00023 float torque; 00024 float command; 00025 00026 // output to PWM 00027 float output; 00028 00029 // Update all state variables and apply command 00030 void update(void); 00031 00032 float get_position(void); 00033 float get_velocity(void); 00034 float get_current(void); 00035 00036 // Set current controller commanded value 00037 void set_command(float command); 00038 00039 //float get_pulse_current(float pulse_time, float pulse_interval); 00040 00041 private: 00042 Timer timer_; 00043 HBridge hbridge_; 00044 CurrentSense current_sense_; 00045 Encoder encoder_; 00046 PIDController current_controller_; 00047 00048 }; 00049 00050 #endif
Generated on Tue Jul 12 2022 15:35:31 by
1.7.2