I have the code for the animation correct on a electric chair, but the audio will not start up like I want it to. I am using cowlacious car/p 300 and prop1. I have the headers set to 9-12v and am using 2 head pin from vtrig to v+/out5 on prop1. Mode is set to 2. Still not able to get it to work. Please help. Code follows.
P.S. you helped/wrote code for me originally.
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL Sio = 7 ' SETUP = UP; no ULN
SYMBOL Trigger = PIN6 ' SETUP = DN
SYMBOL CARP = PIN5 ' V+/OUT5 to V-Trig
' -----[ Constants ]-------------------------------------------------------
SYMBOL IsOn = 1 ' for active-high in/out
SYMBOL IsOff = 0
SYMBOL Yes = 1
SYMBOL No = 0
SYMBOL Baud = OT2400 ' B/R jumper removed
' -----[ Variables ]-------------------------------------------------------
SYMBOL relays = B0
SYMBOL Solenoid = BIT0 ' on K1
SYMBOL Fogger = BIT1 ' on K2
SYMBOL Light = BIT2 ' on K3
SYMBOL Light2 = BIT3 ' on K4
SYMBOL idx = B1 ' loop controller
SYMBOL timer = W4
SYMBOL lottery = W5 ' random #
' -----[ Initialization ]--------------------------------------------------
Reset:
PINS = %00000000 ' clear all
DIRS = %00100000 ' set CARP to output
relays = %0000
GOSUB Set_RC4 ' clear relays
PAUSE 20000
' -----[ Program Code ]----------------------------------------------------
Main:
timer = 0 ' reset timer
Check_Trigger:
RANDOM lottery
PAUSE 5 ' loop pad
timer = timer + 5 * Trigger ' update timer
IF timer < 100 THEN Check_Trigger ' wait for 0.1 sec input
Start_Audio:
CARP = IsOn
PAUSE 100
CARP = IsOff
timer = 0 ' set to T00.0
Shake_It:
RANDOM lottery
Solenoid = lottery ' randomize Solenoid
RANDOM lottery
Light = lottery ' randomize Light
GOSUB Set_RC4
PAUSE 69 ' 100 - 29
timer = timer + 100 ' update timer
Check_Fog_Start:
IF timer < 4000 THEN Shake_It
Fogger = IsOn ' fog on at T4.0
Check_Fog_Stop:
IF timer < 6000 THEN Shake_It
Fogger = IsOff ' fog off at T6.0
Check_Chair:
IF timer < 15000 THEN Shake_It
GOTO Reset ' quit at T15.0
' -----[ Subroutines ]-----------------------------------------------------
' Update RC-4 with "relays"
' -- takes 29ms @ 2400 baud
Set_RC4:
SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
RETURN
' -----[ User Data ]-------------------------------------------------------
thanks for any help.
I didn't see any problems with the code. Can you trigger the audio player manually? Are you using a relay to trigger the audio player?
Here is how I would find out that prop's OUTx is triggering the audio player. Connect a light or a voltmeter that is the same voltage of the prop, between OUTx that the audio player is being trigger from and the V+. If this is working it maybe a problem with the audio player, such as no voltage to the audio player, setup problem with the audio player or a bad audio player input. Now if the prop OUTx isn't working it is going to be the ULN. One of the two common problems with the ULN are, they fail open or they fail shorted "stays on", even when the Stamp is telling it to turn on or off. You can try extending the pause instruction to this
PAUSE 2000
Just as a test to see if OUTx is working, so you can rule the prop out of the picture. Just remember to set the pause instruction back to the original, which this
PAUSE 100
and have audio player disconnected from prop OUTx when are testing that output for the audio player.
I always make my voltmeter my friend when testing and troubleshooting.
I don't see any problems, either, though I would use a 250ms pulse; 100 may be a little short for the CARP's debouncing.
I would say Jon is probably correct, I use a 1 second pulse on my Cowlacious players.
Quote from: JackMan on August 20, 2010, 06:13:54 PM
I would say Jon is probably correct, I use a 1 second pulse on my Cowlacious players.
Jackman has a good point too and using a light( light around 100 ma)like I suggested to see if the prop is triggering will work just fine. This means that you can watch the light blink when the prop triggers the audio player. Every PLC that I worked on has this feature, so you can see if the field wiring is working or not working.
Thanks for all the help. I increased the pulse to 250 ms and it now works great. Thanks
i have the same setup ryagl, prop 1 with a CAR/P......below is my setup. My the Car/P will not play, it will play if manaully pressed, my programming is below:
' =========================================================================
'
' File......
' Purpose...
' Author....
' E-mail....
' Started...
' Updated... 22 OCT 2009
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
' -- connect N.O. button between P6.W and P6.R
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL Trigger = PIN6 ' SETUP = DN
SYMBOL CARP = PIN5 ' V+/OUT5 to V-Trig @12v
SYMBOL Fogger = PIN2 ' V+/OUT2 to relay
SYMBOL Chair = PIN1 ' V+/OUT1 to valve
SYMBOL Light = PIN0 ' V+/OUT0 to relay
' -----[ Constants ]-------------------------------------------------------
SYMBOL IsOn = 1 ' for active-high in/out
SYMBOL IsOff = 0
SYMBOL Yes = 1
SYMBOL No = 0
' -----[ Variables ]-------------------------------------------------------
SYMBOL delay = W3
SYMBOL timer = W4
SYMBOL lottery = W5
' -----[ Initialization ]--------------------------------------------------
Reset:
PINS = %00000000 ' clear all
DIRS = %00111111 ' set output pins
PAUSE 30000 ' PIR warm-up
' -----[ Program Code ]----------------------------------------------------
Main:
timer = 0 ' reset timer
Check_Trigger:
RANDOM lottery
PAUSE 5 ' loop pad
timer = timer + 5 * Trigger ' update timer
IF timer < 100 THEN Check_Trigger ' wait for 0.1 sec input
Light = IsOn
Start_Audio:
CARP = IsOn
PAUSE 50
CARP = isOff
timer = 0
Buzz:
Chair = 1 - Chair ' toggle chair valve
PAUSE 95 ' short delay
timer = timer + 95 ' update timer
IF timer < 5000 THEN Buzz ' done buzzing?
timer = 0
Shake_It:
Chair = 1 - Chair ' toggle chair valve
RANDOM lottery ' restir random #
delay = lottery // 201 + 50 ' 0.05 to 0.25s
PAUSE delay
timer = timer + delay
Check_Fog:
IF timer < 1000 THEN Shake_It ' run 1s before smoke
Fogger = IsOn
Check_Show:
IF timer < 10000 THEN Shake_It ' (adjust for audio timing)
PINS = %00000000 ' everything off
Program_Delay: ' hold 5 minutes
FOR timer = 1 TO 5
PAUSE 60000
NEXT
GOTO Main
' -----[ Subroutines ]-----------------------------------------------------
' -----[ User Data ]-------------------------------------------------------
Quote from: ryagl on August 20, 2010, 07:19:35 PM
Thanks for all the help. I increased the pulse to 250 ms and it now works great. Thanks
You need to increase this PAUSE 50 to PAUSE 250 under the label Start_Audio. The PAUSE instruction is too short and not giving the audio player a chance to see the voltage on it's input pin. You already did the first test to see of the audio player is working. Now, all you have to do is make a change in the code and you should be all set to if it works automatically.
I always say, trigger your audio player manually because, your finger always provides a longer pause and its how I troubleshoot something like this.
Thanks for the help, I will give this a try and see what happens.