PDA

View Full Version : PyCNC - first CNC machine controller on pure Python for Raspberry Pi.



Nikolay-Kha
14-05-2017, 10:16 PM
Hello!
I'd like to present first ever CNC machine controller implementation on pure Python(even without dependencies or any C modules) for ARM based Linux boards. Hardware access layer(HAL) allows to implement support for almost any ARM SoC/CPU with suitable DMA module, but currently it is implemented for Raspberry Pi only. It already works on Raspberry Pi 2 and 3.

Typically, CNC machine controllers are implemented with C or C++ programming language and running on OSless or very real time operation systems. For example, Linux by default is not real time operation system and running LinuxCNC on it require to add special real time features to kernel. I believe that is very old approaches for building such controllers and it's high time to use modern ARM processors for CNC and use very high level programming languages like Python to provide easy development, flexibility and migration between hardware.

I managed to do this! First ever CNC controller implemented on pure Python on Raspberry Pi 2 running Linux, it's better to see, than read:

https://youtu.be/vcedo59raS4

How it works? It uses DMA(Direct Memory Access) on chip hardware module, which just copy allocated in RAM buffer of GPIO states to actual GPIO registers. And this copying process is clocked by system clock and works completely independently from CPU cores. So, I was needed just to generated pulses sequence for axis stepper motors in memory and DMA precisely sends it. As for access to processor registers, it's implemented with /dev/mem system device. That can be implemented with different languages, but Python is very simple language which provides better development experiences. Of course, Python performance is not good, but on the other hand, modern ARMv7 processor performance is more than enough to run it.

And the most pleasant part, I open sourced this project!
Project is here - https://github.com/Nikolay-Kha/PyCNC
There is a wiring diagram and running instructions in git repo.
It's just a begging of this project, currently, it supports just simple things - spindle control, linear interpolation and some basic gcode commands. I have plans in near feature to add round interpolation, 4th axis, temperature sensors, heaters support and implement fully functional 3D printer CNC controller.

Thank you for reading, hope it was interesting for you.

Nikolay-Kha
15-07-2017, 11:23 AM
Hello!
Great news! PyCNC has full 3D printer implementation. Version 1.0.0 is released.

Also I made a hardware with RerRap Prusa i3, RAMPSv1.4 board and Raspberry Pi3. Circuit diagram and photos in repo's README.md file - https://github.com/Nikolay-Kha/PyCNC.

First 3D model was printed on this video -

https://youtu.be/41wdmmztTNA

Overall PyCNC supports:
- 4 axis - X, Y, Z, E;
- Linear interpolation;
- Circular(in XY, ZX, YZ planes) interpolation;
- Minimum end stops and homing procedure;
- Extruder and bed heaters;
- Spindle for engraving.

EddyCurrent
15-07-2017, 01:53 PM
Interesting and good work. I also posted a link to this thread here; http://www.cambam.co.uk/forum/index.php?topic=6710.msg54310#msg54310

This thread might interest you; http://www.cambam.co.uk/forum/index.php?topic=6482.msg51798#msg51798 (GRBL v1.1 Machine Control and GCODE sender Plugin)

What about this ? https://2013.spaceappschallenge.org/project/arduino-raspberry-pi/
would it then run Marlin Firmware ?