Thursday, September 6, 2012

Raspberry PI - New Board Revision / Make in UK


Interesting news at http://www.raspberrypi.org/


1) A New "Revision 2" board, with some subtle and not so subtle changes is now in production. Most notable changes:
  • Mouting holes
  • More power to the USB ports
  • Change to GPIO pin mapping (apparently will make sw development a bit more challenging to work for all rev boards)
Also some other things, see the link above for details.


2) The board will now also be made in the UK (as well as still in China, I assume)

Again, more info on the link above.



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.

Saturday, September 1, 2012

Raspberry PI - another "free" option for connecting to GPIO Pins


I just received a Pi Cobbler Breakout Kit for Raspberry Pi from Adafruit.

It looks great for connecting the GPIO Pins to a proto board while minimizing the likelyhood of shorts.

By the way, check out their site as they not only have a lot of Raspberry PI stuff, they have TONS of other interesting products.

After I had order the "Cobbler" I thought of something else that might be useful for connecting to the rPI GPIO header and require no soldering / heat shrinking like what I suggested here.

If you see an old computer being "recycled" (more joy of junk), open the case and look for the wires that go from the front panel switches and leds and plug into the motherboard. You can see them hanging there in this picture. You can just cut them away from the front panel with side cutters, leaving the wires as long as you can. On the end that plugs into the motherboard, just pull them off, you will find these connectors will fit the rPI GPIO header pins exaclty.

Although most of the connectors are double, and would cover 2 pins at once, that is not a problem (even if you only need access to one GPIO pin). Just strip the insulation off of the end without a connector, twist tightly and insert into the propo board. Tinning the end with your soldering iron will keep it from fraying, just make sure that you use the solder sparingly and knock off any excess while still melted so as not to make the wire to fat to push into the proto board.


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

Thursday, August 30, 2012

Raspberry PI - Suitable for Real Time?


I used to to a lot of true "real time" programming, in Assembler and FOTRAN on PDP-11's, then 6800/6809's and more recently on the PIC in "C" ("WalkMorse" project - not yet published).

From Wikipedia:

"Real-time programs must guarantee response within strict time constraints ... a non-real-time system is one that cannot guarantee a response time in any situation, even if a fast response is the usual result."

This site states

"Note that this module (class to control the GPIO) is unsuitable for real-time or timing critical applications. This is because you can not predict when Python will be busy garbage collecting. It also runs under the Linux kernel which is not suitable for real time applications - it is multitasking O/S and another process may be given priority over the CPU, causing jitter in your program."

So the bottom line is, if you are controlling something that is VERY critical as to timing, the rPI with Raspbian + Python is not the ticket. I would have to do some testing, but IMHO I am sure you would get guaranteed 1 second response at least (maybe with some jitter), probably down to 100 ms (maybe less) without too much issue.

However if you want real guaranteed response, you would need to use a suitable chip such as PIC, ARM, etc. programmed in assembler or C on the bare metal, or a true Real Time OS.

There seems to be some buzz about putting a real time OS on the rPI, but I am not aware of any yet.


References

http://en.wikipedia.org/wiki/Real-time_computing

http://code.google.com/p/raspberry-gpio-python/

http://en.wikipedia.org/wiki/Real-time_operating_system#Examples

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=9&t=5300


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.

Wednesday, August 29, 2012

Raspberry PI - Home Brew Breadboard






I thought I would make a few notes about the Breadboard that I am using to experiment with hardware and software for my rPI, as it might give some newbies out there some ideas.

