Step 6: PicAxe Microcontroller and Code

Picture of PicAxe Microcontroller and Code

Code posted below in Word and Programming Editor formats. If you have trouble opening the code file, use 'save link as' and rename the .tmp file to .bas. I'll be commenting the code after the current re-write, but here's a quick summary :-

Tic Tac Tunes starts up after programming in 'sleep' mode. When asleep, the unit wakes briefly every 4 seconds and checks one of the ADCs (analogue to digital converters). If this reads 255 it wakes up. The ADC is held at 0 with no contact with a pulldown resistor.

Tic Tac Tunes now uses the ADC to read the track value which gives a reading from 0 to 255. The solder blob is at the positive rail voltage, so reads 255.

When awake, additional 255 pulses increase the tempo of the played notes (flashing the LED for each contact), and once the count gets to 8, it reverts to 1 and also switches to the other scale of notes (long LED flash). The PicAxe can only produce notes with a fixed duration, hence the need for the tempo control.

The tracks are in series, so the far end reads at around 127. This value is split in the software to upper and lower keyboard, and then into 18 notes, with 8 divisions for the percussion. An ADC value of zero (probe not touching) gives silence.

The percussion sounds are generated with a chunk of PicAxe SOUND commands, and the notes using TUNE. A watchdog timing loop is reset every time a note is played and if this doesn't happen at least every 20 seconds or so the unit goes into sleep mode until next awoken.

Tic Tac Scales adds more scales to the box, but drops the percussion. Turn on in the same way as Tic Tac Tunes, and select tempo and scale with the control blob. The LED will flash with tempo changes, and also beep as the scale changes to show the scale loaded. They are :-
1) Minor pentatonic
2) Blues
3) Hungarian
4) Arabic
5) Hejaz
5) Chromatic

Tic Tac Beat Box is a free-running beat generator. Start it up by touching the probe anywhere on the top track. It will then invent random beat sequences with 2 to 5 beats, at a range of tempos. It also mixes two sets (at the same count and tempo) to give a bit of variety. Every now and then, it starts a new set. At the start of each set the LED will flash to show the beat count, and gives a brief flash at the start of each bar. Touch the top track again to put it to sleep.

The PicAxe was initially developed for the educational market in UK schools but is being widely used by hobbyists. The PicAxe is based on various PICs but with bootstrap code to interpret the downloaded programs and handle the programming side. They come in all flavours from this suprisingly powerful 8 pin package up to full blown 40 pin.
Look at the manuals and datasheets on the PicAxe site to see the full capabilities. Programming of the chip is via a serial link and done in-circuit. It takes about 20 seconds and you don't even have to unplug the lead to run the program.
I've been in electronics since the early eighties and I've never found a programming environment where the coding / simulation / proving cycle is so simple. Documentation and support from the forum is excellent and there are many robotics enthusiasts using the chips. Control for servos, steppers, ADCs etc are built in to the BASIC-like programming language as well as a host of other goodies. You can also simulate the circuit before you build, and do real-time debugging on a running controller. Look out for more PicAxe based projects from me.

Remove these adsRemove these ads by Signing Up
jdorne3 years ago
Here's an idea, change the instructable to use a 08M2 which has 2048 bytes of memory which means you can store all the programs on it and switch between them using a tactile switch connected to the unused PICAXE pin 3.
AndyGadget (author)  jdorne3 years ago
I made this around 3 years ago, well before the 08m2 came out, but yes, you could do a lot more with a re-write using an 08m2 (although I do quite like the challenge of getting maximum functionality out of a small device.)
Maybe one day, but I'm playing with polyphony on a 14m2 at the moment.
I love it!!!
Whats the difference between each one?

Which one should I use?
rpierce-14 years ago
so just copy and paste the code stuff?
AndyGadget (author)  rpierce-14 years ago
The code is in human readable form in the .DOC files, but to program the chip you need the free Programming Editor from the site linked above.
You open the.BAS file from the Programming Editor and hit the 'program' button.
im using axe pad and it opens "picaxe programs" and .bas isnt one of them
??? what do i doooooo
im sorry if this seems a really stupid question,but how do you program the chip, as this looks a cool thing to make but i dont understand how to do that. Also how much does the programming lead thing cost normally?