Skip to content

Commit d471970

Browse files
committed
reanmed current to dc_current
1 parent d23d1df commit d471970

File tree

10 files changed

+33
-28
lines changed

10 files changed

+33
-28
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Therefore this is an attempt to:
1313
- <i>Support as many <b>motor + sensor + driver + mcu</b> combinations out there</i>
1414
- 🎯 Develop a modular FOC supporting BLDC driver boards:
1515
- *Low-power* gimbal driver (<5Amps) : [*Arduino Simple**FOC**Shield*](https://docs.simplefoc.com/arduino_simplefoc_shield_showcase).
16-
- ***NEW***: *Medium-power* BLDC driver (<50Amps): [*Arduino Simple**FOC**PowerShield*](https://github.com/simplefoc/Arduino-SimpleFOC-PowerShield).
16+
- ***NEW*** 📢: *Medium-power* BLDC driver (<30Amps): [Arduino <span class="simple">Simple<b>FOC</b>PowerShield</span> ](https://github.com/simplefoc/Arduino-SimpleFOC-PowerShield).
17+
- See also [@byDagor](https://github.com/byDagor)'s *fully-integrated* ESP32 based board: [Dagor Brushless Controller](https://github.com/byDagor/Dagor-Brushless-Controller)
1718

1819
##### <b> NEXT RELEASE 📢:</b> <i>Simple<b>FOC</b>library v2.1
1920
> #### Implemented features in dev branch

examples/motion_control/torque_control/encoder/current_control/current_control.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void setup() {
4646
motor.linkCurrentSense(&current_sense);
4747

4848
// set torque mode:
49-
// TorqueControlType::current
49+
// TorqueControlType::dc_current
5050
// TorqueControlType::voltage
5151
// TorqueControlType::foc_current
5252
motor.torque_controller = TorqueControlType::foc_current;

examples/utils/current_sense_test/inline_current_sense_test/inline_current_sense_test.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void setup() {
2424
void loop() {
2525

2626
PhaseCurrent_s currents = current_sense.getPhaseCurrents();
27-
float current_magnitude = current_sense.getCurrent();
27+
float current_magnitude = current_sense.getDCCurrent();
2828

2929
Serial.print(currents.a*1000); // milli Amps
3030
Serial.print("\t");

examples/utils/driver_standalone_test/stepper_driver_2pwm_standalone/stepper_driver_2pwm_standalone.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
// StepperDriver2PWM(pwm1, in1a, in1b, pwm2, in2a, in2b, (en1, en2 optional))
77
StepperDriver2PWM driver = StepperDriver2PWM(3, 4, 5, 10 , 9 , 8 , 11, 12);
88

9+
// StepperDriver2PWM(pwm1, dir1, pwm2, dir2,(en1, en2 optional))
10+
// StepperDriver2PWM driver = StepperDriver2PWM(3, 4, 5, 6, 11, 12);
11+
912
void setup() {
1013

1114
// pwm frequency to be used [Hz]

keywords.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ angleOpenloop KEYWORD2
7878
velocityOpenloop KEYWORD2
7979
getPhaseCurrents KEYWORD2
8080
getFOCCurrents KEYWORD2
81-
getCurrent KEYWORD2
81+
getDCCurrent KEYWORD2
8282
setPwm KEYWORD2
8383
driverAlign KEYWORD2
8484
driverSync KEYWORD2
@@ -124,7 +124,7 @@ velocity_openloop KEYWORD2
124124
angle KEYWORD2
125125
angle_openloop KEYWORD2
126126
torque KEYWORD2
127-
current KEYWORD2
127+
dc_current KEYWORD2
128128
foc_current KEYWORD2
129129

130130

src/BLDCMotor.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ int BLDCMotor::alignSensor() {
183183
// check pole pair number
184184
if(monitor_port) monitor_port->print(F("MOT: PP check: "));
185185
float moved = fabs(mid_angle - end_angle);
186-
if( fabs(moved*pole_pairs - _2PI) > 0.25 ) { // 0.25 is arbitrary number it can be lower or higher!
187-
if(monitor_port) monitor_port->println(F("fail!"));
186+
if( fabs(moved*pole_pairs - _2PI) > 0.5 ) { // 0.5 is arbitrary number it can be lower or higher!
187+
if(monitor_port) monitor_port->print(F("fail - estimated pp:"));
188+
if(monitor_port) monitor_port->println(_2PI/moved,4);
188189
return 0; // failed calibration
189190
}else if(monitor_port) monitor_port->println(F("OK!"));
190191

@@ -250,10 +251,10 @@ void BLDCMotor::loopFOC() {
250251
case TorqueControlType::voltage:
251252
// no need to do anything really
252253
break;
253-
case TorqueControlType::current:
254+
case TorqueControlType::dc_current:
254255
if(!current_sense) return;
255256
// read overall current magnitude
256-
current.q = current_sense->getCurrent(electrical_angle);
257+
current.q = current_sense->getDCCurrent(electrical_angle);
257258
// filter the value values
258259
current.q = LPF_current_q(current.q);
259260
// calculate the phase voltage

src/common/base_classes/CurrentSense.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// get current magnitude
55
// - absolute - if no electrical_angle provided
66
// - signed - if angle provided
7-
float CurrentSense::getCurrent(float motor_electrical_angle){
7+
float CurrentSense::getDCCurrent(float motor_electrical_angle){
88
// read current phase currents
99
PhaseCurrent_s current = getPhaseCurrents();
1010
// currnet sign - if motor angle not provided the magnitude is always positive

src/common/base_classes/CurrentSense.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ class CurrentSense{
2424
*/
2525
virtual int driverSync(BLDCDriver *driver) = 0;
2626

27+
// calibration variables
28+
bool skip_align = false; //!< variable signaling that the phase current direction should be verified during initFOC()
29+
/**
30+
* Function intended to verify if:
31+
* - phase current are oriented properly
32+
* - if their order is the same as driver phases
33+
*
34+
* This function corrects the alignment errors if possible ans if no such thing is needed it can be left empty (return 1)
35+
* @returns - 0 - for failure & positive number (with status) - for success
36+
*/
37+
virtual int driverAlign(BLDCDriver *driver, float voltage) = 0;
38+
2739
/**
2840
* Function rading the phase currents a, b and c
2941
* This function will be used with the foc control throught the function
@@ -41,7 +53,7 @@ class CurrentSense{
4153
*
4254
* @param angle_el - electrical angle of the motor (optional)
4355
*/
44-
virtual float getCurrent(float angle_el = 0);
56+
virtual float getDCCurrent(float angle_el = 0);
4557

4658
/**
4759
* Function used for FOC contorl, it reads the DQ currents of the motor
@@ -50,18 +62,6 @@ class CurrentSense{
5062
* @param angle_el - motor electrical angle
5163
*/
5264
DQCurrent_s getFOCCurrents(float angle_el);
53-
54-
// calibration variables
55-
bool skip_align = false; //!< variable signaling that the phase current direction should be verified during initFOC()
56-
/**
57-
* Function intended to verify if:
58-
* - phase current are oriented properly
59-
* - if their order is the same as driver phases
60-
*
61-
* This function corrects the alignment errors if possible ans if no such thing is needed it can be left empty (return 1)
62-
* @returns - 0 - for failure & positive number (with status) - for success
63-
*/
64-
virtual int driverAlign(BLDCDriver *driver, float voltage) = 0;
6565
};
6666

6767
#endif

src/common/base_classes/FOCMotor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ enum MotionControlType{
3737
*/
3838
enum TorqueControlType{
3939
voltage, //!< Torque control using voltage
40-
current, //!< Torque control using current
40+
dc_current, //!< Torque control using DC current (one current magnitude)
4141
foc_current //!< torque control using dq currents
4242
};
4343

src/communication/Commander.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ void Commander::motor(FOCMotor* motor, char* user_command) {
202202
motor->torque_controller = (TorqueControlType)value;
203203
switch(motor->torque_controller){
204204
case TorqueControlType::voltage:
205-
println(F("volt"));
205+
println(F("dc volt"));
206206
break;
207-
case TorqueControlType::current:
208-
println(F("curr"));
207+
case TorqueControlType::dc_current:
208+
println(F("dc curr"));
209209
break;
210210
case TorqueControlType::foc_current:
211-
println(F("foc"));
211+
println(F("foc curr"));
212212
break;
213213
}
214214
break;

0 commit comments

Comments
 (0)