Posts

Showing posts from March, 2015

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…

One Arduino controlling two brushless DC motors

Image
After some changes I have been able to get it working reliably with two motors. But one of the changes I have made is to use a new type of motors that I reckon are better suited to the task. Instead of using brushed motors that are cheaper, I have found these other brushless motors that have several advantages:  Being brushless there is no other wear than the bearingsThey have built-in driving electronics, so they can be controlled with the Arduino digital outputs, that simplifies things and reduces interface cost. Motors have built-in encoder disk too, but the one they carry is just 100 lines per revolution (a bit poor in my opinion) that can turn into 400 "steps" per revolution with the 4x decoding of the program. The lower number of lines per revolution puts less stress on the Arduino interrupt code, which may be one of the reasons it works ok now.I have moved all the encoder signals to pins that are monitored with the interrupt on pin change and I have reserved the two e…

Moshidraw: pain on every laser cut

Image
I have been using a [cheap] laser cutter machine. You can see which one on the following video.



Till now it kind of works but what is really annoying is the software you have to use to be able to cut and engrave. It is called Moshidraw and for reasons I cannot really understand it comes with a USB dongle for protection (it will not run without it).  Not in a million years I would like to copy such a program.

This is what I have learned so far that causes trouble:

If you DXF file contains curves, the operation will fail randomly (suddenly the cut will take an unexpected route and it will ruin your stock material).If you import a DXF and fail to select the part, the cut will did not work properly.If you have several parts in DXF, it may fail at any point (mostly when it is almost finished and all your stock material will be ruined). Best results and lower risk if you do multiple parts one at a time.There not seem to be a way to force inside cuts first, so some operations will fail as the…