Armed only with a bucket full of enthusiasm, a wiki full of miss-information and a 2 digit IQ, the good Captain seeks not only to understand the modern world, but also fix one or two bits of kit along the way. 

Category

Wednesday, 13 May 2015

Picaxe Programming with Pi

You can write Picaxe programs, compile and download to the device using Windows or Linux x86/64. 

And it is also possible to use a Raspberry Pi and a few cheap components to develop and load your programs to a Picaxe. 

This brief post describes how. 

The Picaxe & Pi combo

I've been playing around with an 08M2 Picaxe chip connected to a Raspberry Pi recently, but was getting a bit tired of removing the chip, putting the device in my programming board, editing and downloading from my laptop, and then re-fitting the Picaxe to my Pi connected breadboard in order to test it. 

Wouldn't it be nice if it could all be done without removing the Picaxe? 

Well it can! 

Platform support

So the first problem is that a Pi is ARM based, not x86.  But a clever guy/gal (known as fanoush) has come up with a solution which uses Qemu in "user mode", and was kind enough to post on the Picaxe forum. 

Fortunately for me, another guy/gal (known as hippy) was kind enough to help me out, as I struggled to get this working.  So this bit is 100% not my own work. 

You can install the files you need by following hippy's instructions.  In a terminal type each of these commands:-

Raspberry Pi serial port

Upspeak and Downspeak

Upspeak (also known as High Rising Terminal) is a protocol difficulty that old people like me encounter when opening a comms link with a young person (...or anyone from Australasia). 

A more serious problem for my Picaxe to Pi comms link is that the Pi uses a Hi going Lo convention, while the Picaxe port is Lo going Hi.  So we need a bit of hardware in between to invert the signals on the two comms lines. 

The only suitable chip I had to hand was a ULN2003.  So I stuck one on a small breadboard with a couple of resistors, a capacitor and a few fly-leads. 

Sorry, I forgot to draw the 0.1uF capacitor (pins 1 to 8 of Picaxe)

The ULN2003 is quite a good choice for those that still don't believe that you can connect 5V devices to the Pi gpio.  As the outputs are open-collector, you can disconnect R1 from 5V and reconnect to 3.3V.

Don't worry too much about the values for R1 & R2.  Anything in the range 4k7 to 10k will be fine. 

The magic command

In order to compile and download our Picaxe programs, we need to specify the compiler, the serial port and the name of our Picaxe source file. 

So once again, navigate in file manager to:-

/home/pi/picaxe/bin

...and then create and save your killer app (e.g. KillerApp.bas). 

Now hit F4 from file manager, and in the new terminal that opens type:-

All systems go! 

This method was tested on a PiB+ and a PiB2 both running Raspian Jessie.  There is no reason (...that I can think of) why is should not work on any Pi variant with Wheezy or Jessie, for any of the Picaxe/compiler devices.