Showing posts from December, 2005

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…

Old signals

I was recently approached by a company willing to give new life to old security equipment. The system had a proprietary serial bus, but the manufacturer refused to disclose any information about it. Provided it was more than twenty years old it should not be a big challenge.

However, figuring out the details of a serial communication you know nothing about will require some nice tools. This time I bought a nice USB oscilloscope. It's only 1 Mhz bandwith but fast enough for my needs in this case. With it I was able to capture bidirectional communication (as it is dual channel) and start the process of figuring it out.

Just looking at the scope signals will tell you the encoding and bitrate (look for the shortest pulses, they are likely single bits and its time-length will tell you the bitrate). Serial communication used to be mostly asyncrhonous, and this was also the case. Once the time duration of a bit known you can figure out the data length and wether parity is being used or no…