Motacon_20200317
Dependents: HelloWorld_MotorKaisei
Diff: BLDCmotorDriver.cpp
- Revision:
- 5:cf8183ae80ef
- Parent:
- 3:a4b4a8e3f2a0
- Child:
- 6:959e725b6be9
--- a/BLDCmotorDriver.cpp Mon Jun 01 13:47:23 2015 +0000 +++ b/BLDCmotorDriver.cpp Fri Mar 13 01:07:30 2020 +0000 @@ -9,7 +9,7 @@ switchingPeriod = 1.0 / 20e3; dutyCycle = tempDutyCycle = 0; GH_A.period(switchingPeriod); // applies to all PwmOut instances - rl.setLimits(0.1, -0.1, 0, sampleTime); // initial 10 second ramp +// rl.setLimits(0.1, -0.5, 0, sampleTime); // initial 10 second ramp //H1.mode(PullNone); //H2.mode(PullNone); //H3.mode(PullNone); @@ -77,105 +77,105 @@ switch(currentSector) { case 0: //001 - GH_A = dutyCycle; - GL_A = 0; - GH_B = 0; + GL_C = 0; GL_B = 0; + GL_A = 1; GH_C = 0; - GL_C = 1; + GH_B = dutyCycle; + GH_A = 0; break; case 1: - GH_A = 0; + GL_C = 1; + GL_B = 0; GL_A = 0; + GH_C = 0; GH_B = dutyCycle; - GL_B = 0; - GH_C = 0; - GL_C = 1; + GH_A = 0; break; case 2: - GH_A = 0; - GL_A = 1; - GH_B = dutyCycle; + GL_C = 1; GL_B = 0; + GL_A = 0; GH_C = 0; - GL_C = 0; + GH_B = 0; + GH_A = dutyCycle; break; case 3: - GH_A = 0; - GL_A = 1; + GL_C = 0; + GL_B = 1; + GL_A = 0; + GH_C = 0; GH_B = 0; - GL_B = 0; - GH_C = dutyCycle; - GL_C = 0; + GH_A = dutyCycle; break; case 4: - GH_A = 0; + GL_C = 0; + GL_B = 1; GL_A = 0; + GH_C = dutyCycle; GH_B = 0; - GL_B = 1; - GH_C = dutyCycle; - GL_C = 0; + GH_A = 0; break; case 5: - GH_A = dutyCycle; - GL_A = 0; + GL_C = 0; + GL_B = 0; + GL_A = 1; + GH_C = dutyCycle; GH_B = 0; - GL_B = 1; - GH_C = 0; - GL_C = 0; + GH_A = 0; break; } } else if (dutyCycle < 0) { currentSector--; if(currentSector < 0)currentSector = 5; switch(currentSector) { - case 0: - GH_A = -dutyCycle; - GL_A = 0; - GH_B = 0; - GL_B = 1; - GH_C = 0; - GL_C = 0; + case 0: + GL_C = 0; + GL_B = 0; + GL_A = 1; + GH_C = -dutyCycle; + GH_B = 0; + GH_A = 0; break; case 1: - GH_A = -dutyCycle; - GL_A = 0; - GH_B = 0; + GL_C = 0; GL_B = 0; + GL_A = 1; GH_C = 0; - GL_C = 1; - break; - case 2: - GH_A = 0; - GL_A = 0; - GH_B = -dutyCycle; - GL_B = 0; - GH_C = 0; - GL_C = 1; - break; - case 3: - GH_A = 0; - GL_A = 1; GH_B = -dutyCycle; + GH_A = 0; + break; + case 2: + GL_C = 1; GL_B = 0; + GL_A = 0; GH_C = 0; - GL_C = 0; + GH_B = -dutyCycle; + GH_A = 0; break; - case 4: - GH_A = 0; - GL_A = 1; + case 3: + GL_C = 1; + GL_B = 0; + GL_A = 0; + GH_C = 0; + GH_B = 0; + GH_A = -dutyCycle; + break; + case 4: + GL_C = 0; + GL_B = 1; + GL_A = 0; + GH_C = 0; GH_B = 0; - GL_B = 0; + GH_A = -dutyCycle; + break; + case 5: + GL_C = 0; + GL_B = 1; + GL_A = 0; GH_C = -dutyCycle; - GL_C = 0; - break; - case 5: + GH_B = 0; GH_A = 0; - GL_A = 0; - GH_B = 0; - GL_B = 1; - GH_C = -dutyCycle; - GL_C = 0; break; } }else {