November 05, 2024, 07:55:39 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Figuring it out

Started by aquawilly54, October 14, 2012, 07:02:01 PM

Previous topic - Next topic

JackMan

October 19, 2012, 02:09:24 PM #30 Last Edit: October 19, 2012, 02:13:38 PM by JackMan
 
QuoteEach time I have tried to use "my" symbols though little boxes popped up that essentially said it didn't recognize them.

Any symbol that you list as an I/O definition, a constant, or a variable, it will be recognized in your program code if it is used correctly.
Give us an actual example of a program you wrote where it did not recognize your symbol and I'm sure someone can tell you why.   This really needs to be a new thread in the Prop-1 section, you need to start one there.  ;)

aquawilly54

Good Evening folks.
First let me apologize for starting a different thread.  That little bit of success made me want to start new.  I'll stay on this one now.
I loaded up the program JackMan made me.  I'm back to square one.  It's not playing. 
I put in the ULN2003 (bottom aligned)
Reformatted the card
Ensured the file is .WAV
Swapped out sensors, just to eliminate the possibility of a bad one.
Swapped the serial cable back and forth, just to see if I had it backwards.
All configuration switches are off, but tried it with 5 and 6 on.  No change.
The audio select switch is in position 0.
The status light stays green, although it did flicker red twice (about 1min apart).
Any ideas?
Steve

JackMan

Your file needs to be named PIPES.WAV as you requested.  Are you powering up the Prop-1 and the AP-16+ and then waiting at least 30 seconds before triggering the PIR? Try removing the PIR from the Prop-1 and use a N.O. switch connected to PIN6 R. and W. Power up and wait at least 30 seconds. Close the switch and see if the AP-16+ plays the file.

aquawilly54

Hello JackMan.
  Yes, the file is Pipes.WAV.
I have waited for over 1 minute to trigger the PIR.
I do not have a switch that I can use on Pin6.  Can I use a small wire or something to short red and white in the serial cable?


aquawilly54

Do the jumpers for for P6 and P7 need to be moved?  They are both in the down position.

aquawilly54

Ok, I just reacomplished everything again.  Now when I trigger the PIR the status light flashes red for 1 second, then goes back to steady green.

That would tell me there is communication between the two, but not any further. 

As stated, I have formatted the disk several times.  I don't believe it to be a corrupt file.  The sxf00 plays just fine.  It's the same file with a different name.  Am I wrong?

aquawilly54

Also, I loaded up that WHOLE program, from the top of the page to the end including the header lines above stamp ID's.  I guess the controller rules out any extraneous info, but it sure seemed like a lot of stuff. 

JonnyMac

October 22, 2012, 08:50:08 PM #37 Last Edit: October 22, 2012, 08:57:41 PM by JonnyMac
If would spell out what you want your program to do, I'll write you code that will work. I'm a really good programmer, I'm awful at mind reading. :)

If you're using P7 to communicate with the AP-16+ then two conditions must be true:
-- the ULN influence must be removed from P7 (replace with ULN2003 or clip pin 1 of ULN2803)
-- P7 setup jumper should be removed or in the UP position (recommended)

Maybe I'm dense and missed it (have been working a lot of long hours) -- if you just want to play "PIPES.WAV" when you get a PIR input on the Prop-1 you can do it with the program below. Make sure all configuration switches on the AP-16+ are OFF (loop is okay if want an ambient file to play between activations).

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


' -----[ Constants ]-------------------------------------------------------

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  TrOn            = 1                     ' active-high trigger
SYMBOL  TrOff           = 0

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


' -----[ Variables ]-------------------------------------------------------

SYMBOL  timer           = B2                    ' for debounce loop


' -----[ Initialization ]--------------------------------------------------

Power_Up:
  PAUSE 3000                                    ' let AP-16+ initialize

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00111111                              ' P5..P0 are outputs

  PAUSE 30000                                   ' PIR warm-up/delay


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  PAUSE 5                                       ' scan delay
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 100 THEN Check_Trigger             ' check timer

  ' play audio file

  SEROUT Sio, Baud, ("!AP16", %00, "PW", "PIPES", CR, 1)

  GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

aquawilly54

JonnyMac,
I understand your frustration with this.  I don't feel much better.
I guess I'm at that point where I have to admit defeat.  I just tried to load the above program.  It wouldn't take it, due to the "CR".  I changed it to 13 and it loaded, but the end result was the same.   The status light flickers red for 1 second.  I moved the P7 jumper as well. 

My main idea was to be able to get the WAV to play, before I added it to the whole program.  I haven't written one yet, because I wanted some success before trudging on, and because timing in the program is an issue for me as well.  I don't have the answers to that either.  I think I saw something that addressed it here in the forum, but I didn't understand it all.

I'm worried that if I've done everything I've been told and this doesn't work currently as the only program loaded, what's going to change in the full program?  I have done everything that you all have instructed me to, so what am I missing?  I know you're a busy man.  I really didn't want to inpose on your time, but if you really don't mind writing a program, I would be extremely grateful.  I feel kind of bad for asking it of you, but here is what I'm shooting for.  It's really pretty short:

