David Briddock has been hard at work writing a series of blog posts about Python and how to use it. This series caters for beginners of all ages who want to learn how to program and don’t know where to start. There are 5 lessons so far and the series is growing at about 2 posts a week. So if you want to know more about Python and how to get started, head on over to David’s page on his blog.
Paddington school Code Club visits the #RaspberryPi factory
Lovely post on the Foundation website written by Nick Corston from a school Code Club in Paddington who had the chance to visit the Raspberry Pi factory in Wales. Read about their visit here
Controlling servo motors on the #RaspberryPi
As part of my “SpacePi” Raspberry Pi astronomy project, I want to be able to control the orientation of the camera module remotely. I want to be able to sit away from the camera rig and control where it is pointing using a web interface and (optionally, and because I damn well can) via a Wii remote.
So, I’m currently doing research into how best to do this.
I’ve got the actual mechanism sorted by buying one of these: Dagu Pan/Tilt which comes with two of these motors. I’m planning on building some kind of LEGO base for it as I don’t fancy trying to balance it on the bottom of the servo! 🙂
The motors operate at a known rate at around 4.8v, which is perfect because that’s what comes off the Pi. Except I don’t think it’s safe to do this. I know the 3.3v rails have a max power draw of 50ma, but I think that the amps available on the 5V is just whatever is left after the Pi takes it’s ~700ma. That might mean I have enough amps left, but I don’t fancy trying this out on one of my beloved Pis! So that means an extra power supply for the servo motors. Okay, I can live with that. I’d rather not, you understand, so if anyone knows that it is safe to power from the Pi, please let me know!
Control of the servos is via PWM, aka Pulse Width Modulation. This is something that the Arduino does very well, but that the Raspberry Pi does less well. This is because the Arduino is what is known as a “real time system”, meaning that when it is running it’s program loop nothing else can use up the CPU. Literally, the only thing running is what you’ve told it to run. The Raspberry Pi, on the other hand, is not a real time system as Linux itself is always beavering away in the background taking up CPU cycles. However, I have come across some ways of getting the Pi to give the impression that it is a real time system and to do PWM ‘properly’.
So, some web pages to look at:
- Better PWM on the Raspberry Pi – an article on hackaday.com about the ServoBlaster project which is a good implementation of software PWM.
- Gordon Henderson has written about an improvement to the WiringPi library to allow threaded PWM on every GPIO pin taking up 0.1% of the CPU each.
- Rahul Kar has blogged about using the WiringPi library and PWM.
- Benjamin van der Veen’s blog was useful in understanding PWM in the first place.
- Petervis.com has a little bit about the single PWM hardware pin on the Pi.
- Great question on StackExchange about using PWM to control servos.
- JRonald’s fork of ServoBlaster that doesn’t use up all the pins for PWM.
- Thread on the Foundation form dealing with ServoBlaster.
- A video showing the Pi driving 5 servos – I think using PigPio.
- Another video this time with link to download PigPio.
- Video showing Python PWM with a link to download. The GitHub is here.
After looking at all these, I would have tried out the Python version first. I like Python, it’s my sort of language. But the author of PyZiPi has said that it’s not suitable for servo control.
If Python fails me, I’ll move onto C/C++ with PigPio first as it seems the simplest, but will probably end up using ServoBlaster and jumping through the required hoops to get it working. (There are all kinds of things mentioned like ‘userland’ which I’ve heard of and frightens me!).
The other thing to try, of course, is to try the WiringPi-Python library which means you can use the WiringPi library from within Python. Certainly seems as though it might work, as Gordon Henderson has hinted in the comments section of this blog page.
More soon! (Once I’ve got the pan/tilt servo rig in my hands)
Perl and #RaspberryPi – Postfix as a mail solution
Mark Dootson has blogged about using Postfix as a solution for emailing from the Raspberry Pi. Read more here
WebIOPi for the #RaspberryPi updated to 0.6
Eric, over at trouch.com, has released a new version of his Python libraries for the Pi. These give an Arduino-like feel to your Python code and provide a clarity that I’ve not seen in many similar projects.
There are quite a few chips and sensors that are built-in and dealt with natively and I’m definitely going to be using it for my next project that deals with the GPIO.
#RaspberryPi model A powered from 2 AAA batteries
Very neat video of a Raspberry Pi model A running from just 2 AAA batteries all in a ModMyPi case. Really clever stuff.