Skip to content

Commit 4c5160a

Browse files
committed
example for Teensy 3.x 6pwm mode
1 parent 366d8d5 commit 4c5160a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// 6pwm standalone example code for Teensy 3.x boards
2+
#include <SimpleFOC.h>
3+
4+
5+
// BLDC driver instance
6+
// using FTM0 timer
7+
//BLDCDriver6PWM driver = BLDCDriver6PWM(22,23, 9,10, 6,20, 8);
8+
// using FTM3 timer - available on Teensy3.5 and Teensy3.6
9+
BLDCDriver6PWM driver = BLDCDriver6PWM(2,14, 7,8, 35,36, 8);
10+
11+
void setup() {
12+
Serial.begin(9600);
13+
// pwm frequency to be used [Hz]
14+
driver.pwm_frequency = 30000;
15+
// dead zone percentage of the duty cycle - default 0.02 - 2%
16+
driver.dead_zone=0.02;
17+
// power supply voltage [V]
18+
driver.voltage_power_supply = 12;
19+
// Max DC voltage allowed - default voltage_power_supply
20+
driver.voltage_limit = 12;
21+
22+
// driver init
23+
driver.init();
24+
25+
// enable driver
26+
driver.enable();
27+
28+
_delay(1000);
29+
}
30+
31+
void loop() {
32+
// setting pwm
33+
// phase A: 3V
34+
// phase B: 6V
35+
// phase C: 5V
36+
driver.setPwm(3,6,5);
37+
}

0 commit comments

Comments
 (0)