Skip to content

Commit 7374f7a

Browse files
committed
Add getDQCurrents function for Park transform
1 parent 8727908 commit 7374f7a

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/common/base_classes/CurrentSense.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,8 @@ DQCurrent_s CurrentSense::getFOCCurrents(float angle_el){
3939
ABCurrent_s ABcurrent = getABCurrents(current);
4040

4141
// calculate park transform
42-
float ct;
43-
float st;
44-
_sincos(angle_el, &st, &ct);
45-
DQCurrent_s return_current;
46-
return_current.d = ABcurrent.alpha * ct + ABcurrent.beta * st;
47-
return_current.q = ABcurrent.beta * ct - ABcurrent.alpha * st;
42+
DQCurrent_s return_current = getDQCurrents(ABcurrent,angle_el);
43+
4844
return return_current;
4945
}
5046

@@ -84,6 +80,20 @@ ABCurrent_s CurrentSense::getABCurrents(PhaseCurrent_s current){
8480
return return_ABcurrent;
8581
}
8682

83+
// function used with the foc algorihtm
84+
// calculating D and Q currents from Alpha Beta currents and electrical angle
85+
// - function calculating Clarke transform of the phase currents
86+
DQCurrent_s CurrentSense::getDQCurrents(ABCurrent_s current, float angle_el){
87+
// calculate park transform
88+
float ct;
89+
float st;
90+
_sincos(angle_el, &st, &ct);
91+
DQCurrent_s return_current;
92+
return_current.d = current.alpha * ct + current.beta * st;
93+
return_current.q = current.beta * ct - current.alpha * st;
94+
return return_current;
95+
}
96+
8797
/**
8898
Driver linking to the current sense
8999
*/

src/common/base_classes/CurrentSense.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ class CurrentSense{
7878
*/
7979
ABCurrent_s getABCurrents(PhaseCurrent_s current);
8080

81+
/**
82+
* Function used for Park transform in FOC control
83+
* It reads the Alpha Beta currents and electircal angle of the motor
84+
* It returns the D and Q currents
85+
*
86+
* @param current - phase current
87+
*/
88+
DQCurrent_s getDQCurrents(ABCurrent_s current,float angle_el);
89+
8190

8291
};
8392

0 commit comments

Comments
 (0)