Python IO on rPi

My next ‘real’ project involves implementing a web interface to control some of the things around swan tron global HQ, the half of the garage I reserved for my lab. I’ve been a huge fan of the Raspberry Pi since the mission was announced. Linux and IO…you have my attention. Add in the $35 price tag and my penchant for destroying hardware…huge fan is correct.

Before I start planning my real project, I need to figure out how this differs from the microcontrollers I’ve used in the past to deal with similar implementations. I know the CPU is going to show itself, but not to what extent. Time to start poking around.

I decided to horse around and knock out a few birds with one stone…python library, digital out, and basic pin function. Oh, and LEDs. Everyone loves LEDs.

the 80s called, they want their printer cable back
cobbler and bread

Prior to this effort, I have mainly explored the rPi via x. I’ve spent a decent amount of time inspecting the file structure (Debian, no surprises) and the xwin UI. It is no speed demon, but it does the trick. I have the wireless adapter configured and set to auto-start, which was most of the battle. It basically performs as advertised, which on paper is very awesome for the price.

My general setup for this was very simple. I bought a cobbler set from Adafruit, which acts simply to pull the IO pins out to a breadboard. Two LEDs, two resisters. A few jumpers. Very simple.

I booted the device, and used aptitude to update and snag the rPi GPIO library.
sudo apt-get update
sudo apt-get install python-rpi.gpio
That does the heavy lifting with the python implementation…sample code is available on the main python site. The update was I used vim to create a dirty python script…unworthy of a repository, but worth a pic:

fugly code
no comments, no worries

The digital outs worked as anticipated. Timing was a bit odd…I ended up playing around a bit with some pauses in order to tune the blinks as I wanted. It looks like coordinating pin outs might be tricky for more complex operations, but at least the library and hardware is up and running.

Don’t take my word for it:

The next steps will be interesting. Figuring out how to ssh into the box in order to run a script of this magnitude will be next, followed by profiling the voltage on the pinout. It should be able to throw my 5v relay with a little tweaking…if not I’ll figure out PWM and tackle the switching mechanically. Fun stuff to come…happy to be playing with the rPi finally. Stay tuned.

IOIO Servo Controller

I just doubled my Android Market presence with one fell swoop. IOIO project number two is in the books: IOIO Servo Controller.

IOIO Servo Controller
servo in altoids can smells like altoids

This project is a one-off of the PowerSwitch Tail relay project I have out in the wild. I took the button out of the mix and implemented a slider bar…removed the relay and am now driving a hobby servo.

IOIO Android app
brand placement

Displayed is the relative level (zero to one) of the slider, the slider itself, and a shameless plug. The onboard LED also fires with a brightness relative to the slider position…which I implemented in the coding and sort of left in there.

The basic concept was to get the PWM output configured correctly, in order to control the servo positioning…the slider function is pretty much just the stock slider from the Android Development docs, widened a bit for the sake of video capture. The rest was just mashing around the code I had out there…not too bad.

Check the thing in action:

This project is available for download in app form on the Android Market. Right next to my other guy…search for IOIO. I will toss the code on my GitHub account as well. Fun project…I may branch and see If I can do anything cool with a few servos. We’ll see.

Shoot any comments to joe(at)swantron(dot)com. I can help with any setup issues, if they may arise. Good luck…

IOIO App Redux Time

I put together a simple proof of concept using a slider to control a PWM pin out…simple is an understatement.

pwm app ioio

Nice, right?

In doing this, I did a fresh download of the IOIO example apps, as I had gutted the Blink example for my 120V relay app. It turns out that there is a fresh firmware version…I grabbed the new IOIO library that is associated with that. So, my proof of concept doesn’t function…I tested it with an LED to no avail.

So, I have a few items to address before I push out another project

  • Update firmware | flash V3 to my IOIO
  • Update my IOIOPowerSwitch App to contain IOIOLib V3
  • Update READMEs / Github / Android Market to cite firmware version
  • Update proof of concept to same specifications
  • _
    It should go smoothly, after the first bullet-point is in the books. Stay toooned.