Moving code from ESP8266 to ESP32

Image
A while ago I made a mashup of Dan Royer's code CNC 2 Axis Demo with my own code for trapezoidal motion stepper and servo control for ESP8266.

I assumed porting the code to the ESP32 would be trivial, and that was true for the most part: changes like library name being Wifi.h instead of Wifi8266.h were not a problem. UDP now does not like multicharacter writes but you can use print instead. So far so good.

However, when it came to the interrupt code I was stuck with the stepper interrupt causing an exception sometimes. And to make things weirder, the servo interrupt worked flawlessly (both of them had the IRAM_ATTR directive if you ask me).

Going little by little, I could narrow down the culprit to a floating point operation during the interrupt, that would cause problems sometimes but not always. Browsing around I found this post. Where the solution was simple: do not use floats within the interrupt routines but doubles. The reason was the float calculation would be performed by…

Painless transition to El Capitán

My aging desktop computer is a 2011 iMac. When I bought it I loved the concept that would allow me a clean desktop. Truth be told and not iMac's fault, my desktop is almost always a mess despite de computer form factor.

Since I upgraded it to Snow Leopard (mostly for the nee to use a newer version of Java) I have learned about some SMART error on the hard drive. Once I started to feel the pressure of certain application binaries not running because my system libraries were too old, I wanted to upgrade the system but I could not. OSX install would check the hard disk and it will refuse to upgrade if found defective.

Whatever the problem my 1TB is suffering is not killing it for more than two years. And the iMac being the DIY-unfriendly that it is I keep delaying the hard disk replacing. A few months ago I found a spare USB hard disk at home and I used it to install Mavericks on it (yeah, I am not in a hurry to get next memory-hog upgrade). It all worked nicely while I keep on using the internal hard disk too. But one USB less plus another wall wart left me a bit low on available power sockets.

A few days ago I saw a very good offer for 240GB SSD drive and I bite the bullet. Combined with one ElCheapo USB-SATA adapter I got a nice deal. Maybe it is not a top-of-the-line speed-demon but it copies one and a half gigabytes in less than a minute.

I used an old MacBook Pro to download and install El Capitán on the SSD drive. I like being able to use a USB drive as the system unit, a feature I only see on Macs though it might be available in some modern PC motherboards.

But the beauty of it is that I brought the drive home and then use it to boot up my MacBook Air flawlessly too. But that was not the final stop, I just use it to customize the install, add things like Arduino or Chrome. And now, after plugging it in to the iMac and booting from it (OSX uses Cmd key press while booting up to go to boot drive selection) I am writing this entry finally on the iMac. Of course nothing was needed to use the wireless keyboard or mouse that were needing for boot selection or typing the user password. Definitely a much better experience than if I was dealing with other operating system.

And for those Arduino users that like me still bitch about the weirdness of Windows 8.1 Arduino IDE install (to enable non-signed drivers) nothing of that happens here. I even found a signed driver for CH34x USB serial chips found on many Chinese boards. Maybe I will upgrade other systems if the experience continues being positive. I still need to figure out how to get my pictures and music back.

Comments

Popular posts from this blog

VFD control with Arduino using RS485 link

4xiDraw: Another pen plotter

Software I2C for Arduino