Hello all
I'm hoping someone can enlighten me as to what I am missing in this code. The idea for the code is that the 18M2 tells the Tenda to randomly select an mp3 from Folder 1. It then waits for an input (within a do/loop). If it receives an input, it selects the first mp3 from Folder 2, as well as sending an output high to a slave 18M2, which begins its routine. If it does not receive an input when the mp3 is finished (input pin monitors when Tenda Busy pin goes high inactive) it will randomly select another mp3 from folder 1. Once the routine has begun, it will do more of the same, waiting for an input and when received, selecting the next mp3 from folder 2 and sending output high to various slaves. I am using a purpose built pcb, with direct connection via traces to between the 18M32 and the Tenda board. All grounds are connected. I have ensured continuity between all appropriate contacts.
It is getting some of it right! When input is received, it is sending a high output, telling a slave to begin its routine. But as far as the Tenda goes, its not behaving as I intended. It is not selecting an mp3 UNTIL it gets an input. It won't advance beyond that initial selection. I have tried other Tendas and am getting the same results, yet they function properly in other pcbs.
Here is the code
I have a similar code that is working, in fact this one is based on that code. I can post that as well.
Any help greatly appreciated
I'm hoping someone can enlighten me as to what I am missing in this code. The idea for the code is that the 18M2 tells the Tenda to randomly select an mp3 from Folder 1. It then waits for an input (within a do/loop). If it receives an input, it selects the first mp3 from Folder 2, as well as sending an output high to a slave 18M2, which begins its routine. If it does not receive an input when the mp3 is finished (input pin monitors when Tenda Busy pin goes high inactive) it will randomly select another mp3 from folder 1. Once the routine has begun, it will do more of the same, waiting for an input and when received, selecting the next mp3 from folder 2 and sending output high to various slaves. I am using a purpose built pcb, with direct connection via traces to between the 18M32 and the Tenda board. All grounds are connected. I have ensured continuity between all appropriate contacts.
It is getting some of it right! When input is received, it is sending a high output, telling a slave to begin its routine. But as far as the Tenda goes, its not behaving as I intended. It is not selecting an mp3 UNTIL it gets an input. It won't advance beyond that initial selection. I have tried other Tendas and am getting the same results, yet they function properly in other pcbs.
Here is the code
Code:
'#18M2 Supreme Overlord
symbol Witches_SX= B.0 'Output to Witches 18M2 RX pin
symbol Witches_RX = pinB.1 'Input From Witches 18M2 SX pin
symbol Craven_SX= B.2 'Output to Raven 18M2 RX pin
symbol Craven_RX= pinB.3 'Input from Raven !8M2 SX pin
symbol Tenda_BZ = pinB.4 'Input from Tenda Busy pin
symbol Tenda = B.5 'Output to Tenda RX pin
symbol Yardhaunt_SX = B.6 'Output to Yard props 18M2 RX pin
symbol Yardhaunt_RX = pinB.7 'Input from Yard props 18M2 SX pin
symbol Baud = T4800 'Tenda Baud rate
symbol Countdown = w5
Init: 'intialise pins, turing outputs low and prepping Tenda
low Yardhaunt_SX
pause 400
low Witches_SX
pause 400
low Craven_SX
pause 400
high Tenda 'high command to B.5
pause 1000
serout Tenda, Baud, ($EF) 'stop Tenda
pause 5000
serout Tenda, Baud, ($E8) 'turn up Tenda volume
pause 5000
goto Waiting
Waiting: 'do/loop waiting for input from Witch Overlord
high Tenda '
pause 200
serout Tenda, Baud, ($000) 'randomly select ambient music
pause 2000
Do
let Witches_RX = 0
If Witches_RX = 1 then
goto Happy_Halloween 'if input is high go to routine
elseif Tenda_BZ = 1 then
goto Waiting 'if mp3 finishes with no input, randomly select mp3
pause 1000
Endif
loop while Witches_RX = 0
Happy_Halloween: 'Opening routine
high Yardhaunt_SX
high Tenda 'send yard overlord command to begin its routine
serout Tenda, Baud, ($F2,01) 'play music for this routine
pause 4000
low Yardhaunt_SX
Do
let Witches_RX = 0
If Witches_RX = 1 then
goto Flying 'if input is high go to routine
pause 1000
Endif
loop while Witches_RX = 0
Flying:
high Yardhaunt_SX
high Tenda
serout Tenda, Baud, ($F2,02)
pause 4000
low Yardhaunt_SX
do while Tenda_BZ = 0
loop
Graveyard: 'beginning of Graveyard routine
high Tenda
serout Tenda, Baud, ($F2,03)
Countdown = 45
do
Countdown = Countdown - 1
pause 1000
loop
do while Tenda_BZ = 0
loop
Craven_Crania:
high Craven_SX
serout Tenda, Baud, ($F2,04)
pause 4000
low Craven_SX
Do
let Craven_RX = 0
If Craven_RX = 1 then
goto Graveyard_2 'if input is high go to routine
pause 1000
Endif
loop while Craven_RX = 0
Graveyard_2: 'the second run of the Graveyard props, timed to music
high Tenda
high Witches_SX
high Yardhaunt_SX
serout Tenda, Baud, ($F2,05)
pause 2000
low Witches_SX
low Yardhaunt_SX
Countdown = 45
do
Countdown = Countdown - 1
pause 1000
loop
do while Tenda_BZ = 0
loop
Second_Act:
high Tenda
serout Tenda, Baud, ($F2,06)
high Witches_SX
pause 2000
low Witches_SX
Do
pause 1000
let Witches_RX = 0
If Witches_RX = 1 then
goto Flying_2
Endif
loop while Witches_RX = 0
Flying_2:
high Tenda
serout Tenda, Baud, ($F2,02) 'Gargoyles breath fiery smoke while Brunswick the witch flies about
pause 3000
do while Tenda_BZ = 0
loop
goto Waiting
Any help greatly appreciated