I have written a program that creates hissing and chuffing sounds plus controls the directional lighting for my garden railway loco.
All runs OK except that there is a noticeable quiet period in the sounds when the loco is running.
I have the sounds and lights running in parallel on an 08M2 chip and I am wondering if the 2 programs are conflicting causing the problem.
I have copied the program (see below) and any advice on how to overcome the problem without having to resort to the use of 2 08M2 chips will be appreciated but if that is the only way it will not be an issue except that using 2 chips for such such simple task may be a waste.
All runs OK except that there is a noticeable quiet period in the sounds when the loco is running.
I have the sounds and lights running in parallel on an 08M2 chip and I am wondering if the 2 programs are conflicting causing the problem.
I have copied the program (see below) and any advice on how to overcome the problem without having to resort to the use of 2 08M2 chips will be appreciated but if that is the only way it will not be an issue except that using 2 chips for such such simple task may be a waste.
Code:
[color=Green]'**** Two programs running in parallel Shay Sound Card MK3 and Shay Lights****
'MK3 added Crawl and Shunt steps to eliminate the sudden changes in the chuff beat at the specific throttle setting transition point present in MK1 and 2.
'Lights added directional Light control.
'########## NOTE; The lights and sound running together give a noticable blank sound space it may be better to split the 2 programs and use 2 seperate 08M2 1 to run sound and 1 to run lights unless a 14M2 can be configured to act as 2 seperate PICAXE chips.#######
'The sound card should fit in the ashpan with the speaker and the light chip with the motor controller[/color]
[color=Blue]SYMBOL [/color][color=Black]soundpin[/color][color=DarkCyan]=[/color][color=Blue]C.0[/color]
[color=Black]START:[/color]
[color=Blue]pulsin C.3[/color][color=Black],[/color][color=Navy]1[/color][color=Black],[/color][color=Purple]b1 [/color][color=Green]'Look at the input pin. RX pulse on leg 4 and put into variable b1. Read RX pulses going to SyRen10A input.
'Stopped[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]146 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]154 [/color][color=Blue]then goto [/color][color=Black]Hiss [/color][color=Green]'pulses between 1.46mS and 1.54ms the train is stopped
'Forward[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]155 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]165 [/color][color=Blue]then goto [/color][color=Black]crawl [/color][color=Green]'pulses between 1.55mS and 1.65mS the train is moving crawling forward slowly[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]166 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]175 [/color][color=Blue]then goto [/color][color=Black]shunt [/color][color=Green]'pulses between 1.66mS and 1.75mS the train is moving forward at shunt speed[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]176 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]185 [/color][color=Blue]then goto [/color][color=Black]slow [/color][color=Green]'pulses between 1.76mS and 1.85mS the train is moving forward slowly[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]186 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]195 [/color][color=Blue]then goto [/color][color=Black]medium [/color][color=Green]'pulses between 1.86mS and 1.95mS the train is moving forward at medium speed[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]196 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]200 [/color][color=Blue]then goto [/color][color=Black]topspeed [/color][color=Green]'pulses between 1.96mS and 2.00mS the train is moving forward at top speed
'Reverse[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]147 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]136 [/color][color=Blue]then goto [/color][color=Black]crawl [/color][color=Green]'pulses between 1.47mS and 1.36mS the train is moving crawling forward slowly[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]135 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]125 [/color][color=Blue]then goto [/color][color=Black]shunt [/color][color=Green]'pulses between 1.35mS and 1.25mS the train is moving forward at shunt speed[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]126 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]115 [/color][color=Blue]then goto [/color][color=Black]slow [/color][color=Green]'pulses between 1.26mS and 1.15mS the train is moving in reverse slowly[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]114 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]105 [/color][color=Blue]then goto [/color][color=Black]medium [/color][color=Green]'pulses between 1.14mS and 1.05mS the train is moving in reverse at medium speed[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]104 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]100 [/color][color=Blue]then goto [/color][color=Black]topspeed [/color][color=Green]'pulses between 1.04mS and 1.00mS the train is moving in reverse at top speed [/color]
[color=Blue]Goto [/color][color=Black]START[/color]
[color=Green]'Chuff beats[/color]
[color=Black]Hiss:[/color]
[color=Blue]SOUND [/color][color=Black]soundpin,[/color][color=Blue]([/color][color=Navy]255[/color][color=Black],[/color][color=Navy]125 [/color][color=Blue]) [/color][color=Green]'constant hiss with slow chuff[/color]
[color=Blue]Goto [/color][color=Black]START
crawl:[/color]
[color=Blue]SOUND [/color][color=Black]soundpin,[/color][color=Blue]([/color][color=Navy]255[/color][color=Black],[/color][color=Navy]20[/color][color=Blue]) [/color][color=Green]'crawl sound output[/color]
[color=Blue]Goto [/color][color=Black]START
shunt:[/color]
[color=Blue]SOUND [/color][color=Black]soundpin,[/color][color=Blue]([/color][color=Navy]255[/color][color=Black],[/color][color=Navy]18[/color][color=Blue]) [/color][color=Green]' shunt sound output[/color]
[color=Blue]Goto [/color][color=Black]START
slow:[/color]
[color=Blue]SOUND [/color][color=Black]soundpin,[/color][color=Blue]([/color][color=Navy]255[/color][color=Black],[/color][color=Navy]16[/color][color=Blue]) [/color][color=Green]'slow sound output[/color]
[color=Blue]Goto [/color][color=Black]START
medium:[/color]
[color=Blue]SOUND [/color][color=Black]soundpin,[/color][color=Blue]([/color][color=Navy]255[/color][color=Black],[/color][color=Navy]14[/color][color=Blue]) [/color][color=Green]'medium sound output[/color]
[color=Blue]Goto [/color][color=Black]START
topspeed:[/color]
[color=Blue]SOUND [/color][color=Black]soundpin,[/color][color=Blue]([/color][color=Navy]255[/color][color=Black],[/color][color=Navy]12[/color][color=Blue]) [/color][color=Green]'top speed sound output[/color]
[color=Blue]Goto [/color][color=Black]START[/color]
[color=Blue]START1:
pulsin C.3[/color][color=Black],[/color][color=Navy]1[/color][color=Black],[/color][color=Purple]b1 [/color][color=Green]'Look at the input pin. RX pulse on leg 4 and put into variable b1. Read RX pulses going to SyRen10A input.
'Lights - turn on Front or Rear LED light depending on stick position[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]146 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]154 [/color][color=Blue]then gosub [/color][color=Black]Lightsoff[/color]
[color=Blue]If [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]155 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=< [/color][color=Navy]200 [/color][color=Blue]then gosub [/color][color=Black]Front[/color]
[color=Blue]If [/color][color=Purple]b1[/color][color=DarkCyan]=< [/color][color=Navy]146 [/color][color=DarkCyan]AND [/color][color=Purple]b1 [/color][color=DarkCyan]=> [/color][color=Navy]100 [/color][color=Blue]then gosub [/color][color=Black]Rear
Lightsoff: [/color][color=Green]'Lights off at neutral stick position[/color]
[color=Blue]Low C.1
Low C.2
Goto [/color][color=Black]START1
Front: [/color][color=Green]'Turns front light on and rear light off with stick in up position[/color]
[color=Blue]High C.1
Low C.2
Goto [/color][color=Black]START1
Rear: [/color][color=Green]'Turns front light off and rear light on with stick in down position[/color]
[color=Blue]High C.2
Low C.1
Goto [/color][color=Black]START1[/color]