As I wrote in the description, I want to write as little code on the microcontroller as possible. Since I learned coding in Python, programming in C/C++ just feels tedious and I want to minimize it. So the idea was to do all complicated calculations in language that I like more, like Python or Nim (which is awesome!).
As far as my understanding goes, usually gcode is sent to the microcontroller, which uses some variation of Bresenhams algorithm to calculate the timings for the stepper motors.
My Idea is to instead calculate all the timings on the computer and send them to the microcontroller which stores them in a buffer and uses a timer to step the motors. For this, one needs fast serial connection and this is one reason why I chose to use a teensy for this project.
The communication protocol for filling the buffer of the microcontroller with n timings looks like this:
size | function | example/description |
---|---|---|
byte | command | 'b' , for filling the 'b'uffer |
byte | axis | 'a' , for the upper stepper |
float | timing 0 | 0.0001 seconds |
byte | action 0 | 'd', lowering the pen |
... | ... | |
float | timing n | 0.0005 seconds |
byte | action n | 'u', lifting the pen |
So there are two buffers, one for either stepper, that get filled independently. And the buffers hold the time in seconds until the next step should be done and some action that should be done at that point in time.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.