NoEinstein
Member
As part of learning about the PicAxe, I've been tinkering with using two Picaxe 14M2 chips to play a song using the tune command. I programmed a "master" chip to play the melody and a "slave" chip to play the harmony. I thought I could use a single wire going from one chip to the other to synchronize the two chips and everything would be okay, but sometimes on power-up, the two parts start off at different times. It's a simple children's song that is played fairly slowly, so I'm surprised my simple synch line isn't good enough to get it to work. Is there something fundamental about the Picaxe I should know to get this to work?
Both chips use the same +V and ground. I've been testing these with the PC disconnected. Sometimes it works perfectly, but about a third of the time it's off.
I delay the Master chip to give the power supply plenty of time (about 2 seconds) to stabilize. I give the slave chip about 4 seconds worth of waiting around for the Master before the slave jumps to a subroutine and starts playing anyway.
Is there any way to make this work right every time? Thanks.
The slave works like this:
Both chips use the same +V and ground. I've been testing these with the PC disconnected. Sometimes it works perfectly, but about a third of the time it's off.
I delay the Master chip to give the power supply plenty of time (about 2 seconds) to stabilize. I give the slave chip about 4 seconds worth of waiting around for the Master before the slave jumps to a subroutine and starts playing anyway.
Is there any way to make this work right every time? Thanks.
Code:
;For the 14M2 picaxe.
;After power up, this waits about 2 seconds then sets
;Pin C.2 (Physical pin 5) High to synch all the other chips.
Main:
Pause 2000 ;Wait for everyone to power up.
High C.2 ;Set the synch line high.
GoSub Jingle
END
The slave works like this:
Code:
Symbol BowDownTime = w0 ;Caution WORD sized uses up b0 and b1!
Symbol Counter = w1 ;Caution WORD sized uses up b2 and b3!
;Chip will behave like a slave for BowDownTime counts...
BowDownTime = 4100 ;Caution WORD sized! Do not exceed 65000!!!
Main:
For Counter = 1 to BowDownTime
IF pinC.2 = 1 THEN GoSub Jingle
Pause 1
NEXT Counter
;If a Synch signal did not get detected on C.3, then play anyway...
High C.2 ;Set the synch line high.
GoSub Jingle
END