Migrating the code to a faster microcontroller?

188 views
Skip to first unread message

Pablo Vila Ferrero

unread,
Nov 5, 2017, 2:24:33 AM11/5/17
to Mechaduino
While I keep working (suffering) on my high voltage/amperage board, I came across to a relatively new microcontroller that I think it will get quite popular, the ESP32. With its 240MHz and the higher PWM resolution (it has 2 DACs that could be used the set the current in the two coils, but they are only 8bits), we could get faster and smoother operation of the motors.

I'm not an expert in coding, I know few thing beyond standar arduino code (binary operation, direct port manipulaiton...), but I can understand most of the Mechaduino code. I'm wondering if anyone have considered or started working on migrating the Mechaduino code to any other microcontroller.

Cristian Nicola

unread,
Nov 5, 2017, 2:56:53 AM11/5/17
to Mechaduino
an stm32 would probably be a better option. my 2c

Pablo Vila Ferrero

unread,
Apr 15, 2018, 6:25:24 AM4/15/18
to Mechaduino
Been working on the subjet this weekend. Got it compiling and seems that the serial works great.

Had to get rid of the timer interrupts, add new functions and new I/O pins. Couldn't find a way to use direct port manipulation on this board, but measured the digitalWrite function and it takes 120ns.

A couple of interrupts turn on the MOSFETs when the set current is reached, then a specific routine is used at 20kHz (that's common chopping frecuency, will try higher on the future) and turn them ON. Although the MOSFET drivers I was going to use had 500ns deadband, seems to not be enough so I added a small delay when they had to switch directions.

Kai Wolter

unread,
Apr 21, 2018, 2:48:27 PM4/21/18
to Mechaduino
It would be much easier to just use the ATSAMD51. It's running with 120 Mhz (not as fast as 240 MHz) and has nearly the same pinout as the ATSAMD21.
It also features two DAC like the ESP and many other thinks.

I would like to see a version with this chip since we could use the existing pcb (at least neraly) and the code should run on it withot changes. but i'm not able to build my own pcbs.


Reply all
Reply to author
Forward
0 new messages