I want to create an orchestra of Tesla coils all playing different notes. To do this I need an MCU to be able to create the switching signals at the needed freq of each note being played by each Tesla coil. I am currently using an STM32F407 dev board and programming in C because in C I can program all the timers to create multiple freq at the same time. I am under the impression in MP that only 1 timer is implemented so MP can only create the 1 freq but with multiple channels with different duty cycle.
Is there plans to implement multiple timers in MP??
Check out the project so far https://www.youtube.com/watch?v=gOO4j_kgvTo
It would be way cool if I could build this project in main line MP using simple programming(standard machine module) that anyone can understand without needing a special build or writing to registers like I do in C.
Multiple Timers for Tesla coli
Re: Multiple Timers for Tesla coli
Support for the hardware timers is available in pyb.Timer and pyb.TimerChannel on all STM32 boards.
This API hasn't be abstracted into a common machine API yet...not an easy task which is why there's only support for the "virtual" Timer in machine.Timer on the STM32 boards.
This API hasn't be abstracted into a common machine API yet...not an easy task which is why there's only support for the "virtual" Timer in machine.Timer on the STM32 boards.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: Multiple Timers for Tesla coli
OK I have just checked the docs for the pyb.Timer(timer) and and pyb.Timer.channel(channel, Timer.PWM, pin) and this is exactly what I need This will make building this project much easierjimmo wrote: ↑Mon Dec 02, 2019 12:59 amSupport for the hardware timers is available in pyb.Timer and pyb.TimerChannel on all STM32 boards.
This API hasn't be abstracted into a common machine API yet...not an easy task which is why there's only support for the "virtual" Timer in machine.Timer on the STM32 boards.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Multiple Timers for Tesla coli
That video is well worth a watch. Amazing
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: Multiple Timers for Tesla coli
Once I get it all working I am going to put tubes of different noble gasses near the plasma trail of each Tesla coil as this will cause the noble gasses to turn to plasma of different colours to make a coloured plasma light show with the musical notes.
ATM I am having a little trouble with my C code on my STM32F407 board as sometimes the Tesla coil doesn't play the notes and I though it was a problem with the Tesla coil but when I put my scope on the signal line from my MCU to the Tesla coil it seems sometimes the timer doesn't output the PWM to the pin. I think it has to do with how I am calculating the ARR by first doing the math as float then converting it to an INT to write to the ARR. I am very new to C so still stumbling around in the dark
I will look at getting MP going on 1 of these boards and use the pyb.Timer modules and see if I can get a better result.
Edit: I have found my problem. It is with the buffering of the ARR and because I am playing low freq (hearing range) and short fast notes means sometimes the ARR wasn't getting updated before the next note was sent. I added this line to the C code and now it all works fine
ATM I am having a little trouble with my C code on my STM32F407 board as sometimes the Tesla coil doesn't play the notes and I though it was a problem with the Tesla coil but when I put my scope on the signal line from my MCU to the Tesla coil it seems sometimes the timer doesn't output the PWM to the pin. I think it has to do with how I am calculating the ARR by first doing the math as float then converting it to an INT to write to the ARR. I am very new to C so still stumbling around in the dark
I will look at getting MP going on 1 of these boards and use the pyb.Timer modules and see if I can get a better result.
Edit: I have found my problem. It is with the buffering of the ARR and because I am playing low freq (hearing range) and short fast notes means sometimes the ARR wasn't getting updated before the next note was sent. I added this line to the C code and now it all works fine
Code: Select all
TIM4->CR1 |= TIM_CR1_ARPE;
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: Multiple Timers for Tesla coli
Once I fixed the timer problem that I had it all works much better. I have put some noble gasses above the tesla coil now to make a light show see https://www.youtube.com/watch?v=-upXNRT ... e=youtu.be
- MostlyHarmless
- Posts: 166
- Joined: Thu Nov 21, 2019 6:25 pm
- Location: Pennsylvania, USA
Re: Multiple Timers for Tesla coli
Awesome!