Hi Fellers. My project is a Merry Mix assembled from Meccano. The object was to simulate a fair ground Merry Mix, such that each ride was accompanied by a different tune. The processor is an 08M2 with leg 4 connected to a LED, motor drive via a BD139 to Leg 6, and a speaker connected via a cap and resistor to Leg 5.
The model works fine with the code, such that each time a 'ride' starts, the next tune in sequence plays:
start:
b0=b0+1
if b0=10 then call reset_b0
high 4 ; Led lights
wait 5
high 1 ;motor and music start
if b0=1 then call tune1
if b0=2 then call tune2
;etc through to tune 9
low 1 ;music stops, motor stops and spools down
low 4 ; LED extinguishes
wait 7
goto start
reset_b0:
b0=1
return
tune1: ;(RTTTL)
tune
0,6,($aa etc.....), and through to tune9
Return
My next attempt was/is to attempt to select and play a tune randomly. I used the code as above more or less, modified as follows:
Start:
high 4
wait 5
high 1
random w0 ;re-seed each cycle
if b0>=0 and b0<=28 then call tune 1
if b0>=28 and b0<=56 then call tune2
etc through to tune9 and <=255 - I used b0 as the LSB of w0.
low 1
low 4
wait 7
goto start
Then the 9 RTTTl tunes as abbreviated above.
This worked fine using the simulator function, and tunes played randomly. b0 changed each iteration, and the appropriate tune played. However, when I applied the program to the processor, I found that the tune always starts at tune1, and repeatedly plays tune1 each ride sequence -
I suspected a hardware glitch, so commented out the motor and LED functions, then increased the cap across the 08M2, but to no effect. I also tried various pause's between each 'if' statement. Nothing seemed to work.
It seems that the processor always wants to start at tune1, irrespectibe of the value of b0, and continue at tune1, even though b0 changes each cycle as displayed by the simulator, and even though the simulator does exactly what I want/expect. I've also tried a different 08M2 in case I'd done something naughty.
I think I'm stumped. Can anyone see a problem in what I've done or suggest a solution?
Ben Baker
The model works fine with the code, such that each time a 'ride' starts, the next tune in sequence plays:
start:
b0=b0+1
if b0=10 then call reset_b0
high 4 ; Led lights
wait 5
high 1 ;motor and music start
if b0=1 then call tune1
if b0=2 then call tune2
;etc through to tune 9
low 1 ;music stops, motor stops and spools down
low 4 ; LED extinguishes
wait 7
goto start
reset_b0:
b0=1
return
tune1: ;(RTTTL)
tune
0,6,($aa etc.....), and through to tune9
Return
My next attempt was/is to attempt to select and play a tune randomly. I used the code as above more or less, modified as follows:
Start:
high 4
wait 5
high 1
random w0 ;re-seed each cycle
if b0>=0 and b0<=28 then call tune 1
if b0>=28 and b0<=56 then call tune2
etc through to tune9 and <=255 - I used b0 as the LSB of w0.
low 1
low 4
wait 7
goto start
Then the 9 RTTTl tunes as abbreviated above.
This worked fine using the simulator function, and tunes played randomly. b0 changed each iteration, and the appropriate tune played. However, when I applied the program to the processor, I found that the tune always starts at tune1, and repeatedly plays tune1 each ride sequence -
I suspected a hardware glitch, so commented out the motor and LED functions, then increased the cap across the 08M2, but to no effect. I also tried various pause's between each 'if' statement. Nothing seemed to work.
It seems that the processor always wants to start at tune1, irrespectibe of the value of b0, and continue at tune1, even though b0 changes each cycle as displayed by the simulator, and even though the simulator does exactly what I want/expect. I've also tried a different 08M2 in case I'd done something naughty.
I think I'm stumped. Can anyone see a problem in what I've done or suggest a solution?
Ben Baker