Look, ma, no wiimote!

(UPDATE: 2 new features, with videos, at the end of the post)

I thought I could improve my previous design, so I ordered some toys from Sparkfun:

– An Arduino Pro Mini

– A pair of 2mW Xbees with chip antenna

– An Xbee explorer regulated

– An Xbee shield and an Ethernet Shield

– A FTDI breakout

– … and some other glue accesories.

I had several objetives in mind. The first one was to  improve the design so I wouln’t have to depend on the Wiimote (and its external cabling). Second, I didn’t want to depend on Bluetooth, due to its (supposed) limited range. Third, since I’m very new in the microcontroller business, I wanted to learn how to wirelessly connect Arduinos. I also wanted to do something that in the end could be very open and very easy to use with any platform. Finally, I wanted to have fun! Then I considered this idea:

Replace Mac with any ethernet-equipped computer you want

This way you could interface with a wide variety of hardware computers and sofware. Of course, you could link to the computer via a serial link, but I considered the OSC option much more interesting.

1. The Transmitter circuit(s). I had to put together 3 blocks: Arduino Pro Mini+Xbee+Xbee explorer, the nunchuck guts and a power stage. This last block was necessary because the Nunchuck needs to be powered by 3.3 volts, but the Pro Mini I bought supplies 5 volts (it can be fed with 5 to 12 volts). There’s a version of the Pro Mini which works at 3.3 volts, but at the half of the speed (8MHz, in contrast to 16MHz of the 5V version). It might have been a good idea to have used the 3.3V version but I wanted the maximum speed possible. However I have to admit that I’m not sure if that extra power is really necessary for this application… anyway, I used a 3.3V regulator with the corresponding decoupling capacitors, a 10nF on the input and 10uF on output, as suggested in the datasheet:

Power stage diagram
Power stage diagram

And this is how it looks:

Power stage, embellished

I cut the Nunchuck cable releasing the 5 smaller cables inside. The green cable is the SDA (data) line, and the yellow one is the SCL (clock). These must be connected to inputs 4 and 5 of the Arduino Pro Mini, because the I2C protocol uses these specific ports (see the Wire library documentation). This is how the Nunchuck should be wired. You can safely ignore and cut the black cable:

Wired guts
Wired Guts

The Arduino pro mini can be fed directly from the batery into its RAW port. For easier debugging, I soldered some male headers to the Arduino, and female headers to the Xbee explorer.

FTDI+Arduino

This way I could easily connect the Arduino to the FTDI breakout for programming (as shown in previous picture) and to the Xbee explorer for testing the circuit. The pinouts of all the components fit perfectly with this setup.

2. Installing the Transmitter. I had some troubles with the orientation of the Nunchuck I previously used, and I also wanted to increase the visual impact of the design, so I re-created the back cover of my guitar:

Back cover
Back cover

I cut it from a transparend DVD box. Then I measured very carefully (ok, not so much) every block I had to put inside, and drilled the necessary holes for the plastic bolts which would hold the circuit boards:

Ready to go inside the guitar
Same from this side

I was worried that the microcontroller could touch a potentiometer inside the guitar and cause a short, so I made a small cover for it out of a plastic folder:

Arduino, undercover

I just connected a 9V battery to the regulator and finally closed the thing. This is how it looks:

Hey! I can see through your blouse!

And you are hot, baby!
The whole thing.

Pretty neat, huh? For the curious, it’s a Vampire Red Schecter 006 Deluxe. It’s an expensive, but very good quality guitar, and the only electric I own, so I’ve been very careful with it.

3. The receiver. The receiver is basically a Duemilanova with a Xbee shield on top of an Ethernet shield:

The receiver

The problem with it is that the Xbee shield uses the ICSP connector for power (and maybe something else), so when I sandwich the Ethernet shield in-between, the Xbee loses those pins. That’s the explanation of those ugly green cables:

Ugly cables

At this point, the USB cable is just for powering the Duemilanova, because all data is sent to the computer through the Ethernet port, in OSC form. Now the software part.

4. Program the Xbees. This was the most painful step, not because it’s hard, but because there’s no “definite guide” to do it. There are some things that depend upon the application, and there are some others which I think each person has to learn in the way. The steps for doing this are beyond the scope of this post, however, there are a few good tutorials in the Net. I personally used information from the Ladyada tutorial, (though it’s better if you have the Xbee adapter kit from Adafruit Industries) and specially this “How-to: Setting up XBee ZNet 2.5 (Series 2) modules“, by caimaver@yahoo.com. Also, this document is useful to understand the AT commands that can be used with the Xbee. In any case, it’s a good idea to install the X-CTU utility, and also the latest Xbee firmware. The problem with the X-CTU program is that it only runs on Windows, so take that into account (it can also be run in a virtual Windows installation, using VirtualBox, or other virtualization programs). Some Xbee parameters can be programmed using a terminal program, but some others not. In my case, I programmed the Receiver as a “ZNET 2.5 COORDINATOR AT”, and the Transmitter as a “ZNET 2.5 ROUTER/END DEVICE AT”. I used a baud rate of 57600, used a different Pan ID than the default and labeled the nodes with some string.

