rPi Hardware Servo Control

Today’s lunch consisted of cold chicken and some fun with servos. Servos, Python, Linux, IO, chicken…nice little Friday.

The goal of this abbreviated session was to figure out how PWM works in the trenches. However sold I am on the rPi in general, I have an uneasy feeling that the CPU is going to be a pain in my ass with respect to stuff I’ve taken for granted on simpler hardware. Whereas the Arduino platform and my beloved IOIO were effectively real-time operating systems, the rPi’s IO pins’ calls are no different from any other PID that is spawned. The amazing Linux-y stuff does in fact have a downside…i.e. no guaranteed execution times.

Anyhow, this is what I am currently poking at. Today’s session was a case-in-point as a matter of fact.

schwervo
schwervo

The setup is as simple as it gets…what I call the ‘junior servo’ hooked up to 3.3V, a ground, and to the single PWM-capable pin (18) on the rPi. I have previously pushed Servo Jr. with 3.3V with the IOIO, so I had a level of confidence I wouldn’t tear down the box. On a bit of a side note, I did verify that ripping 5V off of the board and attempting to push a full sized hobby servo did in fact take the rPi to its knees. Be sure to power any servos externally for any real tests or prototyping.

I again chose to use Python to mash around. Two data points aren’t many, but will definitely allude to a trend you will likely continue to see here: I’m more comfortable with Python than C, and that is our chosen rPi workhorse at Swan Tron Global HQ. Sadly, as opposed to playing around with LEDs from my last rPi post, the GPIO library doesn’t have any PWM support at this point. The workaround is to call out the pin directly…this is pretty easily done with any of the main rPi distros. I am *fairly* certain I am still on Occidentalis v0.2 from Adafruit.

Here is another non-snippet-but-here’s-a-screenshot-worthy two minute py script I put together to push the servo:

bonus cap reflection
bonus cap reflection

As I feared, the hardware instance is begging for well-designed software in order to produce anything predictable. The following video was taken from a fresh boot (READ: after I wiped the thing out with a continuous drive servo) sans any networking. As bare-bones as you can get…the OS executing a Python script and writing to one pin…what you see is:

Executable 1) Software calling for servo to alternate between 0 and 180 degrees, with a delay between position changes

Executable 2) Software calling for servo to step between 0 and 180 degrees with slight delay between position changes

Executable 3) Software calling for servo to step through scenario #2, albeit with a negligible delay between position change calls

Take a look:

Result 1) With adequate time between writes, the servo itself sets the cadence, and smoothly

Result 2) 180 position writes manifests as a jumpy mess, even with ample pauses introduced

Result 3) …and boom goes the dynamite

With the hardware being handcuffed by the CPU, timing on the software level is the name of the game. Sort of fragile, but still wholly awesome.

The next step is going to be a full-out network setup and some real memory profiling. I am going to figure out how to access this thing via ssh and see what that leaves me to work with. The step after that is going to be driving multiple servos…provided software PWM is a possibility. We’ll see where that ends up.

The pipe-dream? Think Roomba with an onboard rPI. SSH access via WiFi on a device that can decouple itself from a charging dock. Basically, I am hung up on the notion of being able to ssh into a robot…I’m not sure it gets much cooler than that.

As always, stay tuned. As also always, feel free to contact me @ [ joe at swan tron dot com ] with any feedback or questions.

Adafruit Raspi Kit

Time to blow the figurative cobwebs off my figurative Python skill set…

pi case
cobble cobble

Adafruit RasPi kit has arrived…the cobbler kit is the final piece I’ve been waiting for. I have a USB hub and my wifi configured…time to cut code.

Busy

Busy at work upgrading the RightNow site. Busy at home chasing our mobile baby. Not too busy to throw a thumb up…

busy

New blog content will follow shortly. I have a RaspberryPi Cobbler kit and case on order from AdaFruit, and a Wii U reserved at GameStop. Automated garage door opener is in the planning phase for the former, and Mass Effect 3 sitting in wait for the later. Stay tuned.

Occidental Distro Setup

I’ve wanted to play around with Adafruit’s Occidental distro since it was announced. The whole gist of the release is that it better caters to the hack-y types…they have taken Wheezy and built in some utilities. Especially cool is Bonjour, which *should* allow ssh access from my other networked machines. Still getting to that point, but I have installed the thing for experimentation.

Thus far I have been poking around…my small assistant did some stress testing…

raspberry pie occidental distro
keyboard smacking

I have some battery packs in the mail, and I need to configure my WiFi dongle. The idea is to let the machine run headless, and see what I can stand up with Python. I need to play around with the pinouts a bit and come up with some ideas. I could bring Clocky back from the dead…we’ll see what shakes out.

Debian on Raspberry Pi

Up and running on the 47 inch Vizio…

rpi
rpi

So cool.

Next item: get WiFi configured and working.
Next next item: poke around with the pin-outs.
Next next next item: something awesome involving Python.

Raspberry Pi Unboxing

It has arrived…

Raspberry Pi Unboxing
awesome

My condolences go out to my Arduino and IOIO boards. This thing is very amazing. Long story short, we have a full blown Linux box with a bunch of interface options. Stay very tuned.

My small sidekick and I shot an unboxing vid out of excitement:

Need to put the new house together quickly so I can play with this thing.