Posts

Showing posts from December, 2014

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…

Closed-loop DC motor to act as a stepper motor

Image
One of the things that I hate the most about 3D printing is that these machines are usually working in open loop and, sometimes, a tiny error happens that ruins a long print. Most 3D printers use one or more stepper motors to move each axis. Steppers are a good solution to the problem, they are easy to control and have lots of torque (compared to similar sized DC motors) but they may skip a step occasionally. The problem then is the print head is no longer where it is supposed to be but slightly off. From there on the print is misaligned and most likely will be useless.

Any type of motor can be equipped with an encoder to check its location at any time. However that adds an additional cost to the equipment and requires extra software to handle this new information.

One idea that has been mentioned many times in RepRap forums is that if steppers were replaced by DC motors with encoders that will allow the accurate position control that offer the steppers, the machines could be made mor…