Using with the Raspberry Pi


The Raspberry Pi is a series of credit card-sized single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and in developing countries.The original model became far more popular than anticipated, selling outside of its target market for uses such as robotics.

The PTHAT has been designed to fit directly onto the Raspberry Pi expansion connector and complies to the Raspberry Pi HAT specifications.

More information can be found at the official site

Development Platforms

The Raspberry Pi can run a number of different operating systems and the popular one is RASPBIAN JESSIE WITH PIXEL .

This is Linux with a Windows GUI and has a number of different development options, with Python being the main one used by devlopers.

Check out the official site for more information and image downloads. 

Windows 10 IoT Core is a new edition of Windows targeted towards small embedded devices and maker boards such as Raspberry Pi2 or Pi3. IoT core is designed to work with low-level bus interfaces such as Serial, I2C, SPI, USB. You can write a Universal Windows Application using a variety of programming languages in Visual Studio to rapidly create maker projects.

Running a dedicated application in a Windows 10 sandbox is pretty cool and more information can be found on the following link which includes how to setup the development environment for your Raspberry Pi

Using the PTHAT with Windows 10 IoT Core.

We have created an example application using Visual Studio 2015 that can be used with Windows 10 IOT.
The example has been written in C# as a Universal Windows Platform (UWP).

This allows you to send commands using the serial port and covers the Instant Commands that are shown on the Command Set Page. Also it automatically formats the commands to the correct syntax. 

Please use the following link to download the full source code. 

To go through every step of setting up Visual Studio 2015 development environment with Windows 10 IOT is a big task and no point repeating it here as there is already good existing information.
A good starting place is Microsoft’s own site

Once you have your Raspberry Pi computer setup with the Windows 10 IOT image and Visual Studio configured, the you will be able to simply load the example application we have provided and start to send commands back and forth to the PTHAT.

When you launch the application it should enumerate the serial ports on your Raspberry Pi and list them in the top box.

1.) Highlight the Serial Port.

2.) Click the Connect button.

Once connected you will find that all the buttons at the bottom of the application will become enabled and the Read Data box will display Waiting for data..
You are now ready to send commands.

Each Axis has to be set before it can be started and in the example we have listed individual settings for the X,Y,Z and E Axis’s.

The following settings can be set:

Frequency: Sets the speed of the pulse train
Pulse Count: Sets the required amount of pulses to be sent out
Direction: Sets motor direction 0=CW 0=CCW
Ramp UP: See command Set page for more details.
Ramp Down: See command Set page for more details.
Ramp Divide: See command Set page for more details.
Ramp Pause: See command Set page for more details.
Link to ADC: See command Set page for more details.
Enable Polarity: See command Set page for more details.

1.) Click Set button

2.) Once set you will see that the Start button has been enabled.


Once the Start button has been pressed the PTHAT will start sending out the pulses and also the Pause and Stop buttons will become enabled. At this point you can pause or stop the pulse train at any time.

Also while the pulse train is running, you can send other request commands such as requesting the amount of pulses that have been sent out so far, the value of the ADC’s etc.

The Read Data box will be updated with the replies from the PTHAT.

You can of course select more than one Axis to set and start at the same time or even start then at different times while the others are running.

Just choose Set for each Axis and the click on Start All.

As you can see when selecting more that one Axis, it will still then allow you to individually pause, Stop each Axis or to control all at the same time.
Here is a video of us testing our application with our 4 motor rig.

Rather than clutter this one page with too much information, we have created an Example Page that has more Windows 10 IOT example applications you can download and try out, along with pictures, screen shots and videos.

Please click here to go to the PTHAT Examples Page


There is a lot of information already out there covering the use of the serial port on the Raspberry Pi, but there is a few considerations when running Raspbian as the serial port may need freeing up or enabled. A good site covering this information is and especially the section near the bottom of the page named Connection to a microcontroller or other peripheral

In the future we will also be providing some PYTHON examples.

Share This