I’m a bit further down the road as of this posting, and already in a tool crunch. It looks like Lowe’s is the winner of this round…I’ll be back there tomorrow on my lunch break. “You wore that apron yesterday Lowe’s bro! j/k! Throw ‘er on the tab!”
Anyhow, this goal for the weekend is to have the base infrastructure in a rudimentary complete status. I have a bunch of question marks at this point, but a sharpening picture of where Emma and I will end up with this thing. I need to get saws and edible stuff out of the picture, so I’m hoping to be in the hardware / software phase of this thing in a few days. The generally awesome people at Adafruit have a new Arduino heading towards the Rockies, and I have a bunch of LED strip-centric things to study before that happens…tons to do. Sensors to study…screws to drive…Fruit Loops to eat. We’re busy. Need some Red Bulls.
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.
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
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.