Picaxe: Stereo Amplifier, Tone Generator and Flame Controller

2_4.jpg

nunchuck_stereo_control_joystick_w_freq_gen_0.bas (14044Bytes)

Preface:  No, this is not a robot.  But either I document this project here or on my turf & soil blog.  This seems like a better choice.  And yes, I use a lot of words.  If you want to skip to the good (or at least better) stuff, watch the second video.

I wanted to learn more about some communication protocols and decided that interfacing a Wii nunchuck ("wiichuck") to a Picaxe would be an easy way to try out the I2C commands.  I ordered a wiichuck adapter and some 3.3V regulators then borrowed one of the wiichucks from the gameroom (it's not needed to watch Netflix anyway).  With the all-knowing internet as my guide, communication between the wiichuck and Picaxe was readily established and suddenly a 2-axis joystick, a 3-axis accelerometer and two buttons were at my disposal.  (I didn't even know the nunchuck HAD two buttons.)  But now that I had an input device, what to control?

I decided to make a stereo volume controller.  This would give me a little experience bit-banging data to a 3-wire serial device.  I promptly smoked a couple of PGA2311 Stereo Volume Control chips using my ancient dual-voltage supply and decided to re-think my design.  I though back over the many great educators from my youth and asked myself: "Self, what would Forrest Mims III recommend?".

I don't really know what Mr. Mims would do, but I decided to go with simple LM386 audio amplifier circuits - one each for left and right.  The 10-kΩ potentiometer that is usually suggested for volume control with the 386 was replaced by a digital potentiometer - the MCP42010 256 Step SPI 10kOhm Digital Potentiometer IC.  The MCP42010 has dual potentiometers - one can be used for each of the two stereo channels.  For reasons that I no longer recall, I didn't use the shiftout/spiout commands that look to be available for the Picaxe 18M2 - instead I used the manual bit-bang methods introduced in the Picaxe Manual Part 2.  Either I had a good reason and have forgotten it, or I wasn't paying attention.  At any rate, I mostly understand the process now.

When looking for information on digital potentiometers, I came across this blog with a similar solution for stereo control (though with different chips) and also this writeup on connecting a MCP42XXX device with a Picaxe.  These might be useful background information for anyone looking to implement a similar solution.

Although the stereo pre-amp has a stereo input jack to connect to an MP3 player or other device, I wanted to use the Picaxe as a tone generator as well.  I wanted to control the tone frequency from the wiichuck joystick, and I wanted the tone to sound continuously rather than for specified note durations and also to continue sounding while the volume was adjusted or other Picaxe commands were issued.  The "sound" command native to the Picaxe fails on both counts, so I used the "pwmout" command to generate an output signal into a low-pass filter that was then fed into the 386 pre-am circuit (both channels).

 

Now why would I want to do all of this work?  To control fire, of course.

A few months ago I built a Reubens Tube after scanning MAKE Magazine at the store one day.  Basically sound is used to excite resonant frequencies inside a burner manifold and the flame height along the manifold reflects the nodes and antinodes inside the tube.  There are many, many videos and writeups of these devices and I won't duplicate another explanation of the physics here.

Many examples of Reubens tubes have a single speaker, but since I had a stereo controller, I thought I'd try to drive the resonances from both end of the tube simultaneously.  There is a possibility that this can cause destructive interference, so I added a DPDT switch on one speaker to swap polarity as needed.  This is a simple way to affect a 180-deg phase-shift of the audio signal on one end of the tube - in theory.  For the stereo version of the Reubens Tube, I used 8-Ω, 3W 40mm full-range speakers from All Electronics - I think JAX recommended them to someone on the ShoutBox one day.  Finally - just to give a little extra-umpf to the signal, I ran the output from the 386 pre-amp circuits into a 10x10 watt stereo amplifier (Kit 88 from KitsRUs).

 

The performance of this setup with the Reubens Tube isn't as good as previous implementations I've tried using other speakers, amplifiers and tone generators.  The resonances aren't as clear in the flame patterns - especially at higher frequencies.  The PWM signal and a simple passive filter don't provide a very clean sinusoid, and I know I have noise in the amplifier ground along with plenty of other issues.  But I get to use a wiimote to control fire, so that's cool.  And it all works well enough to move on to a new project - which will probably have nothing to do with any of this.

So what did I learn or re-learn from this little exercise:  I2C communication, bit-banging, SPI timing diagrams, Picaxe internal clock conflicts, PWM signals, audio filters, not being afraid to just stick a capacitor across the leads to see what happens, and sometimes it's only the 3rd band on the resistor than's important.

I also learned I suck at video presentations - and you're the one who suffers.  For that I am indeed sorry.

https://www.youtube.com/watch?v=A5erOhxVfWM

That’s took time.
But I’m sure your good at writing then video making. I suprised I read it… But hey, need something to do. Very impressed by this project. I’m also interest in I2C’s and using a wii nuncuck. I do have to doing some bragging with the prop. U mentioned that you couldn’t easily run your tin while adusting volume and running other commands. It is obvious but I have to say that a prop would run that better all at once. That actually makes me want to do something similar. But that is for later times. Otherwise… GREAT PROJECT!!!

Great project !

Great project !

** *Remember: You have to

 

Remember: You have to read from the bottom up.

 

Chris the Carpenter: I gotta go and find my drill and some pipe…
Dan M: climate app as in to change the climate?
theandroidman: Just need a climate app…thats all
Zekk: Holy cow cactus u genius! That thing frggin plays music!
Dan M: When it’s too cold you can bundle up more. When it’s too hot, once you are down to skin, you are stuck with the heat. (g)
Delete Chris the Carpenter: Keeps getting better! --He’s running one out of phase! Brilliant!
theandroidman: Tampas good-I get down there from time to time
patrickmccabe: Ah, I am near Tampa.
theandroidman: I need a climate app!
  theandroidman: I am in tallahassee(northern)
  patrickmccabe: Where in florida are you at?
theandroidman: I need a place thats just right…
theandroidman: Course-now its too damn hot.In Florida
Dan M: Ah, well, I was born in the Highlands. I prefer cold to hot.
Zekk: Did anyone notice the recorderin the background or his first vid
theandroidman: I left in early 80s-too damn cold
Delete Chris the Carpenter: Very nice handwriting too!
Dan M: from being the key word there… ha ha
Delete Chris the Carpenter: I don’t want to comment --I am not articulate enought to do it justice with my comment
theandroidman: @zekk-nah-its a classic-It served its purpose and is now just an artifact
theandroidman: Hey DanM-I am from Ohio originally!
Zekk: Nice samplebot android. Probably could it impove it to be even better with today’s tech
patrickmccabe: *stellar
Delete Chris the Carpenter: I could watch this for hours! Oh, yeah --this one is my personal top 10… top 5
patrickmccabe: Yeah the music was stelar
Dan M: Jokes are good. Life’s too short to not have fun at it.
Delete Chris the Carpenter: and now with the music?!?! Holy fuck! Beautiful work!
theandroidman: Duh-thanks
Chris the Carpenter: Front page, android
Delete Chris the Carpenter: and in stereo! Brilliant!
patrickmccabe: I wish. Makes things more fun.
Delete Chris the Carpenter: Oh man, this is one of the best I have seen!
Zekk: Is everyone of ur shouts got ti be a joke pat?
Zekk: I didn’t get to watch the thing about the tube
patrickmccabe: I think a joke could be made now…
Delete Chris the Carpenter: Oh! Hell Yeah, Cactus!! --Reuben’s tube! Awesome! --watching now.

High praise indeed.

Glad you enjoyed it, Chris.  When I get motiviated to make some improvements I’ll post the results.