Building electronic breadboards is something I have been doing since grade 6 or 7 (in the 60's!) and I find that it is very important to help you build reliable and repeatable prototypes and keep from blowing things up.

If you are trying to experiment with hardware on a table or workbench, you need something plug components into and to hold everything stable. You could use alligator leads and loose stuff laying all over, but if you accidentally yank on a wire it will short or disconnect something, in the worst case blowing up your rPI.
 
Photo 1

In Photo 1 above, you can see the overall layout. The DVI computer monitor, USB keyboard and USB mouse are on the left. The square frame with really old style plugboard (that used to use very large old components on little frames) came from an old electronics lab in a school that was being thrown out (lab was probably being turned into a "new media room" or something). 

Onto the old plugboard I bolted on an assortment of new style solderless Breadboard / Proto Board units for inserting leaded parts and DIP ICs to build up circuits. A couple of them have been with me so long they are turning yellow! You can get these at any good hobby / electronic supplier.

An old analog open frame power supply that I scrounged from some equipment that was being thrown out by the same school is bolted to the back. It supplies +5 volts at up to 4 amps (see my posting about using a good beefy power supply), and +12 and -12 at 1 amp. It has a power cord that plugs into the 120 volt wall socket, with the green safety ground tied to the metal frame. There is a hole drilled in the wood to run the power wired underneath. Wiring is very simple, if someone wants a schematic let me know.

Photo 2

 


In photo 2 you can see how I have the rPI bolted to the side so that the monitor, keyboard, mouse and power cables do not move it around. There is a wooden spacer under the inside corner, some insulating foam (just in case, not metal there) and some rubber washers I dug out of my "junk box" to keep trom shorting or damaging the board. The MINI USB power cable goes through a hole on the side under the board.


 Photo 3



 In photo 3 you can see the SPST power switch for the Mini USB going to the Raspberry Pi. This allows me to quickly switch off the rPI without switching off the power supply. Since the PS is analog, it takes a while for the big capacitors in to discharge, and it will run the rPI for quite a few seconds when the plug is pulled out of the wall.

The other switch is a 4 Pole ST switch that allows me to switch off the -12 / +5 / +5 / +12 binding posts with one click, this will be used to power circuitry on the proto boards with jumper wires attached to the binding posts.

You can get toggle switches and binding posts from any good supplier.

 Photo 4



The last photo shows 5 biding posts that have no connection to anything under the board. What I use these for is for connecting test leads from test equipment such as a DVM, Oscilloscope, etc. The leads to them are usually quite heavy, and have relatively thick ends for probing around. I use a banana to banana (or BNC or whatever) lead to connect the equipment, then use a thin long jumper wire to connect to the point in the circuit to be probed. Much less likely to pull something out in the circuit that way.

There is no need to pay someone to cut and strip jumper wires to plug into the proto board, just go dumpster diving and find some pieces of CAT5 solid network cable from an office renovation. Then cut into lengths, strip off the outer sheath, untwist the wires and strip the ends for jumpers.

 To make up the jumpers to plug on the rPI GPIO header, I cut apart an old female DB-25 connector from an old cable (you can find these in good dumpsters everywhere) to get the pins out (hard hacking, but doable if you take care). Then I soldered a jumper cable to an individual pin, covered it in heatshrink, and it's done. You can buy assembled wires with ends, or a fancier breakout cable like this from Adafruit.

I think you will find the time invested in buying a breadboard complete or making one from purchased and scrounged components is well worth the time. It will save you countless hours when your "ratnest" lashup of wires and alligator clips starts to act flaky, or the cat catches a cable and pulls it onto the floor.






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.

Tuesday, August 28, 2012

Raspberry PI - Reading and Writing to GPIO Pins

Next step is to combine the GPIO Input and Output in to one program.

With the power to the rPI off, I used another jumper to tie header pin 18 to the input of a high impedance logic probe.

Then I powered up, logged in and nano's up the following program "switch_led.py"


#!/usr/bin/python
#
import time
import RPi.GPIO as GPIO
#
# to use Raspberry Pi board pin numbers
GPIO.setmode(GPIO.BOARD)
#
GPIO.setup(18, GPIO.OUT)
GPIO.setup(11, GPIO.IN)
#
count = 1
while (count < 100):
        input_value = GPIO.input(11)
        GPIO.output(18, input_value)
        print input_value
print ("End")

Then I ran it with

     $ sudo python switch_led.py

Now when the switch is turned on  and off, the led goes on and off. 

Congratulations, you now have a $35 programmable light switch. But once you can get digital data in and out of a program , the sky is the limit!



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.


Monday, August 27, 2012

Raspberry PI - Reading a GPIO Pin


The next thing that I wanted to do was READ a GPIO Pin.

This article assume that you have installed the software mentioned in
"Raspberry PI – Writing to GPIO Pins".

I connected the following circuit using jumper pins and a proto board (BE careful and do this with the power off, triple check before turning it on!!!!).



You cannot just hook the switch to a logic input, you have to actively pull it high and low (in most cases, won't get into that now). The 10K resistor acts as a "pullup" to pull pin 11 high when the switch is open, and draws only microamps of leakage current (it any).

When the switch is closed, pin 11 is pulled low to ground, drawing only about 0.3 milliamps from the rPI.
 
After checking the circuit, power up the rPI, log in and nano up the following program as "switch.py":

#!/usr/bin/python
#
import RPi.GPIO as GPIO
#
# to use Raspberry Pi board pin numbers
GPIO.setmode(GPIO.BOARD)
#
GPIO.setup(11, GPIO.IN)
#
count = 1
while (count < 100):
        input_value = GPIO.input(11)
        print input_value
print ("End")


Now run the program

     $ sudo python swith.py

You will see "True" scrolling to the screen when the switch is open, and "False" when it is closed.

By the way, the schematic was edited with a "free as in beer" schematic editor from www.expresspcb.com


Reference



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.

Sunday, August 26, 2012

Raspberry PI - Power Supply and USB Problems


Read an article on Slashdot that says the Raspberry Pi has some "problems".

The actual article seems a bit alarmist, to summarize the key information there and in the referenced articles:

1) The rPI gets flakey if you don't use a powerful enough power supply
2) The USB peripherals apparently can't deliver the 500–900 mA that the USB spec calls for (Ref 1)

The interesting thing is that I have observed both of these problems, but quickly figured them out and have had no issues since.

1) I tried powering the rPI from a couple of USB hubs with external power supplies that both said "1 AMP". On the first one, it would get part way through the boot process and reboot, getting stuck in a boot loop. On the second one, it would not even start the boot process. I fixed the issue by running the PI from a heavy duty 4 Amp analog open frame power supply  that I scrounged from some piece of junked gear (have to write a blog posting on the joys of scrounging junk :-)

2) I first tried a really old USB keyboard (a real "IBM" one - remember when they made PCs :-) and it acted flakey, repeating and missing characters. I swapped it out for a newer one, works fine. My conclusion is that the newer one drew less current and worked fine, although I did not measure it.

So to me all the alarmist postings are a bit of an overreaction, moral of the story is to use a GOOD beefy power supply that can deliver the 1 AMP the rPI needs (Ref 2) PLUS the combined current that the 2 USB peripherals need. Better still, use an external self powered hub for the USB peripherals.

References

1) http://en.wikipedia.org/wiki/USB

2) http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=14988



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.