Tuesday, August 21, 2012

Raspberry PI – Safely Interfacing to GPIO Pins


I screwed a rPI to an old breadboard I had, and bolted an old open frame analog +5, +/- 12 supply to the back and wired it all up.

In the last post I got a python program toggling all the I/O ports on and off at 1 second interval, will send out the code. At this point just measuring the result with a high impedance logic probe.

Next problem is interfacing the 3.3v rPI levels to the more common 5 v TTL. According to my research:

For 5=>3.3. you can use a simple 10k/20k resistor voltage divider. I have lots of resistors, just have to find them.

For 3.3=>5 This seems to be the cheapest alternative:
     http://www.datasheetcatalog.org/datasheet/philips/74HC14N.pdf

Blowing a $0.50 chip seems to be better than blowing a $35 rPI board :-)

For the next step I want to tie the rPI serial RXD/TXD to the TXD/RSD of a 40 pin PICAXE. Then write a very simple PICAXE program to allow me to use I/O pins on the PICAXE as an "expander" for lots of Digital I/O and Analog in, maybe even use a couple of pins to do PWM, which can be integrated to produce an Analog out. Want to use a simple human readable ascii protocol to marshal data and commands back and forth - http://www.amelek.gda.pl/avr/uisp/srecord.htm

That protocol is really meant for memory mapped data, but you can easily extend it to do commands, could even leave out the checksum.

You could always use a CSV formathttp://en.wikipedia.org/wiki/Comma-separated_values - but the srecords would be easier to parse as they are more field oriented.

Probably make it totally polling based to start, i.e. the PICAXE monitors the serial port, the rPI sends data and/or a command, the PICAXE responds and reads and/or outputs the ports, and then the PICAXE sends back any data to the rPI. VERY simple.

Joke is that I once tied together 2 multi $100K ATC simulators using a similar technique (one sim for terminal airspace, the other for precision approach radar) - very simple and easy to test and debug. Nice thing about using a human readable ascii format is that you can hang a dumb terminal (emulator) off the lines to see what is going back and forth for development and debugging (if you slow down the back and forth to human readable speeds :-)

References:

http://www.petervis.com/Raspberry_PI/Raspberry_Pi_GPIO_Header/Raspberry_Pi_GPIO_Header.html





Eric Pierce VA3EP - See the Disclaimer in the Introduction

© Eric Pierce and "VA3EP Amateur Radio And Other Geek Pursuits", 1952-2099. Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Eric Pierce and "VA3EP Amateur Radio And Other Geek Pursuits", with appropriate and specific direction to the original content.

No comments:

Post a Comment