Tag Archives: plutarch

Arduino Audio with the WTV020SD-16P

There are plenty of ways to play sound on an Arduino– at the most basic you might burp out some bleeps and bloops with the tone() command, or perhaps drop some coin at Adafruit and get yourself a multifunction music shield.

Our current passion project at Zheng Labs is an audio-enabling upgrade to Plutarch the Pirate Parrot. For this application neither of the above options will quite fit the bill. We want a board that’s inexpensive, light, and small enough to fit inside a roaster chicken’s body cavity while leaving room for a battery pack, microcontroller, and an ever-increasing number of servos.

Enter The WTV020SD-16P. ‘Tis a picky, tricksy little board, but once you get it up and running it’s scrum-diddly-fun to use.

rex

#RAWR! you can download Rex for 3D printing over at the Forge.

To the tutorial!

GATHER YOUR PARTS

  • a WTV020SD-16P
  • a SanDisk 1GB MicroSD card: apparently the WTV020SD-16P can be a little picky about which brand and capacity of MicroSD card will work.
  • a speaker: This one comes with micro-JST connectors, which you can just snip off and plug into your breadboard. I soldered some jumper wires onto mine to make working with the breadboard easier.
    some jumper wires

And of course an Arduino and a breadboard. I dusted off an ancient Duemilanove for this project, but I’d imagine any Arduino will do.

GET THE SOFTWARE

You can get the sample code and the software library you’ll need at the Arduino forum.

Oh God. Forums.

I can’t be the only one who dreads wading into technical forums seeking assistance. In my experience one can find tiny nuggets of precious content only by softing through the dross, dregs and slag of misinformation, know-it-all-ism, and half-baked do-my-homework-for-me questions IN ALL CAPS from engineering undergrads in Gdansk.

Every now and then a patient, knowledgable member with a willingness to shepherd a n00b through a confusing and contradictory information maelstrom will emerge, but more likely than not a cheeto-crusted basement dweller will snidely inform you that a B+ in Electrical Engineering 101 at Carnegie Mellon is a prerequisite for posing a question to your betters.

Thankfully, the Arduino forum’s friendlier than most, and it’s a decent place to start looking for information about the WTV020SD-16P. There’s still a lot to unpack and sort out before you get your board talking, though.

Once you’ve gotten the sample code from the forum you’ll no doubt come across this image in all its JPEG-compressed glory. It’s the second post on the forum. You can’t miss it.

schematic

I can’t stress this enough: do not use this image as your Virgil to guide you through this particular circle of Arduino Hell. There’s nothing inaccurate about it, but there’s too much information here for those who want to just plug this thing into an Arduino without having to first procure an EE degree, and some of it is misleading.

This schematic will get you a WTV020SD-16P that works in standalone mode with some pushbuttons, to be sure, but if all you want to do is control the board with Arduino code this wiring diagram is overkill. For one, the pins in this schematic don’t match the pins specified in the sample code right above it, which is one of those Things You Don’t Know You Don’t Know if you’re just starting out.

My edited schematic is a little simpler and balls-on accurate, I promise. Behold!

schematic simple

You’ll note that the sample code includes a declaration for a Busy pin. It’s used for asynchronous audio play but we’re keeping things simple and not using it in this tutorial. Also, you’ll see several pins on the WTV020SD-16P labeled as NC: they’re Not Connected to anything and can be safely ignored.

If reading schematics ain’t yo thang, here’s what it looks like IRL:

wiring

To recap:

  • Arduino 3V3 to pin 16 (top right of the board)
  • Arduino pin 2 to pin 1
  • Arduino pin 3 to pin 7
  • Arduino pin 4 to pin 10
  • Speaker + to pin 4 (usually this is the red wire)
  • Speaker – to pin 5 (usually the black wire)
  • Arduino GND to pin 8

ACQUIRE AUDIO:

You can download the commonly used sample .ad4 files here, or use mine which IMHO are better for diagnostics and have the added benefit of not dancing on the knife’s edge of fair use and international copyright law violation.

If you’re visiting the blog from abroad you also can use my files to learn what a nondescript northeastern American accent sounds like. No charge.

