PTHAT Pick and Place Example using Buffered and Instant Commands on CNC Machine

With this example, we show how to use the PTHAT being used to learn commands for Pick and Place applications.

We have connected the PTHAT to our CNC 800mm x 800mm machine at work as a test.

Within the software you can alter the settings to suit your own CNC machine, such as Pulses per mm on each Axis and speeds.


Within the application you first connect to your Raspberry Pi serial port by clicking the Connect button.

You have a choice of manually adding commands that will be buffered and executed one after the other, or you can jog the machine to the position you require and click the store button to add the command.
For manually adding commands, both Incremental and Absolute modes are supported.

After storing the commands, you can then play them back.

Instant Commands used in this example are:

Set Axis Command

Start Axis Command

Stop Axis Command

Request Current Pulse Count Command

Set Aux Output Command

Set Wait Delay between commands

Toggle Motor Enable Line

Request Firmware Version



Buffer Commands used in this example are:

H Initiate the buffer

Z Buffer Start Command

In this video we show you how to add manual commands or how to use it in learning mode.

We use Instant commands for jogging and for playing the commands back we use Buffered commands. More of this is explained in the video.

The end developer has easily modify this example to build their own application.

The example application was developed in Visual Studio 2015 that can be used with Windows 10 IOT on the Raspberry Pi or compiled to x86/x64 for use on a PC.
The example has been written in C# as a Universal Windows Platform (UWP).

You can either download the compiled program from the Windows App Store on the following link

Or please use the following link to download the full source code.


Closer look at the PCB's