Multiple Timers for Tesla coli

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Multiple Timers for Tesla coli

Post by OutoftheBOTS_ » Sun Dec 01, 2019 10:02 pm

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.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Multiple Timers for Tesla coli

Post by jimmo » Mon Dec 02, 2019 12:59 am

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.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Multiple Timers for Tesla coli

Post by OutoftheBOTS_ » Mon Dec 02, 2019 6:26 am

jimmo wrote:
Mon Dec 02, 2019 12:59 am
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.
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 easier :)

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Multiple Timers for Tesla coli

Post by pythoncoder » Mon Dec 02, 2019 7:01 am

That video is well worth a watch. Amazing :D
Peter Hinch
Index to my micropython libraries.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Multiple Timers for Tesla coli

Post by OutoftheBOTS_ » Mon Dec 02, 2019 8:09 am

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 :)

Code: Select all

TIM4->CR1 |= TIM_CR1_ARPE;

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Multiple Timers for Tesla coli

Post by OutoftheBOTS_ » Mon Dec 02, 2019 10:04 am

pythoncoder wrote:
Mon Dec 02, 2019 7:01 am
That video is well worth a watch. Amazing :D
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

User avatar
MostlyHarmless
Posts: 166
Joined: Thu Nov 21, 2019 6:25 pm
Location: Pennsylvania, USA

Re: Multiple Timers for Tesla coli

Post by MostlyHarmless » Mon Dec 02, 2019 11:37 am

Awesome!

Post Reply