Unzip the archive and drop the files into the root directory of your FAT16-formatted MicroSD card. Files must be named 0000.ad4, 0001.ad4, 0002.ad4, etc. The WTV020SD-16P supports up to 512 audio files, which should be enough for all but the most loquacious of parrot puppets.

Creating your own .AD4 files from WAV or MP3 of AIFF is brain-dead easy with this OSX tool, but you’ll need to install the JDK first.

Be sure to have your source audio sampling rate set at 32kHz or the software won’t produce any output and (not helpfully) any error messages indicating that there’s a problem.

SOFTWARE:

On OSX, drag the library folder into ~/Documents/Arduino/libraries/

The sample code on the forum shows off everything the library can do, but it’s too much for a proof of concept and has some English errors that introduce ambiguity in the comments. Let’s do some minor surgery.

  1. Cut out everything in between the curly brackets of the loop() function.
  2. Paste the following between the now-empty curly brackets after loop():
int r=random(0,6);
wtv020sd16p.playVoice(r);
delay(1000);

Power up your Arduino, upload the new code and you should be good to go. Good luck, and please post in the comments if I screwed anything up in the tutorial.

Watch this space for news on Plutarch 2.0’s evolution over the next few months. He’s scheduled to debut on Halloween 2017. You might consider watching his progress on Instagram or Twitter: that’s where the microupdates get posted first.

Lao Zheng out.

Plutarch 1.0: finished, still not a robot

After this stability test it’s pretty safe to say that Plutarch is 97% ready to make his debut at J’s Halloween party later this year.

So how did we get here? When last we left our hero he was a naked 3d printed shell enclosing a buggy and unstable collection of wires and electronics.

Rubber cementing the feathers to the body was strikingly straightforward, the only caveat being that one needs to layer the plumage and make sure that none of it gets into the spaces between moving parts.

fledging collar

I ran out of feathers during the fledging process so he’s still got three percent’s worth of bald spots to fix during the 138 days before Halloween.

Epoxying the googly eyes is simple enough. Next time I’ll include 3D printed eye socket markers so I can be sure that Plutarch isn’t walleyed.

googly eyes

Here’s the thing about googly eyes. You can’t buy just two. You have to get a whole mess of them.

Epoxy is enlisted once again to affix the wing feathers to the body, as they’re too heavy to attach with rubber cement alone.

fledging wings

A clever designer would have included tail feather mounting holes in the original 3D printed body, but unfortunately no clever designers showed up to work on body design day. So Plutarch got a few aftermarket holes drilled in his rump.

drill

You may feel some slight pressure, Mr. Plutarch. Please try to relax.

OK! So! Forty-five minutes of fledging and butt-drilling hence, Plutarch’s ready for his big reveal to the family.

too sexy

Possibly too sexy for your cat.

You can see an original Pirate Parrot Accessory in the background of the photo above– one of his duplicates was cannibalized to provide most of Plutarch’s feathers. I bought a bag of blue turkey flats to compensate for the feather shortfall and still didn’t have enough.

The kids (and, of course the Lovely and Talented Mrs. Zheng3) have been watching Plutarch’s progress in bits and bites for the last few months, and they’re assembled in the kitchen for Opening Night. Plutarch is perched, powered up, and ready to go. I hit the button on his remote that makes him shake his head and… BAM.

broken

To everyone’s horror (except the cat, who gives approximately zero f*cks) Plutarch torqued himself off my shoulder, broke a foot, and snapped his battery cables.

Gah. I pinned the broken foot with a couple of epoxy-coated finishing nails and set the patient aside.

Another setback. We were so close.

The epoxy cure delay allows for a few hours of self-reflection. Why am I doing this? Is making an animatronic parrot really best way for me to spend my limited time on earth? How do magnets work, anyway?

Magnets. We need moar magnets. Better-positioned ones, too.

The original perch design put the magnets on the underside of a steel can lid, relying on luck to link up with the magnets embedded in Plutarch’s toes. Fearful of another catastrophic and embarrassing fall, I moved the magnets to the top of the lid and made sure they’re aligned as closely as possible with their mates above.

