Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 5feec22

Browse files
authored
Add PWM_StepperControl example
Credits of `Paul van Dinther`
1 parent 25fc807 commit 5feec22

9 files changed

+49
-38
lines changed

CONTRIBUTING.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,33 @@ However, before reporting a bug please check through the following:
1010

1111
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/Portenta_H7_PWM/issues/new).
1212

13+
---
14+
1315
### How to submit a bug report
1416

1517
Please ensure to specify the following:
1618

1719
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18-
* `ArduinoCore-mbed` Core Version (e.g. `ArduinoCore-mbed` mbed_portenta core v3.4.1)
20+
* `ArduinoCore-mbed` Core Version (e.g. `ArduinoCore-mbed` mbed_portenta core v3.5.4)
1921
* `Portenta_H7` Board type (e.g. Portenta_H7 Rev2 ABX00042, etc.)
2022
* Contextual information (e.g. what you were trying to achieve)
2123
* Simplest possible steps to reproduce
2224
* Anything that might be relevant in your opinion, such as:
2325
* Operating system (Windows, Ubuntu, etc.) and the output of `uname -a`
2426
* Network configuration
2527

28+
Please be educated, civilized and constructive as you've always been. Disrespective posts against [GitHub Code of Conduct](https://docs.github.com/en/site-policy/github-terms/github-event-code-of-conduct) will be ignored and deleted.
29+
30+
---
2631

2732
### Example
2833