5. Code for the Transmitter. Well, I started with the nunchuck guts from my previous design, so I didn’t need to buy a new accelerometer. Also, I wanted to give a try to the I2C protocol which is used in the Wiimote-to-Nunchuck connection and is supported by the Arduino. For that, I checked the nunchuck_funcs.h library written by Tod E. Kurt. I also used his WiiChuck adapter, which can also be found in Sparkfun. That way I could debug the Transmitter code in the Duemilanova before uploading it to the Pro Mini with the Nunchuck soldered to it. Download the code from here. It transmits data from accelerometer, two continuous controllers and two push buttons (which I am not currently using), when it detects a change in the input, polling at intervals of 1 millisecond, and sends the data through the serial link formatted like this:

acc xxx xxx xxx
cca xxx
ccb xxx
bta x
btb x

Where acc is the accelerometer data, cca and ccb the continuous controllers and bta and btb the push buttond.

6. Code for the Receiver. The receiver uses the Ethernet library, the excellent Recotana ArdOSC library and the Messenger library, by Thomas Ouellet Fredericks (for parsing serial input).  Download the code from here. You’ll notice that both, the receiver and the transmitter code are pretty simple. The receiver parses the serial input and generates OSC messages according to this address space:

/guit/acc , fff
/guit/cca , f
/guit/ccb , f
/guit/bta , f
/guit/btb , f

I think the addresing could be improved, specially the data types.

That’s all. I’ll post some video soon (I hope) Done! Here you can see how the guitar controlling Pure Data:

UPDATE:

I added a ribbon controller to increase the interaction possibilities. It’s a SoftPot connected to the unused potentiometer input of the Nunchuck:

I had unstable readings from the SoftPot, but I’m not sure if it’s due to the SofPot or to the Nunchuck. For now, I’m correcting that behavior within PureData.

I also implemented a very simple auto power-off mechanism. It’s very similar to those found in guitars and basses with active pickups. I simply replaced the original mono jack in the guitar with a stereo one, and wired it like this:

Auto power-off.

This way, when I connect a standard mono guitar cable, the battery gets connected powering up the internal circuit. Just in case you don’t believe me, you can see it working here:

I hope you enjoyed it.

Thanks for reading!

JP

23 thoughts on “Look, ma, no wiimote!”

  1. Hijo, para entender eso, creo que hay que ser ingeniero electrónico. Se ve que ha sido un arduo, creativo y muy inteligente trabajo. Yo de verdad te felicito y te reitero mi convencimiento de que tu eres capaz de cualquier cosa. Un abrazo con toda mi admiración. Te amo

  2. Hijo tu mamá tiene toda la razón, que pasa si se le cae a uno la guitarra… hace el mismo ruido que una de Woodstock o la puedes modular durante la caida___???

  3. Hermosito, me encanta lo dedicado e inteligente que eres.
    Un nerd bonito.
    Vas a ver que esto es de publicación!!
    Bisous, mon petit jolie!

  4. Ni Clapton ni el mismísimo Santana soñarían con semejantes sonidos.
    Felicitaciones, sobrino. Rerere-bacano.
    Un abrazo, Poncho

  5. Does anyone have any knowledge with the Philips MC235B Flat Wall Mountable Micro Shelf System I was thinking about obtaining it and just wasn’t certain if its the best 1 to acquire.

  6. I was really excited to google and see this as I was having some similar ideas. Really cool stuff and now I have something to go off of.

    I’m not an EE person (materials science actually) but I am aiming to use the accelerometer through the arduino to just work as a digital potentiometer in a volume, fuzz or envelope filter circuit. Then have that all built into the guitar.

    Your setup is certainly more flexible… 🙂 But I would always need a computer to use it live.

    Excellent work and good luck with your thesis if you aren’t done already.

    1. Hello!
      Thanks for the comment!
      I’ve actually been thinking about that. Two possibilities come to my mind: The first one whould require to install a stereo jack and to use a stereo cable. The extra cable would be used to send serial data. You would have to receive those data with another Arduino and then generate the control signals outside. The other option might be to use the same audio cable, but using frequency multiplexing to send control data. I’m not quite sure if it would work in practice, but in theory it does.
      If I ever try any of these, I’ll let you know.
      See you!

      JP

    2. Hi!

      I have all of the parts now… I am using two arduino FIO boards. The current plan, thanks to some input from a guitar player friend is:

      – Put the gutted nunchuck in a gibson type guitar, with the joystick in the pickup switch area (I just use the bridge pickup on the guitar in question)
      – send that data to a pedal over xbee
      – the pedal acts as an expression pedal (like a Roland ev 5) using an LED taped to a photocell as a variable resistor. The tilt of the guitar controlling the brightness of the LED.

      There are some other tweaks, but that is the main idea. Part two will be sending out the joystick and tilt info out via midi, I have a USB midi breakout cable to cannibalize for that.

      Thank you so much for your inspiration! I’m glad I checked back on this post, since I had missed your reply. I checked because I needed to see what library you used for arduino to arduino communication.

      Right now I have the nunchuck sending data wirelessly, so I pretty much just need to send the tilt info to the other arduino running a modified ‘dimmer’ example sketch! 🙂

    3. Great!
      It would be nice if you publish the details of your project somewhere. I’d really like to check it out.
      I’m planning to improve my system soon too, so keep tuned.

      Bye!

      JP

Leave a Reply

Your email address will not be published. Required fields are marked *