Further to a previous post regarding one Controller approach. This is presented again in
a bit more detail since some experimenters might find it of value as their projects reach a
point where a versatile controller is needed and a quick to assemble device would be appreciated. Controller Development (simplified explaination) Preliminary Rev 0.1 12Sep22
LinGen or Three Phase - using PWM with an STM32 Timer (STM Disco & Nucleo Boards)
NOTE: Achieving a "versatile" Three or Four Channel Pulse Sequencing Controller can be
accomplished with very little cost (<$30us total*) and requires no Programming skills but will
require some video viewing and reading. [* demo cpu and driver/mosfet boards - see below]
At first the approach may appear overwhelming due to STM32_CubeMX however, after a
bit of study, this will evaporate quite quickly, thus exposing a rather simple, elegant, broad
based, and rather fun, application solution! It will form a base from which some cool
"futuristic state-of-the-art" Controllers can be developed.
OverviewBy adding several software lines of code (or one statement duplicated 3 times) to "Main" using
an STM Nucleo demo board and the free STM IDE; four (4), or more, channels of offset control
signals are {easily} created that will accomplish this "Coil Excitation" task.
The focus is on employing the STM32 HAL features in a PCM like application.
You will quickly realize why simply posting a "program" (as seen for many Arduino's)
would be of little value using this approach; but the advantages do become apparent.
These control signals are easily re-configured to suit the development environment, as required.
Additional enhancements such as rotary switches, displays, etc. can also be attached.
Introduction - these videos provide enough information to develop the controller signals:
Don't let yourself get overwhelmed at first - it's a lot easier than you think once you
learn a "few basics" and get a feeling for "how to get around a bit!"
These videos form a brief orientation of sorts:
Mitch Davis youtube search "STM32" ---
watch me first, all 4! https://www.youtube.com/@MitchDavis2/search?query=stm32 [first 4 videos - especially "STM32 Guide #1: Your first STM32 dev board", and
"STM32 Guide #2: Registers + HAL (Blink example)" - plus - "STM32 Guide #3: PWM + Timers" -
{somewhat - timer PWM} related to the target 3 phase generator and Arduino vs STM32 speed. ]
The following videos go directly to the "heart" of this approach which involves:
- Using the free "STM32 CubeMX" IDE, several "Timer" configuration registers are set (using english
readable menus) for your target processor (mounted on a Nucleo or Discovery demo board).
- A bit of simple math or trial-and-error will yield the numbers needed to achieve your desired
timing and sequence scheme.
- After manually adding the "code" to the auto generated "Main" portion of the program to start
the "timers and interupts, etc." (usually two or three short "cook book" lines).
- The Auto-Generated and manually added 'start' code is automatically compiled, down loaded
to the processor and executed.
It's really that simple -- as shown in the example tutorial videos below.
To add a forth channel for the LinGen device simply add one more timer sequence to the 3 Phase
configuration shown below...
How to Generate 3 Phase PWM - Quick Tutorial:
https://controllerstech.com/stm32-timers-6-timer-synchronization-generate-3-phase-pwm/ STM32 TIMERS #6. Timer Synchronization || 3 Phase PWM *** EXTEND TO 4 CHANNELS ***
https://www.youtube.com/watch?v=hMTCX2SMKFU Hands-On with STM32 Timers: Internal Triggering System (by STMicroelectronics)
https://www.youtube.com/watch?v=QMAgD9SS5_E STM32 TIMERS #5. Master Slave Synchronization using the TRIGGER MODE
https://www.youtube.com/watch?v=a1ynzt_RVww&list=PLfIJKC1ud8gjLZBzjE3kKBMDEH_lUc428&index=10 Lecture 13: Timer PWM Output (by Embeded Systems and Deep Learning)
https://www.youtube.com/watch?v=zkrVHIcLGww Eddie Amaya (STM32 - general Timers and detailed PWM MODE with important INFO)
https://www.youtube.com/user/sdf3e33/search https://www.youtube.com/watch?v=qAZjdx71ePc [important info and PWM Mode]
DeepBlue - STM32 PWM Example – Timer PWM Mode Tutorial (with formulas & examples)
https://deepbluembedded.com/stm32-pwm-example-timer-pwm-mode-tutorial/ Target Device: STMF446RE Nucleo-64 development board (Budgetary Price 14.00 US$)
https://www.st.com/en/evaluation-tools/nucleo-f446re.html#overview One of the Discovery boards I use (< $60US):
Discovery kit with STM32F746NG MCU (includes LCD with Touch Screen)
https://www.st.com/en/evaluation-tools/32f746gdiscovery.html There are many much cheaper Discovery and Nucleo development boards available.
Encoder Timer Interface (Rotary Encoder)
STM32 Timer Encoder Mode – STM32 Rotary Encoder Interfacing
https://deepbluembedded.com/stm32-timer-encoder-mode-stm32-rotary-encoder-interfacing/ ((

)) Interface a Rotary Encoder the right way.
https://www.edwinfairchild.com/2019/04/interface-rotary-encoder-right-way.html Driver - MOSFET 4-Channel MOSFET board with optional driver (inexpensive Driver/MOSFET board):
https://www.tindie.com/products/drazzy/4-channel-mosfet-board-with-optional-driver/#product-description [might be a good substitute for expensive SiC FETs and drivers at about $4us per channel]
Appendix
AN4776 Application note "General-purpose timer cookbook for STM32 microcontrollers"
file:///C:/Users/admin/Downloads/en.dm00236305.pdf
STM32 PWM basics
https://www.youtube.com/watch?v=K0_hfbT7vWA HAL #8: HowTo - Timer PWM
https://www.youtube.com/watch?v=quZWGSEMyD0 Getting Started with STM32 and Nucleo Part 6: Timers and Timer Interrupts | Digi-Key Electronics
https://www.youtube.com/watch?v=VfbW6nfG4kw HES LinGen Pole Timing - from original Patent
(see attachment)
This Controller design approach allows easy adjusting/tuning of the timing and sequencing as
the development progresses. As the project matures, this approach can be enhanced as required.
Enjoy, Good Luck and Have a Great Day!
SL