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…

Random rant of the day

A couple of details made me waste some time till I figured them out. First one was an issue with povray 3.7 running on Linux that would preview a black background when I wanted a transparent background. Output was a PNG file and the final result was ok, but I failed to notice that there was an error with the command temporary output to the display and not with the final rendered file. I noticed the problem once I ran the same command with the same files on my Mac and preview shown the checkered pattern of a transparent background.

used with permission

But this does not mean the Mac versions are any better: Second problem, using Meshab 2016.12 version it was impossible to get a snapshot with a transparent background either. It appears it is a known issue too.  Same version of Meshlab but running in Ubuntu worked like a charm.

I had a third problem I can only blame myself for: it turns out STL files and Povray use a different coordinate space, so my renders appeared flipped horizontally. Nothing that ImageMagick cannot fix (convert -flop).  And yes, y-axis is up on povray, so instead of figuring out how to fix that there I just rotated the rendered bitmap so it looks z-axis is up instead.


Popular posts from this blog

VFD control with Arduino using RS485 link

4xiDraw: Another pen plotter

Software I2C for Arduino