Main light comes on and stays on for 30 seconds.
Sound comes on 5 seconds after main light turns on.  No looping.
Light 2 comes on 8 seconds after sound starts.  Light 2 stays on.
Light 3 comes on at the same time as light 2 and goes out after 4 seconds.  Light 2 stays on.
Everything shuts off at the 30 second mark.
20 seconds for reset.


Thank you, sincerely
Steve

bsnut

The big question is, do you want to trigger the sound file serially or use the Start inputs 12 to 24 VDC?
William Stefan
The Basic Stamp Nut

aquawilly54


aquawilly54

Well, I've been home for a couple of hours and played around a bit.  After reading some other posts, I changed my file to 16 bit / 2050 and renamed it to SFX02.  It played using the PIR attached to the AP, but kept looping.  The loop switch is off.  I then changed the name back to SFX00.  It played but kept looping.  I pulled the PIR off and tried the start button.  Nothing happened.  I reconnected the PIR and it kept looping. 

No time to retry the prop 1 / P7 connection, but I will tonight.  This is really frustrating.  I like playing with it, so eventually I'll learn the stuff, but for now I just want Halloween to go well. 
Thanks for being here, guys.
Steve

JonnyMac

October 23, 2012, 11:19:56 AM #42 Last Edit: October 23, 2012, 11:23:42 AM by JonnyMac
QuoteMain light comes on and stays on for 30 seconds.
Sound comes on 5 seconds after main light turns on.  No looping.
Light 2 comes on 8 seconds after sound starts.  Light 2 stays on.
Light 3 comes on at the same time as light 2 and goes out after 4 seconds.  Light 2 stays on.
Everything shuts off at the 30 second mark.
20 seconds for reset.

Okay, with that information I can write a program. Note, though, that I don't know if your sound is 30 seconds long or if you want to stop the AP-16+ after 30s -- another important detail. Yes, I know that this is frustrating, but controllers only do what you tell them to do. Period.

Check your connections:
-- P7 has ULN influence removed
-- P7 SETUP jumper is UP or removed
-- extender cable is connected between P7 and AP-16+ SERIAL header
    * SERIAL header is marked J in the callouts on page 2 of the documentation
-- make sure to follow the W (white) R (red) B (black) cable markings -- a backward cable will cause problems

I also wrote the program to start SFX00.WAV. That way you can test your audio by pressing the START button on the AP-16. If that doesn't work properly then the controller can't do anything for you.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$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  Light3          = PIN2                  ' use OUT2/V+
SYMBOL  Light2          = PIN1                  ' use OUT1/V+
SYMBOL  MainLight       = PIN0                  ' use OUT0/V+


' -----[ Constants ]-------------------------------------------------------

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  TrOn            = 1                     ' active-high trigger
SYMBOL  TrOff           = 0

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


' -----[ Variables ]-------------------------------------------------------

SYMBOL  timer           = B2                    ' for debounce loop


' -----[ Initialization ]--------------------------------------------------

Power_Up:
  PAUSE 3000                                    ' let AP-16+ initialize

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00111111                              ' P5..P0 are outputs

  PAUSE 20000                                   ' PIR warm-up/delay


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  PAUSE 5                                       ' scan delay
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 100 THEN Check_Trigger             ' check timer

T00:                                            ' start of sequence
  MainLight = IsOn
  PAUSE 4958                                    ' 5s - serial command

  ' play audio file, SFX00.WAV
  ' -- allows testing via AP-16+ start button

T05:
  SEROUT Sio, Baud, ("!AP16", %00, "PS", 0, 1)  ' play SFX00.WAV one time
  PAUSE 8000

T13:
  Light2 = IsOn
  Light3 = IsOn
  PAUSE 4000

T17:
  Light3 = IsOff
  PAUSE 13000

  ' could insert loop to wait for end of audio if desired

  GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

As I live in Hollywood and God knows that those of us in "the business" are not afraid to express an opinion, let me express mine:

PIRs stink on ice!

Yes, that is my opinion. We carry them (made by our friends at Parallax) only because our customers want them. That said, they are the most finicky, least reliable sensor you can use on a prop. No, they aren't defective -- even under the best conditions they just don't work very well. A mat switch is a much better choice. Again, this is just my opinion.

Now... if you must use a PIR, do not test your code with one. It's an impossible situation being right next to the controller and PIR and not having it trigger when you don't want it to.  If you have a spare 14" extender cable then you can cut the one end off and solder a normally open button between the white and red wires. In a pinch you can simply strip the insulation from the white and red and touch the wires together (do not let the black touch the red!!!).
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

QuoteI then changed the name back to SFX00.  It played but kept looping.

Did you set the post delay on the AP-16+? If not, this is the reason the file is looping, the PIR keeps triggering.

QuoteI pulled the PIR off and tried the start button.  Nothing happened.

OK, here's where I'm confused. Is the AUDIO SELECT set to 0? If the file is named SFX00.WAV it should play when you manually press the START button.