magnets

The video at the top of the post proves that this time Plutarch stayed put.

But. BUT! Even after all this improvement, Plutarch, while ready for primetime performance, is still not a robot. He’s best described as an animatronic parrot. Roboticization– the addition of sensors and the ability to respond to an environment– shall have to wait until Halloween 2017.

So here’s what I’ve got planned for Plutarch’s next year:

  • improved internal accessibility
  • 2-axis head movement
  • articulated beak
  • audio
  • some kind of sensor ability, for crissakes

#staytuned.

Tales of Plutarch’s earlier incarnations can be enjoyed here and here.

Lao Zheng out.

Plutarch: 148 Days until Halloween

Longtime readers of the blog will recall the first mention of Plutarch the parrot some time ago. To recap: I’m building an animatronic parrot as part of my recurrent pirate costume. I’ve had some success this weekend getting Plutarch’s proof-of-concept to the next level.

Plutarch 1.0 is not yet a robot: he currently lacks any way to percieve the world around him and relies entirely on a user with a remote control to direct his movements. Eventually he’ll get some sensors and some programming that will let him interact with the world, but for now he’s not much more than a remote control servo, an Arduino, and 4 AA batteries crammed inside a 3D printed body. One shudders to think of the wacky magnetic fields created by the rat’s nest of wiring inside his shell.

parts

I wrapped his RF reciever in a Ziploc bag and secured it with a rubber band. It works, but hoo doggies is it ugly.

rf

(The remote control is this nifty little guy from Adafruit.)

TODO: Stability and order! The purpose of this test was to ensure that Plutarch’s magnetic feet would be strong enough to keep him perched on my shoulder even with the torque created by whipping his head back and forth. He passes the test (barely) but it’d be nice to have a more reliable connection between man and parrot.

He’s got to stay on my shoulder for a couple of hours at a crowded Halloween party, which gets to be more and more precarious a proposition as the grog starts a-flowin’ and people are maybe not paying quite so much attention to where they’re going.

inside

Changing his batteries requires removing his head and digging out the Arduino and the battery case, which puts some physical strain on the electrical connections. One of them broke.

stress

Boooooooo.

The on/off switch on Plutarch’s back is also frustratingly flaky, a discovery which I of course made after epoxying it into place. I’ll have to get a new one in there before showtime.

Also it’d be really funny if he had a functional USB port in his cloaca.

While I’m waiting for some parts to arrive (I found a dozen replacement switches for the price of a latte) I can catch up on some much-neglected cosmetic additions to our hero. Plutarch’s body will mostly be covered in feathers someday, so there’s no need to worry about the layer lines created by 3d printing for most of his surface.

His beak is another matter entirely. Painting it directly will leave the print layers intact, which is going to look fugly. Instead, I masked out the beak with some painters’ tape and spread a thin layer of silicone caulk– the stuff you use to seal your bathtub– on the surfaces that will be exposed to outside observation.

silicone beak

Pro Tip: gently wipe down the caulk with a wet finger to get it really smooth.

I had some flourescent pink spray paint left over from painting Brenda the Tardigrade, so into the garage went Plutarch’s head for a couple of coats.

masked

Removing the tape reveals that our currently featherless friend is going to need a little touch-up before he’s fledged. Note the difference in texture between the coated beak and the raw plastic. Nice.

final beak

Once he’s stable, functional and unlikely to short himself out, I’ll start attaching feathers, and then Plutarch 1.0 will be done and I can move on to planning Plutarch 1.5 for Halloween 2017.

The Agony of The Feet

plutarch on rail

If, bit by bit, you replace the parts of a store-bought pirate parrot with 3D printed components and electronics, is it still the same parrot in five years?

Another Halloween has come and gone, and no, I did not festoon the house with an Arduino-controlled lightshow as I had planned to do in July.

Nor did I design and print that glowing Riddler sword cane I’ve been wanting to get to, and I also failed to make any headway on that EL wire and fog-machine witches’ cauldron I was so pumped up about two years ago.

