New experimental firmware: all kinematics in host May 25, 2016 01:11PM |
Registered: 14 years ago Posts: 107 |
Re: New experimental firmware: all kinematics in host May 26, 2016 02:55AM |
Admin Registered: 13 years ago Posts: 7,124 |
Re: New experimental firmware: all kinematics in host May 26, 2016 03:46AM |
Registered: 13 years ago Posts: 1,236 |
Re: New experimental firmware: all kinematics in host May 26, 2016 02:10PM |
Registered: 14 years ago Posts: 107 |
Quote
Dust
A forth hand is also mumbling that 8 bit arduino is dead and your flogging a dead horse. But there is nothing stopping this working on 32 bit machines
Re: New experimental firmware: all kinematics in host May 26, 2016 05:38PM |
Registered: 10 years ago Posts: 14,684 |
Quote
KevinOConnor
Klipper is a new experimental firmware! It is designed to run on both a micro-controller and a low cost host computer such as a Raspberry Pi. The host does all the work of determining how and when to move each stepper motor, it compresses that information, and sends it to the micro-controller. The micro-controller then uncompresses the given schedule and executes it at the specified times. The same host computer can be used to run both Klipper and OctoPrint.
There are several advantages to splitting work between a micro-controller and a host machine:
* It is fast. On a 16Mhz AVR micro-controller, Klipper can reach 90K steps per second. (On a 20Mhz chip, 110K steps per second.)
* It has more reproducible results. Other firmware (in particular ones running on slower AVR chips) can cause print stalls due to CPU bottlenecks or serial port communication issues. Klipper specifies exact event times which leads to more reproducible prints. (In the unfortunate event of a severe communication outage between host and micro-controller, the Klipper micro-controller code would detect the outage and cancel the print.)
* The code is more portable. The micro-controller code (written in C) is small and focused, and should be easier to port to new micro-controller architectures. The host code (written in Python and C) is not hardware specific. Indeed, the most interesting code - the kinematics, the acceleration, the lookahead algorithm, the PID - are written in Python.
* It does not use the Bresenham algorithm or similar kinematic estimations. Instead, Klipper calculates precise event times using full 64bit floating point math (even a low cost Raspberry Pi has full hardware support for 64bit doubles). It is hoped that this will facilitate novel acceleration, extrusion, and kinematic designs.
The code is available at:
https://github.com/KevinOConnor/klipper
The code is in an experimental state. It currently works with Atmel ATMega micro-controllers and with OctoPrint running on the same Raspberry Pi computer. I have been regularly testing it on my RAMBo based cartesian 3d printer. However, it is possible some quirks or bugs may appear. For those willing to experiment, I am interested in hearing the results of tests and feedback from those tests.
Re: New experimental firmware: all kinematics in host May 26, 2016 06:15PM |
Registered: 9 years ago Posts: 978 |
Re: New experimental firmware: all kinematics in host May 26, 2016 06:50PM |
Registered: 14 years ago Posts: 107 |
Quote
frankvdh
I'm curious about the 64-bit timing... I suspect that timing information could be left out of the protocol, and just steps sent to the AVR. The AVR should be able to work out the accelerations and therefore pulse timings itself, knowing the max acceleration and speed of each stepper.
Quote
frankvdh
Another thought I had was that a whole series of steps could be defined by some kind of polynomial. That would be simple and quick for the AVR to calculate exact timings, and give maximum compression of data transmission to the AVR.
Quote
frankvdh
I guess that to make this system work, the host end would need to know printer-specific things like steps/mm in each axis, and also bed-levelling information. Does your protocol get that information from the printer, or does it need to be manually entered into the host?
Re: New experimental firmware: all kinematics in host May 26, 2016 08:11PM |
Registered: 9 years ago Posts: 978 |
Re: New experimental firmware: all kinematics in host May 26, 2016 10:28PM |
Registered: 14 years ago Posts: 107 |
Quote
frankvdh
Is there any reason not to download the Klipper data to a file on the SD card on the printer, and then print from there? That would allow stand-alone printing. Although that wouldn't be a big deal for someone printing from a RPi, it would mean that a desktop machine could be turned off once the file had been transferred. Someone without a connection between their desktop & printer could still use Klipper. And it might also be useful for testing & debugging.
Quote
frankvdh
How do I print some arbitrary .STL (or whatever) file using Klipper? Does it need a conventional slicer to generate G-code which is then read to make the Klipper data?
Quote
frankvdh
Is there a manual or Wiki or something like that?
Re: New experimental firmware: all kinematics in host May 27, 2016 11:55AM |
Registered: 14 years ago Posts: 107 |
Quote
dc42
So I think the idea of calculating the kinematics on a host PC been overtaken by the availability of low-cost 32-bit processors, which now cost less than high pin count 8-bit processors such as the atmega2560.
Quote
dc42
But your code may be interesting to existing Arduino/RAMPS/RPi/Octoprint users who are looking for better movement algorithms without upgrading the hardware.
Re: New experimental firmware: all kinematics in host May 28, 2016 12:08PM |
Registered: 14 years ago Posts: 7,616 |
Quote
KevinOConnor
I think a truly portable firmware would be a great thing to have.
Generation 7 Electronics | Teacup Firmware | RepRap DIY |
Re: New experimental firmware: all kinematics in host May 29, 2016 08:41AM |
Registered: 14 years ago Posts: 7,616 |
Generation 7 Electronics | Teacup Firmware | RepRap DIY |
Re: New experimental firmware: all kinematics in host May 30, 2016 07:55PM |
Registered: 14 years ago Posts: 107 |
Quote
Traumflug
Had a look at the firmware code now. Nice work! Quite readable once one groks this DECL_... mechanism.
Quote
Traumflug
Of course I'm curious how klipper manages to about double the maximum step rate compared to Teacup. After reading sources I think it's because there is no stepper motor synchronisation. At least I can find none. Each movement command is for one stepper only, so the only synchronisation is that the host sends commands in a tight sequence.
Quote
Traumflug
Now, assuming that such a command is 6 bytes, it takes about ((8 data bits + 1 stop bit) * 6 bytes) / 250000 baud = 0.224 ms to send a command. A movement involving 3 steppers (quite common: X, Y, E) has an offset of 0.448 ms or, at 100'000 steps/seconds, of 44 steps. Being 44 steps off track is quite a bit for my taste.
Quote
Traumflug
That said, I do see chances for klipper. It could learn synchronized movements. Adding acceleration, too, would make it very similar to the original RepRap firmware, but that's not neccessary. For acceleration, one update every 2 ms is sufficient. Then it's similar to Teacup firmware with ACCELERATION_TEMPORAL, which currently does neither acceleration nor lookahead, but evenly distributes all participating steppers like klipper. It'd need a parser for the klipper protocol, of course.
Re: New experimental firmware: all kinematics in host May 30, 2016 09:43PM |
Registered: 9 years ago Posts: 978 |
Quote
KevinOConnor
So, the commands are received (and queued) well in advance of the actual stepper movement. On my atmega2560 based RAMBo printer, the "move queue" can hold up to 646 of these stepper sequences in ram. In practice this means the command stream is almost always several seconds ahead of the actual stepper events. (Should some severe communication issue cause a queue under-run then the mcu would detect that and cancel the print.)
Re: New experimental firmware: all kinematics in host May 31, 2016 05:28AM |
Registered: 14 years ago Posts: 7,616 |
Quote
KevinOConnor
You are correct that stepper movement is accomplished with the "queue_step" command and that this command only controls the steps for a single stepper. However, the steps are synchronized with other stepper motors. The synchronization is done by virtue of the clock offset that is implicit in the queue_step command.
Quote
KevinOConnor
I think you may have incorrectly concluded that the queue_step command starts issuing steps relative to when the command is parsed.
Quote
KevinOConnor
The host determines when to step each stepper motor (in Move.process), those steps are compressed (into a series of quadratic functions), sent to the mcu (as queue_step commands), and then the mcu pulses the stepper at the specified times (via the stepper_event timer). I don't think it is similar to ACCELERATION_TEMPORAL.
Quote
frankvdh
If not, then a simple queue under-run should just result in a pause rather than cancellation of the print.
Generation 7 Electronics | Teacup Firmware | RepRap DIY |
Re: New experimental firmware: all kinematics in host May 31, 2016 10:24AM |
Registered: 14 years ago Posts: 107 |
Quote
frankvdh
Quote
KevinOConnor
So, the commands are received (and queued) well in advance of the actual stepper movement. On my atmega2560 based RAMBo printer, the "move queue" can hold up to 646 of these stepper sequences in ram. In practice this means the command stream is almost always several seconds ahead of the actual stepper events. (Should some severe communication issue cause a queue under-run then the mcu would detect that and cancel the print.)
In the case of an object which is very irregular and organic in shape (and consequently doesn't model well to your quadratic model), and very detailed, could the printer consume commands faster than they can be sent to it? Either due to slow calculation by the host, or insufficient comm bandwidth? I.e. once printing has started, can you *guarantee* that the queue won't become empty until the item is finished? If not, then a simple queue under-run should just result in a pause rather than cancellation of the print.
Re: New experimental firmware: all kinematics in host June 01, 2016 01:16AM |
Registered: 9 years ago Posts: 978 |
Quote
KevinOConnor
Quote
frankvdh
In the case of an object which is very irregular and organic in shape (and consequently doesn't model well to your quadratic model), and very detailed, could the printer consume commands faster than they can be sent to it? Either due to slow calculation by the host, or insufficient comm bandwidth? I.e. once printing has started, can you *guarantee* that the queue won't become empty until the item is finished? If not, then a simple queue under-run should just result in a pause rather than cancellation of the print.
There are no guarantees or warranties. Klipper is free software.
Re: New experimental firmware: all kinematics in host June 01, 2016 05:12PM |
Registered: 10 years ago Posts: 293 |
Re: New experimental firmware: all kinematics in host June 01, 2016 11:53PM |
Registered: 14 years ago Posts: 107 |
Quote
WZ9V
This sort of architecture sounds perfect for a BeagleBone assuming you could adapt the stepper/endstop/thermistor code to run on its two PRU's.
Re: New experimental firmware: all kinematics in host June 14, 2016 04:18PM |
Registered: 14 years ago Posts: 107 |
Re: New experimental firmware: all kinematics in host September 05, 2016 05:18PM |
Registered: 11 years ago Posts: 580 |
Quote
Paul W
Instead of interpreting gcode and sending step pulses, a multi-core master controller (like a Pi 3) could send "motion frames" to slave controllers (like 1GHZ Pi Zeros running bare metal, $5 each).
Think of a Pi-3 plugged into a daughter board that has a row of Pi-Zeros socketed into it, each controlling multiple socketed or on-board stepper drivers...
The motion frames would contain pre-computed speed, # of steps, and acceleration profiles. Running without interrupts the bare metal Pi Zeros could supply the step pulses without jitter.
Of course the same thing could be done for Reprap printers. You would need to change the gcode motion planner module to run on a PI, and output motion frames, and program the Pi Zeros to communicate with it and process the motion frames into pulses...
And that could cost more than the existing boards that are already working well. It would however allow very high performance, graphical interfaces, a real operating system (Linux), fast communications, and a continual upgrade path with new Pi models.
Re: New experimental firmware: all kinematics in host September 05, 2016 09:25PM |
Registered: 14 years ago Posts: 107 |
Quote
Paul Wanamaker
Kevin,
This is very good work!
As I have just written in another place, I've been thinking of a scenario for this kind of thing - for a robotics project with a great number of motors.
Quote
Paul W
Instead of interpreting gcode and sending step pulses, a multi-core master controller (like a Pi 3) could send "motion frames" to slave controllers (like 1GHZ Pi Zeros running bare metal, $5 each).
Think of a Pi-3 plugged into a daughter board that has a row of Pi-Zeros socketed into it, each controlling multiple socketed or on-board stepper drivers...
The motion frames would contain pre-computed speed, # of steps, and acceleration profiles. Running without interrupts the bare metal Pi Zeros could supply the step pulses without jitter.
Of course the same thing could be done for Reprap printers. You would need to change the gcode motion planner module to run on a PI, and output motion frames, and program the Pi Zeros to communicate with it and process the motion frames into pulses...
And that could cost more than the existing boards that are already working well. It would however allow very high performance, graphical interfaces, a real operating system (Linux), fast communications, and a continual upgrade path with new Pi models.
Re: New experimental firmware: all kinematics in host September 07, 2016 11:29AM |
Registered: 8 years ago Posts: 3 |
Re: New experimental firmware: all kinematics in host September 08, 2016 09:40AM |
Registered: 14 years ago Posts: 107 |
Quote
shadowjack
Please consider using not quadratic, but cubic curves - to implement real jerk limiting/S-shape acceleration profile.
Great project, I was thinking about doing similar myself.
Also with this architecture it's easy to use FPGA as controller - it can achive tenth of millions of steps per second if there is need for such speeds.
Re: New experimental firmware: all kinematics in host September 08, 2016 01:42PM |
Registered: 8 years ago Posts: 3 |
Re: New experimental firmware: all kinematics in host September 08, 2016 02:37PM |
Registered: 14 years ago Posts: 107 |
Quote
shadowjack
Do you really need to convert some geometry + acceleration profile - > steps - > quadratic (cubic) functions of t - > steps?
Quote
shadowjack
After first conversion to steps you loose some information.
Quote
shadowjack
Maybe skip it and convert to cubic functions directly? At least that's what I was planning to do.
As to possible compression algorithm I can think of splitting step series in some segments (0.1 sec) and trying to fit cubic curve to it using least squares. If error > epsilon split interval in two. Can be split in the middle or some other point using some metric. Then do recursion for each part.
Re: New experimental firmware: all kinematics in host October 24, 2016 11:31AM |
Registered: 9 years ago Posts: 1,873 |
Re: New experimental firmware: all kinematics in host October 24, 2016 12:26PM |
Registered: 14 years ago Posts: 107 |
Quote
JamesK
I find this approach very appealing. How is the project coming along - would you rate it as usable now, or still at the proof of concept stage?
Quote
JamesK
Feature-wise, does it compare with marlin or repetier firmware in terms of being able to control fans for the electronics and hotends?
Quote
JamesK
Where does the low frequency code for things like fans and heaters live, is that on the host side or the mcu? I guess if it's on the host you then have to either interface to the sensors from the application processor, or provide a protocol for passing the readings from the mcu to the application processor.
Quote
JamesK
Is there support for a local interface on an LCD, either connected to the mcu or the RPi (or I guess both if it's useful)?
Re: New experimental firmware: all kinematics in host October 24, 2016 09:01PM |
Registered: 9 years ago Posts: 1,873 |
Re: New experimental firmware: all kinematics in host November 15, 2016 08:38PM |
Registered: 11 years ago Posts: 580 |