Freedom Odds

Guitar Motion Sensor

page 1 2 3 4 downloads


                         __
                       /`  `'-.
                      |     _  `\             This inexpensive controller senses
                      \'-,'` \   |            guitar motion and converts it into
                       /a a  |  /             computer commands that vary effects.
                       |/_   //)
                       \ __, `/
                     .'`\___.'('-.__          Vary reverb, wah, and other effects
                    /__ ;    /_   \ `\        just by waving your guitar around.
                   .`))'`\.'`  \___\  \       You no longer need foot pedals!
                  /  ((  |o       ))   \
                 /   ))  |        ((    \
 .--._          /    ((  |o       ))\_.  |    Lock-in the effects with the lock
`-,   `',,,._.-' '-./))  |        (.'   /     button if desired, or hit the kill
   '--`//// '-._ _.' (( _|o      .'  _.'      switch to bypass the system.  It's
       \```';-._'-._ ))( `-._.-'/__ /,        all at your command now!  
        `""`    '-._'-;_)      /  /   \
                    '-,_'-._(`-||||    \
                   _.-' '-.//-.\\\\_.-.|
                  (     .-' _.. ````;-.|                                        
                   '--;-.`-'   '._.'   /            ,.
                 jgs /   `'.         .'-,           |`:.
                    /      /`'-----'`|   ,          |  `:.
                   /      /    |     |    ,   m1a   | |`.`:;@.
                  /     /`     |     |     ,        | |;.`.`;|
                 |_    /       |     \      ,       ; `.';| || 
                 |     |       |_    |       ,     ,(`;.`.| ||             
                 |     /        \     \       ,___/8o (`:.  ||             
                 |     |         \     \        /o8888o  `; ||            
                 |     |          \     |     /@o8888888o (`;|  ______________
                 |     |           \     \   (`.()oO888888o (<  |`.____________`.
                 /     \            )-.__,'   `.`.;:oO08c{)/ |  | |_''_o_o__o =.|
               _.'`----;          .'     |       `.`.(),0 /  /--| | ,--.   ,--. :
             (`     .`-'         (     .-'         `.`.`/  /    | |( () ) ( () )|
              '---'`              `"""`              `.( /      `.|_`-_'___`-_'_|

Introduction

Wouldn't it be cool if you could move your guitar around to control effects like reverb and wah? If instead of having footpedals which anchor you to one place on stage, your rotation of the guitar did the control? That's what the guitar motion sensing project is all about. In fact, it may also be practical to sense your X, Y, and Z position on stage and control effects with that as well. Let's start by answering a few basic questions.

How is the Project Evolving?

Wow, the project is growing fast! The design is improving, there's plenty of interest on the guitar forums, and the hit counter is shooting up like a rocket! To keep up with it all, these pages have turned into sort of a blog, with the latest information on the later pages. So if you get bored, skip ahead to later pages, or go to the last page for the very most recent progress report. The pages are linked way up there at the top above the guitar player. I'm having a blast, this is fun! Enjoy!

How will it work?

It will work by sensing acceleration using one (or two) of the new miniature 3-axis accelerometer chips that are available today. These chips are very low in cost and they provide measurement of acceleration in all three axes: X, Y, and Z. The simplest, most fundamental way to use one of these is to sense the gravity vector. The earth, being so big and massive, has a gravity field that pulls us down to it. This is why nobody falls off of the planet as was suggested by Jimmy Buffett in his song "Defying Gravity":

I live on a big round ball                          _____
I never do dream I may fall                      .-'.  ':'-.
And even one day if I do                       .''::: .:    '.
Well I'll jump up and smile back at you       /   :::::'      \
I don't even know where we are               ;.    ':' `       ;
They tell me were circling a star            |       '..       |
Well I'll take their word, I don't know      ; '      ::::.    ;
But I'm dizzy so it may be so                 \       '::::   /
                                               '.      :::  .'
I'm riding a big round ball                 jgs  '-.___'_.-'
I never do dream I may fall                    
And even the high must lay low
But when I do fall I will be glad to go
Yes when I do fall I will be glad to go 

So the gravity vector is there, physics tells us it is actually an acceleration field, and we can sense it with an accelerometer. Depending on the particular angle of the guitar, we get corresponding numeric values on the accelerometer. We plug these numbers into a trigonometery formula and *poof* out pops our vertical angle, or phi. Then for the sake of simplicity we take the accelerometer reading that corresponds to a vector perpendicular to the guitar's surface and let that be our theta indicator, but we must integrate it twice to get the angle. And finally we can do some more computerized math tricks to get other information such as your horizontal position on stage. Actually the practical details are a lot more complicated than that, and I'm not fully certain of what possible configurations will lead to what positional information, but that's the basic idea. Certainly we can get two and probably three foot pedals worth of control out of a single-accelerometer setup.

How much will it cost?

Not much, if you already have a computer or can scrounge one up for a good low price. The accelerometer chips are about ten bucks each, and the support circuitry is not a whole lot more, so once the project is boiled down to a fully custom circuit board that mounts on your guitar it will be very inexpensive. Unfortunately the chips are so dang tiny that they cannot be soldered by a hobbyist, so we must purchase them mounted on specialized little "breakout boards" that some small companies are providing. These boards are about $35 US each and you can choose to have either one or two of them depending on how many pedals you want to simulate. The USB interface board is another $35. Then you can add an enclosure plus some way to attach it to your guitar and a long USB cable. So estimate a total cost for everything of around $100 for a Do-It-Yourself project. Later, someday soon perhaps, there is the possibly that a fully optimized product will sell for perhaps $50 or lower. There really isn't all that much stuff in the thing. Oh, and the software will be free or cheap as well. At least *my* software will be free, though I'm not certain just how many effects I will be able to create - we will have to wait and see about that. If someone else jumps on the bandwagon and creates many custom effects or otherwise adds value with their own software product, they will naturally want to receive at least some modest reward for their effort. Also you may want to buy an optional external USB sound card for optimal sound quality, microphone input, or multichannel input, but that is optional. So there are some costs involved but overall it won't be all that ridiculously expensive at all, especially compared to the prices that people are willing to pay for good guitar effects.

When can I buy one?

You can either buy an existing product called a HotHand, or build the project that I describe on these web pages, read on for details.

If you've got the skills and motivation, you can start with the information on this web page and build your own working guitar motion sensor in a very short time, assuming all goes well. Of course, you'd also need to have the software background to program the whole monstrosity as well. However if you're not so adventurous, then I'm guessing that I'll have a completed working unit and more detailed instructions on the internet for you to build one yourself by the end of 2008 at the very latest, or perhaps much sooner than that I hope. If you don't want to build one yourself, I suppose that someone, myself or someone else, will probably start making the product for you to purchase. It all depends on supply and demand, you know, basic economics.

In addition to waiting for my project to be complete, I should mention to you that you can buy an existing product today that does the job, or close to it. To learn about it, go to the top of page 2, where I describe the HotHands product.

What can you tell me now?

A lot. Read on for a virtual core-dump of all the information that I have about guitar motion sensing using accelerometers. I love freeware and sharing information with others on the web. Few things please me more than when people share hard-earned information for the benefit of us all, so I do that myself in every way possible. Let's start with some descriptions of the hardware and software in detail.

The Hardware: A Choice!

Actually the USB solution that I described above is just one of two alternatives. There is also the WiiMote solution. Yes, I said WiiMote, that revolutionary little inexpensive wireless hand-held controller for the Wii gaming console. That WiiMote. It turns out that the thing works on the BlueTooth local wireless networking standard and it also happens to have a 3-axis accelerometer chip in it. Furthermore, working code has already been developed to sense the WiiMote on the ChucK music programming language that I will be using for the software side of the project. Sounds great, so why am I planning to go the USB route for my first try instead of just using a WiiMote?

There are a few reasons. First of all, the WiiMote solution is not cross-platform. It works on Mac one way, Linux another way, and I'm not even sure if it works with Windows at all. So for a first initial release, the WiiMote solution would be problematic to support, software-wise. Second of all, the WiiMote solution requires OpenSoundControl. That would be OK if I actually understood how to program in OpenSoundControl, but I don't at this time. And anyone who has ever done a custom one-of-a-kind development project will tell you that you're better off if you utilize skills that you have rather than expect to learn something along the way. Third of all, the WiiMote is a wireless solution. This is good in that you don't need to run a USB cable along your guitar cable, but it is bad in that it is vulnerable to radio interference. For example, say some smarty-pants decides to bring his own WiiMote to your performance and start pressing buttons just for the heck of it. You may or may not be vulnerable to such foolishness, and I really don't know if you are. Why take a chance? Trust a wire instead. Fourth of all, I do not have BlueTooth on either my Mac or my Linux computer. It would be something else to buy, another $50, something else to figure out, something else that might not work or need to be configured or incompatible or need drivers or... you get the idea. "KISS" is the name of the game, or "Keep it Simple, Stupid!". Oh, Fifth and final reason: I want to use two of these accelerometer chips and the WiiMote has only one. So for those five personal reasons I'm going the USB route first. Besides, I can always add WiiMote support later once I get the USB version working.

The USB Solution

OK, OK, OK, we can do it the USB way first, sheesh! What does the USB solution involve? Well, it needs a USB interface, one or optionally two accelerometer boards, some way to hook them up together, some way to mount them on the guitar, and finally a long USB cable. Where can we buy the circuit boards?

I have searched the web and consulted peers extensively for the answer to this question. There are several alternatives from which to choose. My conclusion is that the best USB interface for the job is the Utltimarc A-PAC2 product, available here. The primary advantage of the Ultimarc A-PAC2 product is that it requires no programming whatsoever. Further, it requires no resistors, capacitors, configuration switches, and is basically a no-brainer solution (remember the KISS concept). The board provides +5V power from the USB cable and receives six analog input signals. That's it. No other complicated anything to configure or worry about, just power out and 6x analog in, what could be simpler? And it has mounting holes for securing it to the guitar, plus it comes with a color-coded ribbon cable for wiring everything up. They couldn't have made a simpler, easier, better product for this job if they were trying to, so that's my choice. Oh, one more detail: the A-PAC2 product is designed to look like a six-axis gaming joystick to the computer's operating system. All the other alternative products either had custom drivers that were not cross-platform, or simply did not make any mention of how you actually talk to the thing! A little information please, people - I don't ask for much, just what I need to make a proper purchasing decision - so why was it so difficult to figure out most of the other products? I dunno. The A-PAC2 *should* do the job nicely.

I have also searched diligently for the best accelerometer breakout board for the job, and found this one. It's the DE-ACCM3D Buffered 3D Accelerometer product from Dimension Engineering. What makes the Dimension Engineering product so good for our project is that it not only has buffers for our analog signals, which are high impedance and therefore *need* buffers, but it also has a supply voltage regulator to step down the 5 Volt supply from the USB interface to the 3.3 Volt supply that the chip requires. The one competing breakout board that I found just had the chip on it and did not have these necessary features. Plus there are plenty of two-axis and one-axis alternatives, but we want all three-axes for our project. Why go through all this effort and not get the full effect from the hardware? There is just one issue to be dealt with regarding these Dimension Engineering breakout boards, which is the filter capacitors. It turns out that the ADXL330 accelerometer chip that we are using has an analog bandwidth that is set by a capacitor on each of the X, Y, and Z output pins. Dimension Engineering has decided to put very small capacitors on their product, resulting in high-bandwidth signals. We don't need that much bandwidth for our purposes, and I really don't know for sure but I suspect that the USB interface or the software interface or both will have a bandwidth limit that is below that of the Dimension Engineering boards. Solution? Easy: solder new caps on top of the existing caps on the board. More on that later.

Visiting Radio Shack

I have a love-hate relationship with Radio Shack. On the one hand, they have parts on display that you can touch, feel, examine, and actually purchase from retail outlets everywhere. On the other hand, they maximize profit by charging outrageously high prices for the lowest quality parts available. So why would I buy all the various miscellaneous parts for this project from Radio Shack? Because you can too. In other words, availability. I want you to be able to get all the parts you need in one trip if you want, plus go back if you forgot something or lost it or broke a part or whatever. This is not necessarily practical with mail-order electronics distributors like my very favorite supplier, Digi-Key (1-800-digikey), web page here. So not now but when the time comes I will be buying the miscellaneous parts for the project from Radio Shack. What do we need to buy?

Let's see... We have our USB interface board, a color-coded ribbon cable, and two little miniature circuit boards that by the way are designed to be plugged into a 16 pin dual-inline package socket, or DIP socket. We could just wire all this up but then we would end up with a sproingy chaotic mass of wires and chips, yuck! Instead of that, let's do it right. We'll need a proto-board, which is a circuit board designed for mounting chips and other circuit components. We could make something custom out of wood or fiberglass or plastic sheet, but a protoboard already has holes drilled and solder pads etched plus it will either have mounting holes or we can drill them out. Then we need two 16-pin DIP sockets to hold the accelerometer boards. The wiring harness is enough for most of the wiring, but we'll need to jumper the power and ground signals from one chip to another, so we'll need a spool of small-gague wire, preferably stranded and 22 or 24 gague. We need a little solder and a soldering iron if we don't have that already in our shop. Plus we'll need some mounting hardware to attach the two circuit boards together, probably some hex standoffs of some sort.

What about the case, and how do we attach the whole conundrum to the guitar? I happen to like the look of bare electronics, so I'm thinking that instead of a plastic or metal case, I'll just use a conformal coating to protect it from the possibility of stray shorts or static electricity. Though some electronics hobbyists and professionals may laugh and point, I find that clear spray-paint is a good substitute for the expensive conformal coatings that one can purchase. Other alternatives include pigmented paint - you can draw your own designs, sign your name, put an image on it, or whatever. Or else perhaps you could get a can of that thick gooey stuff that you dip tools into and dries to form a rubbery handle for the tool. I rather enjoy that last alternative, but I prefer the clear spray-paint or not coating at all just in case I need to work on it. Either you do that or you buy/make an enclosure for the thing, it's your choice. I should also mention that people have gotten creative with electronics enclosures as well. I've seen stuff like tupperware, cigar boxes, Altoids mint tins, etc., and in fact I put the very first electronics project that I ever built into a salt water taffy box from the New Jersey Shore. So be creative and make it your original work of art!

As for mounting it to the guitar, I plan to use velcro strips, really strong ones not the weaker type. That way I don't need to drill holes in my precious Fender guitar and I can always remove the stick-on velcro from the guitar later, or so I hope. That's the plan anyway, for now at least. I'm a little concerned about the possibility that the velcro will generate static electricity and zap the chips, but I've never heard of that happening. Maybe I'll rethink the matter. We'll see.

Oh, and by the way, we will need a USB cable of course, preferably a 10 foot long one or longer. I'm not sure where to get that, but probably Radio Shack will have them and if not then try an office supply store. You need the kind that connects from the computer to a USB device, I'm not sure how that's worded in the industry. I know, I'm a little uncertain about some of the details... Well, I haven't been there / done that yet or I would know. This is still in the planning stages for heaven's sake!

ChucK the Software

No, don't ChucK it out the window! Write it in ChucK! ChucK is the name of a fantastic software programming language that I have discovered in my electro-techno-webified music journeys. It has many of the features of a software synthesizer, works kind of like a guitar pedal board, and also has a complete, full-fledged programming language to boot. You can do tons of stuff with ChucK and having programmed for nearly 30 years on literally dozens of programming languages, I can say without a moment's hesitation that I get more fun out of ChucK programming than any other programming language ever. ChucK is fun, ChucK is easy, ChucK is free... it's ChucKtastic! OK, ChucK commercial over. So being such a happy little ChucKist, naturally I turn to ChucK for programming up the software for my guitar motion sensing project.

Wait a minute, does ChucK have all the capabilities that we need? Yes, and then some. There is just one feature that we are waiting on, but we can get by without it for now. Specifically, that is cross-platform compatibility for the Graphical User Interface, or GUI. Right now ChucK has buttons, sliders, windows, and fancy stuff like that only on the Mac platform. We are still waiting for the Linux and Windows versions to have GUI suppport, and waiting, and waiting, and waiting it seems. The weeks roll by and become months and still we wait, but fear not, it is promised in the next release. And that's ALL we need.

Besides a GUI for easy use by musicians, we need a way to communicate with the USB interface first of all. ChucK has that in the form of a gaming joystick interface. Actually I'm not yet sure if ChucK's gaming joystick interface supports all six of the axes that we need, but I will find out when I get there. We need ChucK to convert the accelerometer data into theta and phi angles, plus do subtraction and mulitple integrations to obtain the X, Y, and Z position information. No problem, ChucK has trigonometry and we can program integration fairly easily. We also need ChucK to do our effects and to vary them in response to the angular data. ChucK has three types of reverb, a pitch shifter, and delay lines built-in for us to use. ChucK also has filters, signal sources, FFT and IFFT capability, and lots of synthesized instruments of its own to play around with if we want. We also need ChucK to receive the guitar's audio sample stream from the external guitar sound card that we will be using. No problem, I'm told that ChucK can do that although I have no external guitar sound card with which to test it at this time - that should be OK. ChucK must also route the effects-processed audio signal back out to the sound card where it can be converted into analog and sent to our guitar amp. ChucK can do that too, I'm told.

ChucK must also be cross-platform so that we can use whatever computer that we happen to have available to us, be it a Mac, a Linux box, or (ugh) Windows. No problem there, although there is some question of whether it runs properly under one of the flavors of Windows, I forget which one. But basically, yes, ChucK is cross-platform. ChucK must also be freeware so that any musician on a budget can use it, and that's the case since ChucK is released from Princeton University under the GNU General Public License - yes, it's freeware. What else do we need? I dunno but that's a lot and ChucK has got it all! (You can tell I'm a ChucK fan, can't you?) And by the way, you get ChucK here.

The Accelerometer Chip

I also happen to be a fan of the company that makes our three-axis accelerometer chip. Not that I'm going to write a cheerful list of virtues for them like I did for ChucK above, but I've had good experience in using their products and I consider them to be one of the more top-notch companies. Who are they? Why, Analog Devices, of course! Actually my favorite chip maker is National Semiconductor, but Analog Devices is a close second, and I ramble now so let me refocus! Let's look at the chip!

Go to the Analog Devices front page which is here. Then in that search box type: ADXL330 and click on the GO button. See that link in the Quick Links Window to the left that says "Data Sheet rev A"? Click it! (note: if you click on the "Data Sheet" link in the "On This Page" window it just scrolls down the screen, you need the link on the left in the Quick Links window to get the data sheet.) Your puter should download the datasheet and open it up in a pdf file viewer for you, or else do it manually.

Important: RTFM! That means Read The F-ing Manual if you're not familiar with the acronym, and in this case it means that you should read this datasheet thoroughly if you're going to do this project. Read it if only to get a good feel for what the chip does. Read it! I call your attention to the following details... First of all, look at the Functional Block Diagram on the first page. Notice the four external capacitors: there is one called C_DC which is for supply voltage decoupling, and three called C_X, C_Y, and C_Z, which are for bandwidth adjustment. The accelerometer breakout board(s) that we will be using have these three bandwidth capacitors on them, but they are small in value. If you are just using one accelerometer board and you just want to simulate two pedals at a time, then I *believe* that you will not have to muck around with these capacitors, you can leave them as is. If you are using two accelerometer boards because you want to simulate more than two pedals at a time, then *IMHO*, you will have to muck around with these capacitors, but I'm really not quite sure yet.

Second of all, look on page 12 at the paragraph titled "Setting The Bandwidth Using C_X, C_Y, and C_Z". Then look at the table in that paragraph. The column on the left is the bandwidth, which is a measure of how quickly the accelerometer responds to changes in acceleration, or in other words how it responds to vibration. The column on the right is the capacitor value that sets that bandwidth. We don't need a whole lot of bandwidth, I mean you're not going to swing your guitar in a circle 500 times per second, are you? Perhaps the fastest motion we will ever need to sense is about 10 Hz or at the very most, 50 Hz or so. That would be if we decided to detect the guitar player knocking on the guitar body as a kill-switch signal or something. What does this mean? It means we may have to solder capacitors onto the accelerometer boards. If that is the case, then we will have to look really close on the boards and identify the location of the three capacitors, then solder additional capacitors on top of the existing ones. To be perfectly kosher about it one would remove the existing capacitor, but that is not easy to do since it requires heating up two solder joints simultaneously and could result in damaging the little circuit board pads by lifting them up off the board. So instead, if we must do this, I recommend soldering the larger caps directly onto the existing caps on the board. Now I happen to know that we can get 0.10 uF capacitors in those little surface mount packages, but I'm not sure if we can get 0.47 uF caps that small. It would really be better if we could do this with 0.47 uF caps, to be on the safe side, and end up with approximately a 10 Hz bandwidth. So I'm going to recommend soldering through-hole capacitors onto the surface mount pads. It's a bit of a kludge and requires some microsurgery so it's not for everybody which is why I am taking the time to explain it in such detail. In fact, I think I'll call an end to this corner of the web page for now because I really don't know if we do in fact need to do this or not, and there's no way for me to determine it until I have a working system in my hands to test. So the jury's out on that one and all I ask you to remember from this blathering is that there's something possibly important about those dang little capacitors and we'll deal with them later.

Third of all, also on page 12 is a paragraph about the self-test feature. We will not be using the self-test feature and it is disabled on our boards so no problem there. OK, Fourth on the list is to go to page 4 and look at the Abolute Maximum Ratings Table. Notice that Vs is listed with a max value of 7V. Some people I corresponded with were under the mistaken impression that this meant that we could run the chip at a supply voltage of 5V from the USB wire with no problem. This is totally incorrect, and it took me a while to figure it out so I'm taking the time to point it out to you. Reading to the right of the Absolute Maximum Ratings table we find a paragraph which states:

"This is a stress rating only;  functional operation of the device
at these or any other conditions above those indicated in the
operational section of this specification is not implied."

Which is technical gobbledygook and legaleez meaning "Don't run the dang thing at 5 Volts or you'll break it!". So from this we learn that our accelerometer chip(s) will be all cozy and happy at 3.3 Volts supply, which is why we need to buy the Dimension Engineering breakout-board or otherwise provide the supply regulation ourselves. Just a little detail there, but an important one to be sure. Um, besides that, just glance over the rest of the data sheet and get familiar with the part, I'd suggest.

The Kill Switch

I had not thought of putting a kill switch into the project, but two of the guitarists who I corresponded with mentioned the need for one as a primary consideration. After all, sensing acceleration is a bit complicated, it's an experimental system, we don't know how reliable the whole thing is going to be, and if we're on stage we need simple solutions to complex problems. So we need a kill switch.

For the WiiMote version of the project, we can just choose the biggest button on the WiiMote and make it the kill switch, no problem there I suppose. For the USB version we have a bit of a limitation to deal with here. You see, for those of us who choose to have two accelerometers, all six of the analog inputs are used up. And there are no digital inputs or other complexities, in fact it was that very simplicity that led me to prefer this particular USB interface. So hmmmm, how do we implement a kill switch on the double-accelerometer USB version?

I say we use gestures, specifically the knock gesture. If you knock on the guitar just like knocking on someone's front door to let them know you are there waiting for them to open the door, then the whole system shuts down and routes the "clean" guitar to the sound card output. Then, if you want to turn the system back on you just go to the computer and do something simple and easy to do, such as press the spacebar. I can think of other tricks, such as installing and wiring a switch that shunts zero volts to all three outputs of one of the accelerometers to act as a kill switch also, and users may want a feature like that. I know if I was onstage and my reverb went loony, I'd want a big red button to push that would fix it all. Of course the ultimate kill switch is to just unplug the guitar from the sound card and plug it into the amp. That's an alternative too. We will have to wait and see with time and experience what works as a practical kill switch.

More to Follow

Well, dear reader, if you've gotten this far then you've probably been reading my silly gibberish for some time now. I hope you enjoyed the writing and my somewhat awkward sense of humor, plus learned all that there is to learn about the guitar motion sensor project at the time of this writing (July 2008). I'll be updating this page as I learn more and get around to writing about it. For now you should have enough information to go about the project and possibly even get it done before I do, especially since I am waiting for finances to clear up so I can purchase hardware. So whether you choose to simply be aware of the project for future reference and possible purchase later, or plan to build one yourself, or even if this concept is just not for you, I wish you the best in your guitar-playing adventures! Oh, and remember that I am just an email away if you have any questions or suggestions. Cheers, have fun, and good luck!

Sincerely,

Les Hall

copyright 2008 Les Hall

My stuff: Sports Prediction, Commentary, Oscillator, Music, HS TechSpy, and Dome Homes.

Web Site Hit Counters
Hit Counters
Contact me inventor-66@comcast.net