Skip to content

Commit f1d6de2

Browse files
author
Richard Unger
committed
Merge remote-tracking branch 'simplefoc/dev' into dev
2 parents 7499e30 + aa7e3ec commit f1d6de2

File tree

7 files changed

+58
-8
lines changed

7 files changed

+58
-8
lines changed

.github/workflows/teensy.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: PlatformIO - Teensy build
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/cache@v3
12+
with:
13+
path: |
14+
~/.cache/pip
15+
~/.platformio/.cache
16+
key: ${{ runner.os }}-pio
17+
- uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.9'
20+
- name: Install PlatformIO Core
21+
run: pip install --upgrade platformio
22+
23+
- name: PIO Run Teensy 4
24+
run: pio ci --lib="." --board=teensy41 --board=teensy40
25+
env:
26+
PLATFORMIO_CI_SRC: examples/hardware_specific_examples/Teensy/Teensy4/bldc_driver_6pwm_standalone/bldc_driver_6pwm_standalone.ino
27+
28+
- name: PIO Run Teensy 4
29+
run: pio ci --lib="." --board=teensy41 --board=teensy40
30+
env:
31+
PLATFORMIO_CI_SRC: examples/hardware_specific_examples/Teensy/Teensy4/open_loop_velocity_6pwm/open_loop_velocity_6pwm.ino
32+
33+
- name: PIO Run Teensy 3
34+
run: pio ci --lib="." --board=teensy31 --board=teensy30 --board=teensy35 --board=teensy36
35+
env:
36+
PLATFORMIO_CI_SRC: examples/hardware_specific_examples/Teensy/Teensy3/bldc_driver_6pwm_standalone/bldc_driver_6pwm_standalone.ino
37+
38+
- name: PIO Run Teensy 3
39+
run: pio ci --lib="." --board=teensy31 --board=teensy30 --board=teensy35 --board=teensy36
40+
env:
41+
PLATFORMIO_CI_SRC: examples/hardware_specific_examples/Teensy/Teensy3/open_loop_velocity_6pwm/open_loop_velocity_6pwm.ino

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# SimpleFOClibrary - **Simple** Field Oriented Control (FOC) **library** <br>
22
### A Cross-Platform FOC implementation for BLDC and Stepper motors<br> based on the Arduino IDE and PlatformIO
33

