Skip to content

Commit 51f0f79

Browse files
committed
FEAT added standalone driver examples
1 parent 624935f commit 51f0f79

File tree

4 files changed

+102
-1
lines changed

4 files changed

+102
-1
lines changed

examples/motion_control/open_loop_motor_control/open_loop_velocity_example/open_loop_velocity_example.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Open loop motor control example
2-
#include <SimpleFOC.h>
2+
#include <SimpleFOC.h>
33

44

55
// BLDC motor & driver instance
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// BLDC driver standalone example
2+
#include <SimpleFOC.h>
3+
4+
5+
// BLDC driver instance
6+
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 5, 6, 8);
7+
8+
void setup() {
9+
10+
// pwm frequency to be used [Hz]
11+
// for atmega328 fixed to 32kHz
12+
// esp32/stm32/teensy configurable
13+
driver.pwm_frequency = 50000;
14+
// power supply voltage [V]
15+
driver.voltage_power_supply = 12;
16+
// Max DC voltage allowed - default voltage_power_supply
17+
driver.voltage_limit = 12;
18+
// driver init
19+
driver.init();
20+
21+
// enable driver
22+
driver.enable();
23+
24+
_delay(1000);
25+
}
26+
27+
void loop() {
28+
// setting pwm
29+
// phase A: 3V
30+
// phase B: 6V
31+
// phase C: 5V
32+
driver.setPwm(3,6,5);
33+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// BLDC driver standalone example
2+
#include <SimpleFOC.h>
3+
4+
// BLDC driver instance
5+
BLDCDriver3PWM driver = BLDCDriver6PWM(5, 6, 9,10, 3, 11, 8);
6+
7+
void setup() {
8+
9+
// pwm frequency to be used [Hz]
10+
// for atmega328 fixed to 32kHz
11+
// esp32/stm32/teensy configurable
12+
driver.pwm_frequency = 50000;
13+
// power supply voltage [V]
14+
driver.voltage_power_supply = 12;
15+
// Max DC voltage allowed - default voltage_power_supply
16+
driver.voltage_limit = 12;
17+
// daad_zone [0,1] - default 0.02 - 2%
18+
driver.dead_zone = 0.05;
19+
20+
// driver init
21+
driver.init();
22+
23+
// enable driver
24+
driver.enable();
25+
26+
_delay(1000);
27+
}
28+
29+
void loop() {
30+
// setting pwm
31+
// phase A: 3V
32+
// phase B: 6V
33+
// phase C: 5V
34+
driver.setPwm(3,6,5);
35+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Stepper driver standalone example
2+
#include <SimpleFOC.h>
3+
4+
5+
// Stepper driver instance
6+
StepperDriver4PWM driver = StepperDriver4PWM(5, 6, 9,10, 7, 8);
7+
8+
void setup() {
9+
10+
// pwm frequency to be used [Hz]
11+
// for atmega328 fixed to 32kHz
12+
// esp32/stm32/teensy configurable
13+
driver.pwm_frequency = 50000;
14+
// power supply voltage [V]
15+
driver.voltage_power_supply = 12;
16+
// Max DC voltage allowed - default voltage_power_supply
17+
driver.voltage_limit = 12;
18+
19+
// driver init
20+
driver.init();
21+
22+
// enable driver
23+
driver.enable();
24+
25+
_delay(1000);
26+
}
27+
28+
void loop() {
29+
// setting pwm
30+
// phase A: 3V
31+
// phase B: 6V
32+
driver.setPwm(3,6);
33+
}

0 commit comments

Comments
 (0)