Hi all,
I've spent the last couple of days trying to get a R.Pi and a Picaxe to talk to each other using the GPIO serial port (rather than plug in the AXE027 USB.) I thought I'd post what I've learnt:
I have been using the UART pins on the GPIO header, These are header pins 8 (Tx) and 10 (Rx). In addition you'll also need 0v from header pin 6.
Interfacing circuit:
1. Connect the ground (0v) of the RPi and the Picaxe together
2. Level conversion - The RPI serial port uses 3.3v so we must use some simple level shifting circuits to interface this with the (in my case 5v) Picaxe supply.
2.a) Picaxe Tx -> RPi Rx . This is a simple 5v->3.3v conversion and can be done using a simple voltage divider.
I used two 100KOhms.
On this diagram - connect Vin to your picaxe serial output pin, and Vout to the RPi Rx GPIO pin
2.b) Rpi Tx -> Picaxe Rx . We want to step up 3.3v to 5v. This requires a transistor circuit known as the voltage follower.
The supply rails are connected to 5v and 0v respectively (the picaxe power supply).
The Tx GPIO pin from the RPi is connected to the transistor base (good practice says you should have a high value [100k] resistor between the Tx pin and the base, though it will work without)
The load resistor should be around 10Kohms, and the output connected to your serial input pin on the picaxe.
3. The RPI serial port uses the "idle high" configuration* so when setting the baud rate on the serout or serin command be sure to use the TRUE flag (e.g. T9600_8)
This configuration should allow you to send and receive data via the RPi's serial port. To send data you will need to open a serial console, I use minicom, on the RPI. The UART port is /dev/ttyAMA0 (at least on the Debian install).
Remember you will have to set the baud rate and the protocol (8 bits, no parity, one stop bit)
This works well for me using a 14m2. My plan is to write code which will allow reading and writing to the picaxe I/O pins via the serial link. Effectively turning the Picaxe into an IO extender, though potentially much more if some of the more exciting picaxe functions are implemented. Using the infra red capability it would be relatively easy to build a remote control for your RPi.
I've spent the last couple of days trying to get a R.Pi and a Picaxe to talk to each other using the GPIO serial port (rather than plug in the AXE027 USB.) I thought I'd post what I've learnt:
I have been using the UART pins on the GPIO header, These are header pins 8 (Tx) and 10 (Rx). In addition you'll also need 0v from header pin 6.
Interfacing circuit:
1. Connect the ground (0v) of the RPi and the Picaxe together
2. Level conversion - The RPI serial port uses 3.3v so we must use some simple level shifting circuits to interface this with the (in my case 5v) Picaxe supply.
2.a) Picaxe Tx -> RPi Rx . This is a simple 5v->3.3v conversion and can be done using a simple voltage divider.
I used two 100KOhms.
On this diagram - connect Vin to your picaxe serial output pin, and Vout to the RPi Rx GPIO pin
2.b) Rpi Tx -> Picaxe Rx . We want to step up 3.3v to 5v. This requires a transistor circuit known as the voltage follower.
The supply rails are connected to 5v and 0v respectively (the picaxe power supply).
The Tx GPIO pin from the RPi is connected to the transistor base (good practice says you should have a high value [100k] resistor between the Tx pin and the base, though it will work without)
The load resistor should be around 10Kohms, and the output connected to your serial input pin on the picaxe.
3. The RPI serial port uses the "idle high" configuration* so when setting the baud rate on the serout or serin command be sure to use the TRUE flag (e.g. T9600_8)
This configuration should allow you to send and receive data via the RPi's serial port. To send data you will need to open a serial console, I use minicom, on the RPI. The UART port is /dev/ttyAMA0 (at least on the Debian install).
Remember you will have to set the baud rate and the protocol (8 bits, no parity, one stop bit)
This works well for me using a 14m2. My plan is to write code which will allow reading and writing to the picaxe I/O pins via the serial link. Effectively turning the Picaxe into an IO extender, though potentially much more if some of the more exciting picaxe functions are implemented. Using the infra red capability it would be relatively easy to build a remote control for your RPi.