November 23, 2024, 06:38:27 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Converting Haunted House Program from Prop-1 to a Prop-2

Started by Spooky Dad, September 13, 2011, 09:05:42 PM

Previous topic - Next topic

bsnut

I found your problem that is keeping you from running your program. Here is your mistake and surprised the compiler didn't pick it up.

IF idx = Ghost

You made the mistake that is common and I had made myself. You can't compare a variable with an I/O pin. You have "idx" as a variable and "Ghost" is a I/O pin, which changes from a 1 to 0. You need to be comparing with a "0" which is constant in your variable.

It should look like this and should take care of problem.

IF idx = 0

When the Basic Stamp starts up it, the variable "idx" is set to 0, then your code changes to something else.
William Stefan
The Basic Stamp Nut

Spooky Dad

bsnut - Got it!  In the prop-1 program that I am converting from, I declared GHOST (and others) as a symbol and equal to a particular pointer number, hence the comparison to idx I was striving for.  I get why it's not working now.  I also have an error in my wave files I figured out.  I can't have COUNTDOWN.WAV, so I will be changing that back to COUNT.WAV.  Thanks!

JonnyMac - Sorry I am a slow learning on the documentation.  Thanks for your comment.

Spooky Dad

OK.  I have updated the code based on the error that bsnut found (see updated file).  Thanks again bsnut. 

While I have successfully downloaded the code to the Prop-2, when I run the program now, as soon as an input is detected (either shorting W and R or hooking up a parallax motion) the board resets itself.  What am I doing wrong?

bsnut

I don't understand what are meaning by the board resets itself. Do you have the PIR hooked up correctly? If PIR was hooked up wrong it may short out the power supply on the Prop-1, which would shut you down until power was removed and restored. Also the problem could be in the code itself, which could make you think it is reseting.



William Stefan
The Basic Stamp Nut

Spooky Dad

The PIR is hooked up via the supplied cable to White - Red - Black on the input P0.  What I mean by resetting itself is that the code starts over, which I know since I added the "Wait for it" debug command in the start up session of the code.  I briefly see the debug statements "Ready to Go", "I'm a Ghost" and "The haunt is NOT Spooky" before seeing the "Wait for it" statement again. 

bsnut

I will download the new version of your program later on today to see what is causing your problem.

So, what does the program need to do after this debug statement "Wait for it"?
William Stefan
The Basic Stamp Nut

Spooky Dad

October 03, 2011, 03:00:50 PM #21 Last Edit: October 03, 2011, 07:06:50 PM by Spooky Dad
The program is waiting for 30 seconds to let the motion settle into it's environment, then it should start by checking the input pins, starting with P0, waiting for the motion to be tripped.  The "wait for it" is the start of the 30 second pause.  The debug message "Ready to go" signifies the end of the warm up period.  Then I inserted a few other debug messages to determine whether or not IDX equals ghost and whether or not it is Spooky or non-spooky.  Unfortunately, after I shot W and R (or let the motion trip it), the Prop-2 appears to be doing a reset and starting from the Power Up again.  Make sense?

Spooky Dad

October 03, 2011, 08:38:47 PM #22 Last Edit: October 03, 2011, 09:45:25 PM by Spooky Dad
OK Gang - I now have a psuedo working program (now that I'm past the bad motion & past the bad logic, thank you JonnyMac and bsnut, respectively).  The items that are still not working on the program, which I would greatly appreciate some help with are:


  • The GOSUB Read_Record command isn't pulling the right values from the table on lines 157 and 178
  • How do I get the name of the wave file, eg. COUNT.WAV, into the sfx variable?
  • Can I get some help simplifying the code to save space, as I have already had to cut some debug commands in order to get the program to this stage?

Version 8 attached!!!

JonnyMac

Here is my take on the program -- and this represents over 7 hours of programming so that just goes to show that no matter how "simple" we think something is, as my friends in the DPRG would say, "It's harder than it looks."

To be blunt, this is really eight Prop-1 programs jammed into a Prop-2.  I think we need raise the price of our products! ;)

This does not use the table approach and I think is far simpler to follow.  The main loop is a little tricky as it allows for testing where you can press a key to activate a section, or use normal triggered input.  The program takes advantage of conditional compilation to allow you to (de)activate testing mode and debug messages.

Now.... I put more than 7 hours into this.  I expect you to put 4x that into studying the listing.  I wrote the code in such a way that you should be able to match it up with your spec.  Please, print the listing and take time to study it.

Warning: I can only test by compilation, so I will leave it up to you to do the final wringing out.  The test mode is setup to help you do this.
Jon McPhalen
EFX-TEK Hollywood Office

bsnut

Jon,
You beat me to the punch with your program that you did. I was doing the same thing that you did and I will try to be done later on this week.

I will be converting his old Prop-1 program that he email to me to a Prop-2 program to show how easy it can be sometimes. I will also add the extra scene in the Prop-2 program since the Prop-1 program has only 7 different scenes.
William Stefan
The Basic Stamp Nut

Spooky Dad

Consider the training program and final wring out started.  Thank you JonnyMac!  I can already tell that I am going to learn alot from the code, which I have been staring out for nearly an hour now.  Starting to make sense, but you are right, I will need some significant time to absorb.  The debug Testing mode state is not only going to be handy in understanding the code, but will save me a lot of time as I hook everything up.  Thanks again!

Spooky Dad

Day 1 of the advanced training course is over, with most everything working and understood (full updated program attached).  My only issue so far that searching through the Basic Stamp Reference and Syntax Manual hasn't resolved is the bit of code below.  The code is supposed to play the Chickn.wav (renamed it thinking it was the length of the name that was causing my problem) when it switches from Spooky to Non-Spooky, but it doesn't.  The same relay on the AP-16+ that trips when all the other *.wav files play trips for it, but after a split second, the Ambient.wav keeps on playing.  I double checked that the chickn.wav file is encoded like the others.  I even added in some extra debug statements so that I could better keep tabs on what is going on.  Might it be a setting on the AP-16+?  Once I get this kink worked out, I will start hooking up the props to it.

Main:
  IF (SpookyMode <> lastMode) THEN              ' mode switch change?
    dc16.LOWBIT(6) = SpookyMode                 ' set chicken lights
    GOSUB Set_DC16                              ' refresh

    DEBUG "Spooky <> Last Mode", CR, LF
 
  IF (SpookyMode = No) THEN                   ' switched to non-spooky?
      pntr = Chicken
      rpts = 1

      DEBUG "Play WAV", CR, LF

      GOSUB Play_WAV
      GOSUB Audio_Wait
    ENDIF
    lastMode = SpookyMode                       ' save
  ENDIF

  IF (SpookyMode = lastmode) THEN
       DEBUG "Spookymode equal last mode", CR, LF
  ENDIF

Spooky Dad


Spooky Dad

I finished the line by line studying of the code.  Today I add switches on all the inputs, LEDs (Prop-2 and DC-16) and lights (RC-4) and will go through a complete end-to-end testing of the code for both the Spooky and Non-Spooky modes.  The Testing Mode is absolutely fantastic.  It was absolutely wonderful for assisting me in understand what was going on for a prop by prob basis and helping me learn and work out the major kinks in the show.  I'll report more tomorrow.

EFX-TEK SUPPORT IS THE BEST ON THE WEB!!!!! 

livinlowe

Shawn
Scaring someone with a prop you built -- priceless!