Feb 02

Windows 10 Will Support Raspberry Pi 2

As if the news about the next generation Raspberry Pi wasn’t exciting enough Microsoft just announced that Windows 10 will support for the new Raspberry Pi. This is all part of Microsoft’s  Windows Developer Program for IoT that already supports a stripped down version of Windows on Intel’s Galileo. Gotta say the potential for working with a Raspberry Pi with remote PowerShell is pretty awesome. I’m hoping to see some GPIO control cmdlets. If you’re not already registered you can sign up here.

Jul 29

Using Raspberry Pi to Control a TinyG ShapeOko

When I put together my ShapeOko CNC I decided to use a TinyG as the controller. It’s a great board with a lot of support behind it, however the TinyG is strictly a controller for the mill’s motion. The G-Code commands need to be read in though a serial connection and it only has a buffer of 255 characters which means it requires that a computer be connected to send the commands. Instead of leaving my laptop with the ShapeOko I decided to use a Raspberry Pi for this purpose. Most of the documentation around the TinyG is based on Windows or Mac; there is not much info on using it with Linux. This is currently the way I’m using the Raspberry Pi to control the TinyG.

Finding the Serial Port

The first thing you need to do is find which serial port the TinyG is on. The easiest way to find it is by running the command:

dmesg|grep FTDI

It will respond with something similar to this:
I’ve highlighted the line you should look for. Unless you have another USB to serial device connected (like an Arduino) yours should also show up as “/dev/ttyUSB0″. In the following examples the assumption is that this is the address for the TinyG. If yours is different then you may need to change the commands below.

Putty and Plink

The commonly recommended program to communicate with the TinyG is a freeware (not open source) program called CoolTerm. It does have a Linux version however it is compiled for x86 processors so it will not run on a Raspberry Pi’s ARM CPU. An alternative program that can do the job and will be familiar to at least a few IT people is Putty. It is a free, open source terminal emulator and serial console for Windows and Linux. Putty is a GUI based program and it can be used, however I find it easier to use the command line version: Plink.

One of the benefits of using Putty is that it supports XON/XOFF flow control protocol. As I’ve mentioned, the TinyG can only buffer up to 255 characters before erratic behavior, missed lines and other trouble start cropping up. TinyG utilizes XON/XOFF to tell the sending computer to stop sending commands when its buffer is almost full and continues when it gets below a certain level.

Install Putty and Putty Tools

Putty is available in the Debian based software repositories (this includes Raspbian and Ubuntu). You can install Putty and Plink on a Raspberry Pi with this command:

sudo apt-get install putty putty-tools

Open the Serial Console

To connect directly to the TinyG using the command line version use this command:

plink -serial /dev/ttyUSB0 -sercfg 115200,8,n,1,X

This will open an interactive serial console that can send and receive commands. From here you can fully interact with the TinyG.

Stream G-code Files

The next step once you’ve configured all your settings and run some simple commands is to be able to send a whole file of G-code to the ShapeOko. You can do this by piping the file to plink like this:

cat project.nc | plink -serial /dev/ttyUSB0 -sercfg 115200,8,n,1,X

In this example the file “project.nc” would contain a series of G-code commands and plink would send those to the TinyG.

Exiting Plink

The shortcut to exit plink is CTRL+C. You can also use CTRL+Z but this simply suspends the program instead of closing it (Explanation of the difference between CTRL-C and CTRL-Z in Linux CLI).

Next Steps

The method above will give you the basic ability to directly communicate with the TinyG or stream of G-code into the TinyG, however it doesn’t give you a visual interface and you still need to find a way to get the G-code files to the Raspberry Pi. I started writing a web interface based on PHP and have spoken with Alden from Syntheos who invited me to help with their NodeJS based web interface, hopefully I will have more on this in the near future.