Motor current controller
Fork of CURRENT_CONTROL by
Diff: CURRENT_CONTROL.cpp
- Revision:
- 14:67fc256efeb7
- Parent:
- 13:b5f85f926f22
- Child:
- 15:d9ccd6c92a21
--- a/CURRENT_CONTROL.cpp Sat Dec 24 09:55:00 2016 +0000 +++ b/CURRENT_CONTROL.cpp Mon Dec 26 07:52:43 2016 +0000 @@ -75,6 +75,7 @@ delta_output = 0.0; curFeedBack = 0.0; curFeedBack_filter = 0.0; + curCommand = 0.0; voltage_out = 0.0; // Set PID's parameters @@ -98,6 +99,8 @@ { analog2Cur = Analog2Cur_in;//LTS25-NP current sensor working with STM32F446RE : 3.3*8/0.6 Ke = angSpeed2BackEmf; + Kt = Ke; + Kt_inv = 1/Kt; voltage2Duty = voltage2Duty_in; } void CURRENT_CONTROL::SetReversal(bool reverse_current_in, bool reverse_rotationalSpeed_in, bool reverse_voltage_in) @@ -208,8 +211,12 @@ // Control /////////////////////////////////////////////////////////// +void CURRENT_CONTROL::TorqueControl(float TorqueRef, bool enable){ + Control(Kt_inv*TorqueRef, enable); +} void CURRENT_CONTROL::Control(float curRef, bool enable) { + curCommand = curRef; // Init check OffsetInit(); if (!Flag_Init) return;