Skip to content

Commit 483d921

Browse files
committed
forgotten use
1 parent d73aea5 commit 483d921

File tree

2 files changed

+6
-37
lines changed

2 files changed

+6
-37
lines changed

src/BLDCMotor.cpp

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ void BLDCMotor::setPhaseVoltage(float Uq, float Ud, float angle_el) {
221221
case FOCModulationType::SinePWM :
222222
case FOCModulationType::SpaceVectorPWM :
223223

224-
if (modulation_centered) {
225224
// Sinusoidal PWM modulation
226225
// Inverse Park + Clarke transformation
227226
_sincos(angle_el, &_sa, &_ca);
@@ -243,6 +242,7 @@ void BLDCMotor::setPhaseVoltage(float Uq, float Ud, float angle_el) {
243242
// - The part of the duty cycle in which all phases are
244243
// off is longer than in centered modulation
245244
// - Both SinePWM and SpaceVectorPWM have the same form for non-centered modulation
245+
if (modulation_centered) {
246246
center = driver->voltage_limit/2;
247247
if (foc_modulation == FOCModulationType::SpaceVectorPWM){
248248
// discussed here: https://community.simplefoc.com/t/embedded-world-2023-stm32-cordic-co-processor/3107/165?u=candas1
@@ -256,41 +256,10 @@ void BLDCMotor::setPhaseVoltage(float Uq, float Ud, float angle_el) {
256256
Ub += center;
257257
Uc += center;
258258
}else{
259-
angle_el = _normalizeAngle(angle_el + _PI_2);
260-
_sincos(angle_el, &_sa, &_ca);
261-
262-
263-
264-
// Inverse park transform
265-
Ualpha = _ca * Uq;//- _sa * Uq; // -sin(angle) * Uq;
266-
Ubeta = _sa * Uq;// + _ca * Uq; // cos(angle) * Uq;
267-
268-
// Clarke transform
269-
270-
// determine the segment I, II, III
271-
if ((angle_el >= 0) && (angle_el < _120_D2R)) {
272-
// section I
273-
Ua = Ualpha + _1_SQRT3 * Ubeta;
274-
Ub = _2_SQRT3 * Ubeta;
275-
Uc = 0;
276-
277-
} else if ((angle_el >= _120_D2R) && (angle_el < (2 * _120_D2R))) {
278-
// section III
279-
Ua = 0;
280-
Ub = _1_SQRT3 * Ubeta - Ualpha;
281-
Uc = -_1_SQRT3 * Ubeta - Ualpha;
282-
283-
} else if ((angle_el >= (2 * _120_D2R)) && (angle_el < (3 * _120_D2R))) {
284-
// section II
285-
Ua = Ualpha - _1_SQRT3 * Ubeta;
286-
Ub = 0;
287-
Uc = - _2_SQRT3 * Ubeta;
288-
}
289-
290-
Ua = Ua*1.5;
291-
Ub = Ub*1.5;
292-
Uc = Uc*1.5;
293-
259+
float Umin = min(Ua, min(Ub, Uc));
260+
Ua -= Umin;
261+
Ub -= Umin;
262+
Uc -= Umin;
294263
}
295264
break;
296265
}

src/common/base_classes/FOCMotor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
SIMPLEFOC_DEBUG(msg, ##__VA_ARGS__)
2222

2323
#define SIMPLEFOC_MOTOR_DEBUG(msg, ...) \
24-
SimpleFOCDebug::print("MOT:"); \
24+
SimpleFOCDebug::print("MOT: "); \
2525
SIMPLEFOC_DEBUG(msg, ##__VA_ARGS__)
2626

2727
#else

0 commit comments

Comments
 (0)