2934
```
3035
Arduino IDE version: 1.8.19
31-
`ArduinoCore-mbed` mbed_portenta core v3.4.1
36+
`ArduinoCore-mbed` mbed_portenta core v3.5.4
3237
Portenta_H7 Rev2 ABX00042
3338
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
39+
Linux xy-Inspiron-3593 5.15.0-58-generic #64~20.04.1-Ubuntu SMP Fri Jan 6 16:42:31 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
3540
3641
Context:
3742
I encountered a crash while using this library

changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
## Table of Contents
1717

1818
* [Changelog](#changelog)
19+
* [Releases v2.0.3](#Releases-v203)
1920
* [Releases v2.0.2](#Releases-v202)
2021
* [Releases v2.0.1](#Releases-v201)
2122
* [Releases v2.0.0](#Releases-v200)
@@ -26,6 +27,10 @@
2627

2728
## Changelog
2829

30+
### Releases v2.0.3
31+
32+
1. Add example [PWM_StepperControl](https://github.com/khoih-prog/Portenta_H7_PWM/examples/PWM_StepperControl) to demo how to control Stepper Motor using PWM. Check [Using PWM to step a stepper driver #16](https://github.com/khoih-prog/RP2040_PWM/issues/16)
33+
2934
### Releases v2.0.2
3035

3136
1. Convert to `h-only` code

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Portenta_H7_PWM",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"keywords": "timing, device, control, timer, pwm, interrupt, isr, isr-based, hardware-timer, mission-critical, accuracy, non-blocking, mbed, mbed-portenta, portenta-h7, portentah7, portenta-h7-m7, portenta-h7-m4, portentah7-m7, portentah7-m4, stm32h7, stm32, precise, hardware",
55
"description": "This library enables you to use Hardware Timers on an STM32H7-based Portenta_H7 board to create and output PWM to pins. These PWM channels, using Portenta_H7 Hardware Timers, still work even if other functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software ir ISR-based PWM, using millis(), micros() or Timer Interrupt. This important feature is absolutely necessary for mission-critical tasks. You can start, stop, change and restore the settings of any PWM channel on-the-fly.",
66
"authors":

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Portenta_H7_PWM
2-
version=2.0.2
2+
version=2.0.3
33
author=Khoi Hoang <khoih.prog@gmail.com>
44
maintainer=Khoi Hoang <khoih.prog@gmail.com>
55
sentence=This library enables you to use Hardware Timers on an STM32H7-based Portenta_H7 board to create and output PWM to pins.

platformio/platformio.ini

+23-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
; Please visit documentation for the other options and examples
99
; https://docs.platformio.org/page/projectconf.html
1010

11+
; ============================================================
12+
; ============================================================
1113
[platformio]
1214
; ============================================================
1315
; chose environment:
@@ -27,6 +29,8 @@
2729
default_envs = portenta_h7_m7
2830
;default_envs = portenta_h7_m4
2931

32+
; ============================================================
33+
; ============================================================
3034
[env]
3135
; ============================================================
3236
; Serial configuration
@@ -37,30 +41,38 @@ upload_speed = 921600
3741
;monitor_speed = 9600
3842
;monitor_port = COM11
3943

44+
; ============================================================
4045
; Checks for the compatibility with frameworks and dev/platforms
4146
lib_compat_mode = strict
4247
lib_ldf_mode = chain+
4348
;lib_ldf_mode = deep+
4449

50+
; ============================================================
4551
lib_deps =
4652

47-
53+
; ============================================================
4854
build_flags =
4955
; set your debug output (default=Serial)
5056
; -D DEBUG_ESP_PORT=Serial
5157
; comment the following line to enable WiFi debugging
5258
; -D NDEBUG
5359

60+
; ============================================================
61+
; ============================================================
5462
[env:portenta_h7_m7]
5563
platform = ststm32
5664
board = portenta_h7_m7
5765
framework = arduino
5866

67+
; ============================================================
68+
; ============================================================
5969
[env:portenta_h7_m4]
6070
platform = ststm32
6171
board = portenta_h7_m4
6272
framework = arduino
6373

74+
; ============================================================
75+
; ============================================================
6476
[env:pico]
6577
; ============================================================
6678
; Just a sample
@@ -71,6 +83,8 @@ board = pico
7183
framework = arduino
7284
upload_protocol = picotool
7385

86+
; ============================================================
87+
; ============================================================
7488
[env:ESP8266]
7589
platform = espressif8266
7690
framework = arduino
@@ -116,6 +130,8 @@ board = nodemcuv2
116130
;board = xinabox_cw01
117131
;board = esp32doit-devkit-v1
118132

133+
; ============================================================
134+
; ============================================================
119135
[env:ESP32]
120136
platform = espressif32
121137
framework = arduino
@@ -157,6 +173,8 @@ board = esp32doit-devkit-v1
157173
;board = iotbusproteus
158174
;board = nina_w10
159175

176+
; ============================================================
177+
; ============================================================
160178
[env:SAMD]
161179
platform = atmelsam
162180
framework = arduino
@@ -230,7 +248,8 @@ board = adafruit_itsybitsy_m4
230248
;board = rolawan
231249
;board = seeed_grove_ui_wireless
232250

233-
251+
; ============================================================
252+
; ============================================================
234253
[env:NRF52]
235254
platform = nordicnrf52
236255
framework = arduino
@@ -251,6 +270,8 @@ board = feather52840
251270
;board = ninab302
252271
;board = ninab112
253272

273+
; ============================================================
274+
; ============================================================
254275
[env:STM32]
255276
platform = ststm32
256277
framework = arduino

src/PWM_Generic_Debug.h

+2-7
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@
66
Built by Khoi Hoang https://github.com/khoih-prog/Portenta_H7_PWM
77
Licensed under MIT license
88
9-
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
10-
unsigned long miliseconds), you just consume only one Portenta_H7 STM32 timer and avoid conflicting with other cores' tasks.
11-
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
12-
Therefore, their executions are not blocked by bad-behaving functions / tasks.
13-
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 2.0.2
9+
Version: 2.0.3
1610
1711
Version Modified By Date Comments
1812
------- ----------- ---------- -----------
1913
1.0.0 K.Hoang 21/09/2021 Initial coding for Portenta_H7 using ArduinoCore-mbed mbed_portenta core
2014
2.0.0 K.Hoang 10/12/2021 Use new library code and examples
2115
2.0.1 K.Hoang 11/12/2021 Fix PWM_Multi example. Temporary fix polarity for HRTIM PWM
2216
2.0.2 K.Hoang 07/02/2022 Convert to h-only. Optimize code.
17+
2.0.3 K.Hoang 21/01/2023 Add `PWM_StepperControl` example
2318
*****************************************************************************************************************************/
2419

2520
#pragma once

src/Portenta_H7_PWM.h

+2-7
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@
66
Built by Khoi Hoang https://github.com/khoih-prog/Portenta_H7_PWM
77
Licensed under MIT license
88
9-
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
10-
unsigned long miliseconds), you just consume only one Portenta_H7 STM32 timer and avoid conflicting with other cores' tasks.
11-
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
12-
Therefore, their executions are not blocked by bad-behaving functions / tasks.
13-
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 2.0.2
9+
Version: 2.0.3
1610
1711
Version Modified By Date Comments
1812
------- ----------- ---------- -----------
1913
1.0.0 K.Hoang 21/09/2021 Initial coding for Portenta_H7 using ArduinoCore-mbed mbed_portenta core
2014
2.0.0 K.Hoang 10/12/2021 Use new library code and examples
2115
2.0.1 K.Hoang 11/12/2021 Fix PWM_Multi example. Temporary fix polarity for HRTIM PWM
2216
2.0.2 K.Hoang 07/02/2022 Convert to h-only. Optimize code.
17+
2.0.3 K.Hoang 21/01/2023 Add `PWM_StepperControl` example
2318
*****************************************************************************************************************************/
2419

2520
#pragma once

src/Portenta_H7_PWM.hpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@
66
Built by Khoi Hoang https://github.com/khoih-prog/Portenta_H7_PWM
77
Licensed under MIT license
88
9-
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
10-
unsigned long miliseconds), you just consume only one Portenta_H7 STM32 timer and avoid conflicting with other cores' tasks.
11-
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
12-
Therefore, their executions are not blocked by bad-behaving functions / tasks.
13-
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 2.0.2
9+
Version: 2.0.3
1610
1711
Version Modified By Date Comments
1812
------- ----------- ---------- -----------
1913
1.0.0 K.Hoang 21/09/2021 Initial coding for Portenta_H7 using ArduinoCore-mbed mbed_portenta core
2014
2.0.0 K.Hoang 10/12/2021 Use new library code and examples
2115
2.0.1 K.Hoang 11/12/2021 Fix PWM_Multi example. Temporary fix polarity for HRTIM PWM
2216
2.0.2 K.Hoang 07/02/2022 Convert to h-only. Optimize code.
17+
2.0.3 K.Hoang 21/01/2023 Add `PWM_StepperControl` example
2318
*****************************************************************************************************************************/
2419

2520
#pragma once
@@ -34,13 +29,13 @@
3429
#endif
3530

3631
#ifndef PORTENTA_H7_PWM_VERSION
37-
#define PORTENTA_H7_PWM_VERSION "Portenta_H7_PWM v2.0.2"
32+
#define PORTENTA_H7_PWM_VERSION "Portenta_H7_PWM v2.0.3"
3833

3934
#define PORTENTA_H7_PWM_VERSION_MAJOR 2
4035
#define PORTENTA_H7_PWM_VERSION_MINOR 0
41-
#define PORTENTA_H7_PWM_VERSION_PATCH 2
36+
#define PORTENTA_H7_PWM_VERSION_PATCH 3
4237

43-
#define PORTENTA_H7_PWM_VERSION_INT 2000002
38+
#define PORTENTA_H7_PWM_VERSION_INT 2000003
4439
#endif
4540

4641

src/Portenta_H7_PWM_Impl.h

+2-7
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@
66
Built by Khoi Hoang https://github.com/khoih-prog/Portenta_H7_PWM
77
Licensed under MIT license
88
9-
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
10-
unsigned long miliseconds), you just consume only one Portenta_H7 STM32 timer and avoid conflicting with other cores' tasks.
11-
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
12-
Therefore, their executions are not blocked by bad-behaving functions / tasks.
13-
This important feature is absolutely necessary for mission-critical tasks.
14-
15-
Version: 2.0.2
9+
Version: 2.0.3
1610
1711
Version Modified By Date Comments
1812
------- ----------- ---------- -----------
1913
1.0.0 K.Hoang 21/09/2021 Initial coding for Portenta_H7 using ArduinoCore-mbed mbed_portenta core
2014
2.0.0 K.Hoang 10/12/2021 Use new library code and examples
2115
2.0.1 K.Hoang 11/12/2021 Fix PWM_Multi example. Temporary fix polarity for HRTIM PWM
2216
2.0.2 K.Hoang 07/02/2022 Convert to h-only. Optimize code.
17+
2.0.3 K.Hoang 21/01/2023 Add `PWM_StepperControl` example
2318
*****************************************************************************************************************************/
2419

2520
#ifndef Portenta_H7_PWM_IMPL_H

0 commit comments

Comments
 (0)