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.
Fork of CURRENT_CONTROL by
Revision 11:31cd02611cd0, committed 2016-12-22
- Comitter:
- benson516
- Date:
- Thu Dec 22 19:22:59 2016 +0000
- Parent:
- 10:9f5f4a22346c
- Child:
- 12:085f35babe21
- Commit message:
- Current control - done
Changed in this revision
| CURRENT_CONTROL.cpp | Show annotated file Show diff for this revision Revisions of this file |
| CURRENT_CONTROL.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/CURRENT_CONTROL.cpp Wed Dec 21 18:45:23 2016 +0000
+++ b/CURRENT_CONTROL.cpp Thu Dec 22 19:22:59 2016 +0000
@@ -51,7 +51,7 @@
MotorMinus(PwmChannel2),
wheelSpeed(QEI_A, QEI_B, NC, pulsesPerRev, arraysize, samplingTime, QEI::X4_ENCODING), //(pin1, pin2, pin3, pulsesPerRev, arraysize, sampletime, pulses)
pid(0.0,0.0,0.0,samplingTime),
- lpFilter(samplingTime, 100.0) // 1.5915 Hz = 10 rad/s
+ lpFilter(samplingTime, 70.0) // 1.5915 Hz = 10 rad/s
{
@@ -208,7 +208,7 @@
// Control
///////////////////////////////////////////////////////////
-void CURRENT_CONTROL::Control(float curRef)
+void CURRENT_CONTROL::Control(float curRef, bool enable)
{
// Init check
OffsetInit();
@@ -231,8 +231,11 @@
// voltage_out = 0.0 + func_back_emf(angularSpeed);
// Output saturation and unit changing
- SetVoltage(voltage_out);
+ if (enable)
+ SetVoltage(voltage_out);
+ else
+ SetVoltage(0.0);
//--------------------------------//
--- a/CURRENT_CONTROL.h Wed Dec 21 18:45:23 2016 +0000
+++ b/CURRENT_CONTROL.h Thu Dec 22 19:22:59 2016 +0000
@@ -53,7 +53,7 @@
//
void OffsetInit(void);
float saturation(float input_value, float &delta, const float &limit_H, const float &limit_L);
- void Control(float curRef);
+ void Control(float curRef, bool enable);
// Back emf as the function of rotational speed
float func_back_emf(const float &W_in);
