Motor current controller
Fork of CURRENT_CONTROL by
CURRENT_CONTROL.h@0:955aa05c968a, 2016-04-22 (annotated)
- Committer:
- adam_z
- Date:
- Fri Apr 22 09:39:01 2016 +0000
- Revision:
- 0:955aa05c968a
- Child:
- 1:c5973a56d474
started;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
adam_z | 0:955aa05c968a | 1 | #ifndef __CURRENT_CONTROL_H__ |
adam_z | 0:955aa05c968a | 2 | #define __CURRENT_CONTROL_H__ |
adam_z | 0:955aa05c968a | 3 | |
adam_z | 0:955aa05c968a | 4 | #include "mbed.h" |
adam_z | 0:955aa05c968a | 5 | #include "PID.h" |
adam_z | 0:955aa05c968a | 6 | |
adam_z | 0:955aa05c968a | 7 | |
adam_z | 0:955aa05c968a | 8 | class CURRENT_CONTROL |
adam_z | 0:955aa05c968a | 9 | { |
adam_z | 0:955aa05c968a | 10 | public: |
adam_z | 0:955aa05c968a | 11 | |
adam_z | 0:955aa05c968a | 12 | void CURRENT_CONTROL(PinName curChannel, PinName PwmChannel1, PinName PwmChannel2, float Kp, float Ki, float Kd, float samplingTime); |
adam_z | 0:955aa05c968a | 13 | void ControlCompute(float curRef, float curFeedback); |
adam_z | 0:955aa05c968a | 14 | void ChangePwmPeriod(float microSeconds); |
adam_z | 0:955aa05c968a | 15 | |
adam_z | 0:955aa05c968a | 16 | typedef enum { |
adam_z | 0:955aa05c968a | 17 | PWM1; |
adam_z | 0:955aa05c968a | 18 | PWM2; |
adam_z | 0:955aa05c968a | 19 | } PWMIndex; |
adam_z | 0:955aa05c968a | 20 | |
adam_z | 0:955aa05c968a | 21 | PID pid; |
adam_z | 0:955aa05c968a | 22 | PwmOut MotorPlus; |
adam_z | 0:955aa05c968a | 23 | PwmOut MotorMinus; |
adam_z | 0:955aa05c968a | 24 | float controlOutput; |
adam_z | 0:955aa05c968a | 25 | |
adam_z | 0:955aa05c968a | 26 | float currentOffset; |
adam_z | 0:955aa05c968a | 27 | float currentFeedBack; |
adam_z | 0:955aa05c968a | 28 | private: |
adam_z | 0:955aa05c968a | 29 | |
adam_z | 0:955aa05c968a | 30 | float Ts; |
adam_z | 0:955aa05c968a | 31 | AnalogIn currentAnalogIn; |
adam_z | 0:955aa05c968a | 32 | |
adam_z | 0:955aa05c968a | 33 | }; |
adam_z | 0:955aa05c968a | 34 | |
adam_z | 0:955aa05c968a | 35 | |
adam_z | 0:955aa05c968a | 36 | |
adam_z | 0:955aa05c968a | 37 | |
adam_z | 0:955aa05c968a | 38 | |
adam_z | 0:955aa05c968a | 39 | |
adam_z | 0:955aa05c968a | 40 | |
adam_z | 0:955aa05c968a | 41 | |
adam_z | 0:955aa05c968a | 42 | |
adam_z | 0:955aa05c968a | 43 | |
adam_z | 0:955aa05c968a | 44 | |
adam_z | 0:955aa05c968a | 45 | |
adam_z | 0:955aa05c968a | 46 | |
adam_z | 0:955aa05c968a | 47 | |
adam_z | 0:955aa05c968a | 48 | |
adam_z | 0:955aa05c968a | 49 | |
adam_z | 0:955aa05c968a | 50 | |
adam_z | 0:955aa05c968a | 51 | |
adam_z | 0:955aa05c968a | 52 | |
adam_z | 0:955aa05c968a | 53 | |
adam_z | 0:955aa05c968a | 54 | |
adam_z | 0:955aa05c968a | 55 | |
adam_z | 0:955aa05c968a | 56 | |
adam_z | 0:955aa05c968a | 57 | |
adam_z | 0:955aa05c968a | 58 | |
adam_z | 0:955aa05c968a | 59 | |
adam_z | 0:955aa05c968a | 60 | |
adam_z | 0:955aa05c968a | 61 | |
adam_z | 0:955aa05c968a | 62 | |
adam_z | 0:955aa05c968a | 63 | |
adam_z | 0:955aa05c968a | 64 | |
adam_z | 0:955aa05c968a | 65 | #endif |