November 23, 2024, 10:08:14 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


I can't get it to work.

Started by kaamra, August 22, 2013, 06:54:52 AM

Previous topic - Next topic

kaamra

I'm trying to use a prop 2 to trigger a LED, then a sound from a BooTunes, another LED and another sound from the BooTunes, all triggerd from a PIR motion sensor. My problem is, when I hook it all up, nothing happens. I'm not sure if it's a programming problem or a wiring problem. Here's my code.....

' {$STAMP BS2}
' {$PBASIC 2.5}

'------[ I/O Definations ]-----------------------------------------------------------

Trigger         PIN 15   ' 1 = present; 0 = not presemt
Light1          PIN 13   ' to trigger first light, pulse 0->1->0
Light2          PIN 11   ' to trigger second light, pulse 0->1->0
Killyou         PIN 9    ' to trigger first laugh, pulse 0->1->0
Laugh           PIN 7    ' to trigger second laugh, pulse 0->1->0


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


IsOn             CON  1
IsOff            CON  2


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


Groupwait       VAR  Byte


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


' Only on start up

RESET:

DIRL = %0011111111111111           ' makes p15 and p14 inputs, the rest are outputs
OUTL = %0000000000000000           ' all outputs off


'------[ Program ]-------------------------------------------------------------------
'
'
Main:

SStartagain:
  Trigger = 0
SLookAgain:
  IF Trigger = IsOff THEN SStartAgain     ' if no group, start at the beginning
  GroupWait = GroupWait + 1
  IF GroupWait < 20 THEN SLookAgain       ' keep looking until we see group many times


Light1 = IsOn

PAUSE 500

PULSOUT Killyou,1

PAUSE 2000

Light1 = IsOff

PAUSE 2000

Light2 = IsOn

PAUSE 500

PULSOUT Laugh,1

PAUSE 2000

Light2 = IsOff

FStartAgain:
GroupWait = 0
FLookAgain:
  IF Trigger = IsOn THEN FStartAgain    ' if there is group, start at the beginning
  GroupWait = GroupWait + 1
  IF GroupWait < 100 THEN FLookAgain    ' keep looking until we see no group many times

GOTO Main

JonnyMac

Do me a favor and describe how you want the program to behave -- but don't do it in code. Be very specific about timing, audio files to play, etc.  Be specific -- again, in English, not code -- and I should be able to get you going. I looked up the BooTunes and there should be no problems connecting.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

I'm no expert on the Prop-2 but I think the problem might be the second line under MAIN.......Trigger = 0
Shouldn't it be Groupwait = 0 ?

kaamra

When the PIR motion sensor is triggered, I want an LED to come on, and a 10 second audio file to play from the Bootunes, then the LED goes off. Then, a second LED comes on, and a 17 second audio file to play, and that LED goes off. That's it. I've never programmed in BASIC before, and I'm not sure on the right way to wire everything together. I hope that explains what I'm trying to do.

JackMan

By your description, the PAUSE's following the 2 PULSOUT commands are not correct. They need to be 10000 and 17000 in order for the LEDs to remain lit until the end of the audio files. There may be other issues also, like I said, I'm no expert with the BS2.

kaamra

I thought I would probably need to add pauses there, but so far, I can't get it to do anything.

JonnyMac

August 23, 2013, 09:38:26 AM #6 Last Edit: August 23, 2013, 10:01:36 AM by JonnyMac
Connections could be a problem -- you've made no indication of how you've connected the Prop-1 to the BooTunes box.

Based on their documentation and features, here's what I would do:

1) Power the BooTunes box from the Prop-2 V+ and GND terminals
    -- this allows the Prop-2 power switch to control both

2) Use the Busy output so that you don't have to insert and deal with delays
    -- remove pin 1 of the ULN2803
        * see http://www.efx-tek.com/php/smf/index.php?topic=130.0
    -- move the P15 SETUP jumper to the UP position
    -- use a WRB wire to connect to the BooTunes Busy port (black to emitter [arrow], white to cathode [no arrow])

3) Use P14 as the trigger port
    -- connect N.O. trigger between P14.WHITE and P14.RED

4) Starting audio
    -- connect V+ to input BooTunes C[ommon] terminal
    -- connect OUT1 (Audio1) to BooTunes input 1
    -- connect OUT4 (Audio2) to BooTunes input 2


As we make our own audio player, I don't have a BooTunes and cannot test this code -- it does compile without errors. There is  timing spec for inputs on the BooTunes box so I made a routine that waits for the Busy indicator to tell me the player is active. Another subroutine tells me it's done -- this means you can change audio files without having to re-time your program.

Note that I changed your IO lines -- please connect the code as-is, then move IO lines (if you really need to) after you get things working. Note that the IO definitions for the audio output pins use CON instead of PIN; this is important for the way this program is designed.

' =========================================================================
'
'   File...... karma_player.bs2
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Busy            PIN     15                      ' (I) SETUP = UP; NO ULN
Trigger         PIN     14                      ' (I) SETUP = DN

Audio2          CON      4                      ' (O)
Light2          PIN      3                      ' (O)

Audio1          CON      1                      ' (O)
Light1          PIN      0                      ' (O)


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

IS_ON           CON     1                       ' for active-high in/out
IS_OFF          CON     0

TR_ON           CON     1
TR_OFF          CON     0

YES             CON     1
NO              CON     0

AUDIO_PLAYING   CON     0                       ' play = OC output


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

timer           VAR     Byte                    ' for debouncing
asPin           VAR     Byte                    ' audio start pin


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

Reset:
  OUTH = %00000000 : OUTL = %00000000           ' clear all
  DIRH = %00000000 : DIRL = %00011011           ' set outputs


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

Main:
  timer = 0
  DO WHILE (timer < 100)                        ' debounce = 100ms
    PAUSE 5
    IF (trigger = TR_OFF) THEN
      timer = 0
    ELSE
      timer = timer + 5
    ENDIF
    PAUSE 5
  LOOP

Section1:
  asPin = Audio1
  GOSUB Audio_Start
  Light1 = IS_ON
  GOSUB Audio_HOld
  Light1 = IS_OFF


  ' PAUSE 1000                                  ' delay between sections


Section2:
  asPin = Audio2
  GOSUB Audio_Start
  Light2 = IS_ON
  GOSUB Audio_HOld
  Light2 = IS_OFF

  GOTO Reset


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

Audio_Start:
  HIGH asPin
  PAUSE 25
  IF (Busy <> AUDIO_PLAYING) THEN
    GOTO Audio_Start
  ELSE
    LOW asPin
  ENDIF
  RETURN

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

Audio_Hold:
  PAUSE 25
  IF (Busy = AUDIO_PLAYING) THEN
    GOTO Audio_Hold
  ENDIF
  RETURN


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

kaamra

One more question, where can I get a WRB wire? I can't seem to find one anywhere.

JonnyMac

We have them in 14" and 68" versions -- the latter is good for connecting sensors.

-- http://www.efx-tek.com/topics/cables.html
Jon McPhalen
EFX-TEK Hollywood Office