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.

IOIO on LiIon Battery Power

I finally bucked up and picked up a few Li-Ion batteries for my dust-collecting Clocky mod project. A two cell, a three cell, and a suitable charger for the two arrived in the mail yesterday. I’ve said it before and I’ll say it again…lithium ion battery tech is crazy. I can’t believe how deprived we were, or more accurately, how pumped I am to utilize this stuff at a decent price point.

Anyhow, I managed to spec out a high quality, thrifty Li-Ion that will fit on my payload…

ioio external liion battery power

whrrrrrrr

…and, the little sucker screams…

I have a hard connection from my phone to the IOIO in the vid. I need to configure the new ROM with bluetooth, and wanted to test the power function stand-alone. That will be the next step. The next next step will include piecing the payload together as a drivable unit. The next next next step will be tweaking the UI for some more realistic control units. After that is next next next next, and will involve a video of the unit in action.

Project Demo

One step closer…

ioio garage time

the olde clamp test

This thing screams with wall wart power. Watch…

Now comes the hard part…choosing a decent battery and mounting the circuit board savely on the chasis. I have found a few good candidates, but they are a little bulky for my application. Still looking…

The UI should be fairly straight forward. Just need a few more garage sessions, and I’ll be good to go.

The cordless Dremel was a super purchase FWIW. One of the best tools I’ve used.

Upgrading DC Motors to Servos

A whole bunch of Dremel work and some hot glue…

The Clocky conversion to servo motor control is mostly done.

clocky with servos

getting close

I still need to make the servo mounts more secure, but the initial test runs look promising:

Getting close. I determined that the IOIO board will not fit inside the casing, so I will have to come up with an external mount. Which will change the balance, so I might end up having to add some counterweights for balance. It should shape up, mechanically, in another garage session or two. The UI work will be another session, thereafter, but look for a finished product within the next week or so.

IOIO Project Revamp

A while back, I put together a project that added remote control via an Android. I broke out the leads to the DC motors that were existent, and left the structure largely intact…resulting in a monster of a build.

ioio remote

here we go again


I would like to clean the build up a bit, but to do so will need to go with a different approach. I am looking into gutting the existing components entirely, and implementing continuous drive servos as my powertrain. This will likely get messy.

Servo motors will add big gains in the power consumption realm, and provide added control. I am not looking for speed, so I think this option might work out well. Stay tuned…

Bluetooth Servo Control Redux

The project is wrapped. I have fully shown servo control via bluetooth, via Android, via IOIO. +3 via

usb b gone

no hands

The easiest way to test this, by far, is to snag the app on the Android Market. Here:

servo bluetooth

market-y

This does require a newer version of the IOIO bootloader than is currently shipping from units at Sparkfun, but details can be tracked down at this Google Groups area on how to update. It will work standardly, with a USB cable.

From there, you can take a look at my code on GitHub.

push to git hub

pushed

I haven’t included the IOIO libraries, but that will be part of the Eclipse setup if you decide to start hammering out some code. I can provide some guidance if anyone is in need of any.

Take a look. I bumped the SDK minimum again, in order to ensure that this function is intact. If this causes any hardship, I can relax the requirement.

Anyhow, take a look at the app in action in the previous post. Cheers.

IOIO Servo Controller v2.0

I’m preparing to publish a project utilizing the new bluetooth library for the IOIO. I started horsing around with my IOIO Servo Controller application, and finally got frustrated with the lag that was existing between my slider bar and the servo. I never pulled my improved function from my IOIOSeek work over…it was overdo.

Anyhow, I sort of cleaned house and put together an improved interface, and pushed it to github.

push it

push it

Here is a quick vid of the new app in action:

I pushed a new apk to the Android Market as well. If you have it installed, it should update in the morning. Here is a sneak peek of the updates:

*Optimized code to alleviate lag between slider bar and servo positions.
*Increased minimum version requirements, for future bluetooth connectivity
*Added function to keep slider in an inactive state until IOIO connection made
*Cleaned up code to remedy force close situations
*Remapped PWM pin from 5 to 10 for consistency with my other apps
*Removed text field of slider position / on board LED
*Simplified layout for smaller screens

I pulled some function, but am more than willing to reintroduce the relative readout and/or on-board LED display. I am trying to go simple with this one, and ramp it up once I can figure out the lag that the bluetooth connection will introduce.

Android IOIO Project | IOIOSeek

I hope you don’t mind, but I went ahead and stepped it up a few notches.

My newest project brings my end-goal a few steps closer. I now have the pieces in place to put together an actual robotic implementation with the IOIO…since things have officially reached the cool stage, I decided to drop this as a stand-alone project. Complete with pics, a vid, and an app.

IOIOSeek:

IOIO android servo seek

dig the lighting

What I have here are two slider bar controlled servos, an analog input-read solar panel, and some LEDs toggled via a button. The control is via the IOIO / Android.

servos and solar panels on ioio android

dig the wires

The pictures, however nice, don’t really tell the story. Take a look at the video to see this thing in action:

As the video alludes to, I am going to run with this concept. The automation (robotics) lies in the analog reading with respect to the servo positions. I plan to ‘scan’ the panel…that is the piece that is missing. Once I can implement that mess, I will have a tracking system. Implementations will fall out of that.

analog input ioio

+1 tape

As with the last few projects, I have dumped the app on the Android Market for general perusal. The app’s description provides the details of the pin configuration, which is straight forward. I have two PWM outputs, a pure 3.3V digital toggle, and a pin configured for analog input. That is that.

I will push my code to GitHub as well eventually, and provide a link therein. I still need to polish my generic servo code, since my latency was borderline awful in retrospect. Look for that in the near future as well.

As always, drop any questions to joe[at]swantron[dot]com. Feel free to share your IOIO projects with me…

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…