What I did manage to do was stay married to the lovely and talented Mrs. Zheng3, who in addition to being lovely and talented also had the foresight to order us up a couple of relatively inexpensive pirate costumes from some online retailer.

See, here’s the thing about Halloween costumes. A store-bought costume is all well and good, but I gots ideas, man. Next time you and I are having a beer ask me about my plans for a two-person piñata donkey costume. If you whack us with a stick we’ll drop a bunch of candy out through a trapdoor in the belly. It’s-a-gonna-be-awesome.

pinata

Of course, I don’t have the time to make this. I also must make peace with the idea that I will never, ever, learn how to do DIY vacuum forming and craft myself a suit of Dr. Doom armor. The probability of my constructing an animatronic tarantula the size of a Great Dane approaches zero. Halloween’s an annual exercise in abandoning fun projects before they get started.

But you’ve gotta have a costume, right? Especially since we annually attend a spectacular haunted house/halloween party thrown by good friends of ours out in the boondocks of Hortonville, Wisconsin. Can’t show up there wearing my usual costume of cargo pants and free trade show T-shirts.

As she’s done so many times in the past, the lovely and talented Mrs. Zheng3 pulled my bacon out of the fire with an assist from Amazon prime and MasterCard, and now we’ve got pirate gear aplenty.

But what about next year? And the year after that? We’ve decided that our best option is to commit to the pirate life completely and upgrade our costumes by degrees. This year’s our baseline, and at some point in the next twelve months I’ll buy a nice set of leather boots to replace the cheap vinyl boot-tops that go over my dress shoes.

(The costume has a little tag on the inside that says, I kid you not, DO NOT WASH. Need to replace the shirt ASAP.)

do not wash

Maybe next year I’ll find a flouncy pirate shirt that can do double duty at the renaissance faire. And the year after that I can fall off my wallet and get a nice steel cutlass. And so on and so forth and in five years I’ll have a really great pirate costume just hanging in the closet.

We also bought a polystyrene parrot accessory. He doesn’t look too bad for $10 but the UX could use some love. At the most basic level, it’d be nice if I didn’t have to worry about my bird falling off to join the choir invisible every time I reach for the guacamole.

Plutarch’s original feet have two problems. First, they look nothing like actual parrot feet. Parrot feet are weird, and these are clearly sparrow feet repurposed by an overworked factory manager in Guangzhou.

original feet

Second, the feet don’t ship with a convenient way to attach to the wearer. Plutarch ships with a shoelace-like strap that’s halfheartedly hot-glued to his sole, intended to loop under his owner’s armpit. You’ll see from the Amazon reviews that this is a less-than-optimal solution.

Magnets are my go-to solution for holding things together. A while ago I bought a passel of tiny neodymium magnets for some long-forgotten purpose, and I still have about fifty of them left. A few minutes tweaking a cube in Maya gets me a pair of parrot feet with little sockets for the magnets. The magnets are friction-fit, but being a belt-and-suspenders type of hominid I’ve super glued them in.

feet magnets

A steel tuna fish can lid, easily hand-bent to be convex, hides under my clothing. I’ve covered the lid in athletic tape because it’ll be under a white shirt eventually and I don’t want it to show through.

feet pauldron

Besides, I’m nursing a rotator cuff injury, again, and have no other use for my athletic tape for at least a month. Feh.

Also, Coco gives approximately 6.02×10-23 f_cks about this parrot.

These feet are printed flat in ColorFabb signal yellow PLA/PHA, which is easy enough to deform post-print with a little bit of heat. A few months ago I bought this great little heat gun for heat-shrink tubing and it does a fine job helping me mold Plutarch’s toes to my shoulder.

plutarch shoulder

In the long term I’d like to put some motor control into Plutarch’s head so that he can swivel to look at stuff. And a webcam. And a speaker. And wireless control so that I can control the parrot from across the room.

I’ve already got a wee servo on order from Adafruit, so that’ll be next weekend’s project.

Like I said, I gots ideas. Check back in a year and we’ll see how far I’ve gotten.

Why Plutarch? Ship of Theseus, grandfather’s axe, and all that.

Lao Zheng out.