# Gauging Interest: Raspberry Pi audio servo controller



## ViennaMike (Nov 24, 2010)

*Raspberry Pi audio servo controller*

I've just started working on writing software to use a Raspberry Pi an an audio servo controller to control the jaw of a skull (filling the role otherwise filled by a Scary Terry type board, or Jawduino or Wee Little Talker). The code will be released as free open source once I've got the initial version working, but I'm curious whether or not others are interested and might use it if available.


----------



## David_AVD (Nov 9, 2012)

I don't have an application for it right now, but I'm interested to see how a pi would be used for prop control.


----------



## crpalmer (Sep 3, 2011)

I use raspberry pi's for all kinds of props. Here's a link to my talking skull implementation if you want it:

https://github.com/crpalmer/pi_lib/blob/master/talking-skull.c

I use this for playing random audio tracks and I also use it with a microphone (which let's people make a prop talk).

I also create an Android app which let's you remotely control the audio. Very nice platform for prop control.


----------



## Brianaala (Nov 4, 2018)

While I love this stuff, why use a pi to make a Jawduino? Arduino is cheaper. Will the raspberry pi allow it to do more?


----------



## DarkOne (Oct 16, 2012)

I'm definitely interested. I have a few pi zeros and zero w's waiting for something to do.


----------



## ViennaMike (Nov 24, 2010)

DarkOne said:


> I'm definitely interested. I have a few pi zeros and zero w's waiting for something to do.


I should have something posted within 1-4 weeks. It's actually coming along more quickly than I expected, but I'm awaiting some parts for more testing of the code. A Pi with WiFi, like the Zero W, will probably be easier to work with (in headless mode), since you'll want to edit some setup files. I'm using a Pi 3A for development, but I plan to test it on a Pi Zero W as well.


----------



## Brianaala (Nov 4, 2018)

Super cool! I can't wait to see what it can do!
I also have some Pi Zero W's around with nothing to do.


----------



## Drakul (May 12, 2009)

I would definitely be interested but why stop with a single servo controller? Anybody ambitious enough to write code to drive a three axis skull (four servos - Up/down, side/side, left/right, jaw) and coordinate it with a soundtrack? Now that would be cool!


----------



## ViennaMike (Nov 24, 2010)

That would be cool. What I'll be doing is a bit simpler. I'll use the Raspberry Pi as the audio servo controller for the jaw, but it will include a TRIGGER_OUT pin that then can be used to start running a canned routine on a specialized servo controller for the other servos in the skull. I use a Maestro servocontroller from Pololu for that. They already have a nice piece of software for writing the servo routines and saving it on the controller for stand-alone operation.


----------



## Drakul (May 12, 2009)

Good info, ViennaMike, thanks! I don't have time these days for much programming but do you know if the RPi has enough output pins to control four servos?


----------



## ViennaMike (Nov 24, 2010)

Drakul said:


> Good info, ViennaMike, thanks! I don't have time these days for much programming but do you know if the RPi has enough output pins to control four servos?


It does have enough output pins. It's limited to two hardware PWM timers, though (only one on older boards). So you need a GPIO library that supports DMA PWM (which is good enough for servo control, whereas software PWM is not. There's a c library that supports up to 8 servos (https://github.com/richardghirst/PiBits/tree/master/ServoBlaster), so it's definitely possible. In python, you'd want a GPIO library that supports DMA PWM.

The nice thing about an external servo controller like the Maestro is that it already has a scripting language for writing complex control scripts for the sets of servos (sending movement commands is the EASY part  ). For what you had suggested in your previous note, you'd probably want to create a simple language like that to make the coding easier and more flexible.


----------



## Drakul (May 12, 2009)

I see what you mean about the Maestro. For $20 or so, I'm sure it's worth the investment to save a bunch of programming pain. Which version of Maestro do you use? It looks like the Micro-Maestro 6 would be enough to control a three axis skull. How difficult is it to coordinate the servo operation with a soundtrack? I currently use VSA to drive my three axis skull but am getting tired of having to run cables from a laptop to drive the prop. I would much rather go with something like a Boobox but they're relatively expensive... an RPi and Micro-Maestro looks like a good alternative solution.


----------



## ViennaMike (Nov 24, 2010)

I've used the 6 channel micro for a 3-axis skull. That one has somewhat less memory than the larger ones, but so far I haven't found that to be an issue.
I've programmed it two ways. 

When I built Yorick (a skull connected to a Raspberry Pi serving as an Alexa device) I used Vixen (version 2, not the completely different version 3) to program the controller, as there is a servo controller plugin for Vixen 2. There's even a 3D skull add-on someone made to help visualize things. It was quite a pain, to be honest, but I really liked the results (you can google "alexa" and "yorick" to see video). 

For simpler things, I just opened my sound file with Audacity to view the timing, and hand-coded the movements using the Maestro's built in scripting language. It takes a little getting used to how to code in it, but it's not bad, and worked fine.


----------



## ViennaMike (Nov 24, 2010)

Brianaala said:


> While I love this stuff, why use a pi to make a Jawduino? Arduino is cheaper. Will the raspberry pi allow it to do more?


Bottom line, yes. Although folks have added to the Jawduino, the basic Jawduino takes audio from an outside source and controls a servo. End of story. This Pi implementation can be on all the time, but can also trigger off of either an outside sensor like a PIR, can light up LED eyes and trigger another prop or device, can either use an outside audio source or store the audio on the Pi (no external shields required), play multiple files in order, and also offers the option of filtering out high and low frequencies before determining the jaw setting, as the Wee Little Talker does.

I'm developing it on a Pi 3A+, but I'm pretty sure it will run on a Pi Zero and plan to test that, so it's pretty cheap. You do also need a USB sound card, but I picked up one that's working well for $5 from Adafruit.


----------



## ViennaMike (Nov 24, 2010)

crpalmer said:


> I use raspberry pi's for all kinds of props. Here's a link to my talking skull implementation if you want it:
> 
> https://github.com/crpalmer/pi_lib/blob/master/talking-skull.c
> 
> ...


Thanks! I'm pretty much a novice at C, but from what I could follow, a lot of good stuff there (and in your library in general).


----------



## ViennaMike (Nov 24, 2010)

*ChatterPi initial version is up and running!*

Good news, the initial version of my Raspberry Pi audio servo controller software, which I've named ChatterPi, is complete. You can see a video demo: 



 (the jaw is controlled by ChatterPi, the other movements with a Maestro servo controller). There's a full write up, with links to the code and a complete Users' Manual on my blog: https://www.mcgurrin.info/robots/690/
UPDATE: 7/13/2020: this note orginally stated that it would not run on a Pi Zero. I found the section of code that was taking to long and rewrote it. It now runs fine on a Pi Zero, saving a few bucks in implementation!


----------



## Batbuddy (Sep 3, 2014)

Sweet Work! And thanks for the mention of my site in your Blog. I will have to give this a try, Now where did I put that Pi...


----------



## ViennaMike (Nov 24, 2010)

Batbuddy said:


> Sweet Work! And thanks for the mention of my site in your Blog. I will have to give this a try, Now where did I put that Pi...


:biggrinkin: You're welcome. I definitely freely used concepts and features from the Scary Terry boards, your Jawduino, as well as the Wee Little Talker.


----------



## IMU (Apr 8, 2009)

*Wow*

Oh great, another project I want to try. :googly:


----------



## ViennaMike (Nov 24, 2010)

Update: I've modified the code to improve the slow section, and it now runs just fine even on a Pi Zero. So folks with a Pi Zero, have at!


----------



## ViennaMike (Nov 24, 2010)

Update: Several users found a couple of issues, which have now all been resolved in the latest version, and there's now a Pi SD card image file, so you can get up and running more quickly, without having to download and install all the dependencies and then install the ChatterPi software. The code is all available at GitHub - ViennaMike/ChatterPi: Flexible Audio Servo Controller using Raspberry Pi (for talking skulls, etc.) and there's a write up at https://www.mcgurrin.info/robots/690/


----------



## Batbuddy (Sep 3, 2014)

This is very cool Thanks for sharing.


----------



## Greg G (Nov 4, 2012)

Yes, thanks for sharing and well documenting it.


----------



## ViennaMike (Nov 24, 2010)

I'm happy to report that ChatterPi worked like a charm this Halloween, controlling my animated skull's jaw movements throughout the night, and triggering the pre-recorded other skull movements to run in the Maestro servo controller:


----------



## Greg G (Nov 4, 2012)

Very nice. That worked out quite well. I think I might switch my prop mouth over to voice activated servo too. Right now for pre-recorded stuff I use my IMU to follow my mouth movements then just sing/talk along as the audio is playing to sync to the audio. I'd like to be able to do both so I can open the mouth even when there is no audio playing to it (like when you open your mouth in amazement but aren't saying anything, and other situations like that) in both pre recorded and live interactive.


----------

