Moving code from ESP8266 to ESP32

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…

Some interesting tools

My last project dealt wih the use of 1U rack-mounted PCs. Once the software was ready for deployment I needed to find an easy way to get the operating system and applications loaded onto the systems and I was looking for an easy and fast way of doing it.

The units I am using are manufactured by Supermicro and they have no floppy or CD-ROM but are equipped with dual Gigabit Ethernet ports and USB 2.0. While booting the system up from a USB CD-ROM was possible this was leaving me with the task of manually configuring each unit.

I've used in the past Symantec's Ghost software for harddisk clonning and I've found it quite useful. But to be able to use it in this case I would need to boot these computers out of a floppy disk or specially crafted CD-ROM that I don't have ready. On the other hand, a Ghost license will need to be purchased.

Browsing around I've found a couple of projects G4U (Ghost for Unix) and G4L (Ghost for Linux) that offer you a ready to burn ISO image. You boot up your system and you have network support (Ethernet) and some basic tools to recover (or to send) a harddisk image from (to) a server so you can clone disks quite easily through the network.

As in my project I needed to boot the system and get the OS and apps installed, I can boot up off the CD-ROM and get the disk contents from my FTP server. The whole operation takes around 4 minutes over Fast Ethernet (used disk size has a big impact on this time, as you can guess).

If you have some time to spare you can follow the thread on both tools websites where G4U 's author complains of G4L 's plagiarism.

If your code does not change very often and you disk image is not very big you might want to copy all together in a single CD-ROM or DVD-ROM so you don't need to use the network nor an FTP server. Although in this case you will notice that both drives provide lower throughput than a network link and therefore the clonning process can take longer.

I've recently got a 60GB USB 2.0 bus-powered TEAC harddisk and an LG 1GB USB 2.0 pen drive, I've been looking around for alternative ways of booting up computers. Booting off a USB seems quite interesting to me. I've found that St. Petersburg Linux does exactly this. But if you have more space on your USB drive you can even boot up Knoppix.


Popular posts from this blog

VFD control with Arduino using RS485 link

4xiDraw: Another pen plotter

Software I2C for Arduino