Kitronik Music Box Upload of Tune Issue

Mitch01

New member
Hi Everyone,
Please may anyone help me. I am a technician in a secondary school and we have been constructing Kitronik Music Box kits. We are now at the stage where we are trying to upload a RTTTL ringtone to a 08M2 Chip. We are trying to do this using Picaxe Editor 6 and a Picaxe USB cable (AXE027). I am able to upload the tune to the chip and play it back through the chip and mini speaker if I am attached to a power source (the batteries are connected).
However, the tune can't be activated by pressing the switch alone. It is playing constantly and I require the stitch to activate the tune. How can I programme the kit to allow this to be achieved?
Please Help!
 

inglewoodpete

Senior Member
While I admit I've not encountered the Kitronik Music Box before (living at the other end of the world!), it looks like a good kit to learn circuit building and programming on.

Even with over 40 years experience in electronics and programming I still "start small" by writing some test code first. This is referred to in "Testing the PCB" on page 3 of the instructions. The test code will prove that the PCB, switch and sounder operate correctly. From what you are saying, there could be a problem with wiring of the switch or the code that detects the state of the switch. If your test code does not produce the results you are expecting, post the code here and forum members will help you get it going.
 

hippy

Technical Support
Staff member
I am not familiar with the kit - https://kitronik.co.uk/products/2122-programmable-music-box-kit - but it looks like one end of the switch goes to Input Pin 3 / C.3, and the build instructions include a circuit diagram which shows that, pulled down to 0V, the other end of the switch to +V.

Input Pin 3 (C.3) is an input-only pin, and the circuit wiring as to be expected, so it should just work if the switch is connected correctly and isn't faulty. That it's not working could be a wiring issue. Things I would check are -

That the switch does activate and deactivate when it is pressed using a resistance meter.

That the switch wires are to the correct holes.

That the resistor which goes to Input Pin 3 (C.3) is in place.

That one end goes to Input Pin 3 (C.3), and the other does go to +V, Leg 1 of the 08M2, top left leg as viewed.

It might also be worth posting your code or flowchart in case there is anything which may be wrong in that.
 

Mitch01

New member
https://kitronik.co.uk/products/2122-programmable-music-box-kit

I have been able to download the tune to the chip and I can get it to play back when the power is connected (batteries). My problem is that it is not activated by compressing the switch. The tunes are RTTTL ringtones that I downloaded from the Picaxe site.

So, In short, we are using:

Picaxe - Music Box Kits
Picaxe - RTTTL ringtones downloaded from their site
Picaxe - USB Cable AXE027
Picaxe Editor 6.1
USB AXE027 Cable Drivers were installed (YouTube tutorial watched)
Chip that is being programmed: 08M2

I have come to the conclusion that the tunes I have uploaded are missing a command to activate the tune when the switch is compressed. I have no idea how to rectify this however. Below is a copy of the tune for Star Wars I have used that plays on the chip but is not activated by the switch.

If anyone has any ideas what I need to add to this tune to allow this, I would be forever grateful.


RTTTL Ringtone from Picaxe Website:
'StarWars
tune 0, 4,($65,$65,$65,$EA,$C5,$43,$42,$40,$CA,$05,$43,$42,$40,$CA,$05,$43,$42,$43,$C0,$2C,$65,$65,$65,$EA,$C5,$43,$42,$40,$CA,$05,$43,$42,$40,$CA,$05,$43,$42,$43,$C0)
 

hippy

Technical Support
Staff member
It would be worth posting your code and a photo of your board and its wiring.

With the switch wired to Pin C.3 (leg 4), with a pull-down, I would have expecting something like this to work -

Code:
#Picaxe 08M2
Do
  If pinC.3 = 1 Then
    'StarWars
    tune 0, 4,($65,$65,$65,$EA,$C5,$43,$42,$40,$CA,$05,$43,$42,$40,$CA,$05,$43,$42,$43,$C0,$2C,$65,$65,$65,$EA,$C5,$43,$42,$40,$CA,$05,$43,$42,$40,$CA,$05,$43,$42,$43,$C0)
  End If
Loop
 

AllyCat

Senior Member
Hi,
Code:
RTTTL Ringtone from Picaxe Website:
'StarWars
tune 0, 4,($65,$65,$65,$EA,$C5,$43,$42,$40,$CA,$05,$43,$42,$40,$CA,$05,$43,$42,$43,$C0,$2C,$65,$65,$65,$EA,$C5,$43,$42,$40,$CA,$05,$43,$42,$40,$CA,$05,$43,$42,$43,$C0)
Yes, if that is all you are sending to the Picaxe/Project it will only play once. You need to wrap a "Program Loop" around the Tune to read the switch and repeat the tune as required.

Unfortunately, there seems to be an "issue" with the web links above, which appears to give only limited information. When I googled "Kitronik Music Box kit" I found apparently the same page, but the "+ View More" opens up to give much more detail, so I didn't realise there was a problem. In particular there is a .PDF of "Teaching Resources".

However, it appears that hippy has now provided a sample of the program code that you probably need.

Cheers, Alan.
 

Mitch01

New member
It would be worth posting your code and a photo of your board and its wiring.

With the switch wired to Pin C.3 (leg 4), with a pull-down, I would have expecting something like this to work -

Code:
#Picaxe 08M2
Do
  If pinC.3 = 1 Then
    'StarWars
    tune 0, 4,($65,$65,$65,$EA,$C5,$43,$42,$40,$CA,$05,$43,$42,$40,$CA,$05,$43,$42,$43,$C0,$2C,$65,$65,$65,$EA,$C5,$43,$42,$40,$CA,$05,$43,$42,$40,$CA,$05,$43,$42,$43,$C0)
  End If
Loop
Hi,
Sorry for only just replying, it has been very busy. I just wanted to thank you for all your help. I input the code that you suggested and it worked perfectly. All the students now have a tune playing on their devices and are thrilled. Thank you so much for your help once again.
 
Top