4-
![Library Compile](https://github.com/simplefoc/Arduino-FOC/workflows/Library%20Compile/badge.svg)
4+
![Library Compile](https://github.com/simplefoc/Arduino-FOC/workflows/Library%20Compile/badge.svg) [![PlatformIO - Teensy build](https://github.com/simplefoc/Arduino-FOC/actions/workflows/teensy.yml/badge.svg)](https://github.com/simplefoc/Arduino-FOC/actions/workflows/teensy.yml)
5+
56
![GitHub release (latest by date)](https://img.shields.io/github/v/release/simplefoc/arduino-foc)
67
![GitHub Release Date](https://img.shields.io/github/release-date/simplefoc/arduino-foc?color=blue)
78
![GitHub commits since tagged version](https://img.shields.io/github/commits-since/simplefoc/arduino-foc/latest/dev)
@@ -26,6 +27,8 @@ Therefore this is an attempt to:
2627

2728
> NEW RELEASE 📢 : <span class="simple">Simple<span class="foc">FOC</span>library</span> v2.3.2
2829
> - Improved [space vector modulation code](https://github.com/simplefoc/Arduino-FOC/pull/309) thanks to [@Candas1](https://github.com/Candas1)
30+
> - Bugfix for teensy3.2 - [#321](https://github.com/simplefoc/Arduino-FOC/pull/321)
31+
> - Added teensy3/4 compile to the github CI using platformio
2932
> - And more bugfixes - see the [complete list of 2.3.2 fixes here](https://github.com/simplefoc/Arduino-FOC/issues?q=is%3Aissue+milestone%3A2.3.2_Release)
3033
3134
## Arduino *SimpleFOClibrary* v2.3.2

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ sensor_direction KEYWORD2
133133
sensor_offset KEYWORD2
134134
zero_electric_angle KEYWORD2
135135
verbose KEYWORD2
136+
verboseMode KEYWORD1
136137
decimal_places KEYWORD2
137138
phase_resistance KEYWORD2
138139
phase_inductance KEYWORD2

src/BLDCMotor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void BLDCMotor::move(float new_target) {
422422
shaft_angle_sp = target;
423423
// calculate velocity set point
424424
shaft_velocity_sp = feed_forward_velocity + P_angle( shaft_angle_sp - shaft_angle );
425-
shaft_angle_sp = _constrain(shaft_angle_sp,-velocity_limit, velocity_limit);
425+
shaft_velocity_sp = _constrain(shaft_velocity_sp,-velocity_limit, velocity_limit);
426426
// calculate the torque command - sensor precision: this calculation is ok, but based on bad value from previous calculation
427427
current_sp = PID_velocity(shaft_velocity_sp - shaft_velocity); // if voltage torque control
428428
// if torque controlled through voltage
@@ -561,6 +561,8 @@ void BLDCMotor::setPhaseVoltage(float Uq, float Ud, float angle_el) {
561561

562562
center = driver->voltage_limit/2;
563563
if (foc_modulation == FOCModulationType::SpaceVectorPWM){
564+
// discussed here: https://community.simplefoc.com/t/embedded-world-2023-stm32-cordic-co-processor/3107/165?u=candas1
565+
// a bit more info here: https://microchipdeveloper.com/mct5001:which-zsm-is-best
564566
// Midpoint Clamp
565567
float Umin = min(Ua, min(Ub, Uc));
566568
float Umax = max(Ua, max(Ub, Uc));

src/StepperMotor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ void StepperMotor::move(float new_target) {
311311
shaft_angle_sp = target;
312312
// calculate velocity set point
313313
shaft_velocity_sp = feed_forward_velocity + P_angle( shaft_angle_sp - shaft_angle );
314-
shaft_angle_sp = _constrain(shaft_angle_sp, -velocity_limit, velocity_limit);
314+
shaft_velocity_sp = _constrain(shaft_velocity_sp, -velocity_limit, velocity_limit);
315315
// calculate the torque command
316316
current_sp = PID_velocity(shaft_velocity_sp - shaft_velocity); // if voltage torque control
317317
// if torque controlled through voltage
@@ -440,4 +440,4 @@ float StepperMotor::angleOpenloop(float target_angle){
440440
open_loop_timestamp = now_us;
441441

442442
return Uq;
443-
}
443+
}

src/drivers/hardware_specific/renesas/renesas.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ bool configureTimerPin(RenesasHardwareDriverParams* params, uint8_t index, bool
207207
t->timer_cfg.cycle_end_irq = FSP_INVALID_VECTOR;
208208

209209
t->ext_cfg.p_pwm_cfg = &(t->pwm_cfg);
210+
t->ext_cfg.capture_a_ipl = BSP_IRQ_DISABLED;
211+
t->ext_cfg.capture_a_irq = FSP_INVALID_VECTOR;
212+
t->ext_cfg.capture_b_ipl = BSP_IRQ_DISABLED;
213+
t->ext_cfg.capture_b_irq = FSP_INVALID_VECTOR;
210214
t->pwm_cfg.trough_ipl = BSP_IRQ_DISABLED;
211215
t->pwm_cfg.trough_irq = FSP_INVALID_VECTOR;
212216
t->pwm_cfg.poeg_link = GPT_POEG_LINK_POEG0;

src/drivers/hardware_specific/teensy/teensy3_mcu.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// if defined
44
// - Teensy 3.0 MK20DX128
55
// - Teensy 3.1/3.2 MK20DX256
6-
// - Teensy 3.5 MK20DX128
76
// - Teensy LC MKL26Z64
87
// - Teensy 3.5 MK64FX512
98
// - Teensy 3.6 MK66FX1M0
@@ -14,7 +13,7 @@
1413
#pragma message("SimpleFOC: compiling for Teensy 3.x")
1514
#pragma message("")
1615

17-
// pin definition from https://github.com/PaulStoffregen/cores/blob/286511f3ec849a6c9e0ec8b73ad6a2fada52e44c/teensy3/pins_teensy.c
16+
// pin definition from https://github.com/PaulStoffregen/cores/blob/286511f3ec849a6c9e0ec8b73ad6a2fada52e44c/teensy3/pins_teensy.c#L627
1817
#if defined(__MK20DX128__)
1918
#define FTM0_CH0_PIN 22
2019
#define FTM0_CH1_PIN 23
@@ -116,7 +115,7 @@ int _findTimer( const int Ah, const int Al, const int Bh, const int Bl, const i
116115
}
117116
}
118117

119-
#ifdef FTM3_SC // if the board has FTM3 timer
118+
#ifdef FTM3_CH0_PIN // if the board has FTM3 timer
120119
if((Ah == FTM3_CH0_PIN && Al == FTM3_CH1_PIN) ||
121120
(Ah == FTM3_CH2_PIN && Al == FTM3_CH3_PIN) ||
122121
(Ah == FTM3_CH4_PIN && Al == FTM3_CH5_PIN) ){
@@ -134,7 +133,7 @@ int _findTimer( const int Ah, const int Al, const int Bh, const int Bl, const i
134133
}
135134
}
136135
}
137-
#endif
136+
#endif
138137

139138
#ifdef SIMPLEFOC_TEENSY_DEBUG
140139
SIMPLEFOC_DEBUG("TEENSY-DRV: ERR: Pins not on timers FTM0 or FTM3!");

0 commit comments

Comments
 (0)