GRBL CNC
https://github.com/gnea/grbl
Python Streaming Scripts (Officially Supported by Grbl) [Cross-Platform]
NOTE: If you are having difficulties with streaming to Grbl, we will ask you to use this Python streaming script to eliminate the GUI you are using as the source of the issue. Before posting to the issues thread, please use this script to run your G-code program.
Included with the source code and officially supported by Grbl, two Python streaming scripts are supplied to illustrate simple and more complex streaming methods that work well cross-platform. These scripts don't fully support all of the Grbl's features, but are intended more as a way to compare or troubleshoot other garden variety or newly-written GUIs out there. These are located in the 'script' folder on the main repository. Note: The streaming scripts require the pySerial module installed.
- Install the pySerial module.
- Download simple_stream.py Python script.
- Open the script in a plain text editor and change the following line to reflect your system:
s = serial.Serial('/dev/tty.usbmodem1811',9600)
- In place of /dev/tty.usbmodem1811(Mac), you should put the serial port device name of your Arduino. This will be different for each machine and OS. For example, on a Linux system this would look like /dev/ttyACM0. Or on a Windows machine, this may look like COM3.
- The script looks for and reads gcode from a file named grbl.gcode, you should create this file and put the gcode you want to execute in it. Or simply change this name in the script to your needs.
- Open a terminal/command window and change directories to the location of the Python script and execute the Python script with the following command:
./simple_stream.py
(Mac/Linux) python simple_stream.py
(Windows)
- You should now see the gcode being streamed to grbl along with 'ok' messages and your machine should begin moving.
The other, more advanced streaming script stream.py has command line arguments and does not require modifying the script itself, unlike simple_stream.py. The main difference is that stream.py uses a character counting scheme to ensure that Grbl's serial read buffer is full, which effectively creates another buffer layer on top of Grbl's internal motion queue. This allows for Grbl to access and parse the next G-code block immediately from the serial read buffer, rather than wait for the 'ok' send and response in the simple_stream.py script. This is very useful for motions, like curves, that have very rapid, short line segments in succession that may cause buffer starvation, which can lead to strange motion hiccups. In other words, it ensures a smoother motion. Use this script, if you are not afraid of command line or are experiencing weird motions.
No comments: