jiexuan fan / ServoController_2

Dependencies:   QEI mbed-src

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Motor.h Source File

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