November 23, 2024, 12:53:04 PM

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.


New to Prop-1 Need Assist with Programming

Started by machtoo, June 11, 2012, 12:41:31 PM

Previous topic - Next topic

JonnyMac

Well, it looks like Jack and William got you sorted while I was traveling home from MHC.  Welcome to the forums and do have fun with your EFX-TEK products.
Jon McPhalen
EFX-TEK Hollywood Office

machtoo

Thanks.  I am testing the program and it appears to be working.  May need a couple of tweaks but overall it is triggering as programmed.

JonnyMac

Here's a slight variation that does a couple things differently.  For example, you don't have to use 3 lines of code when using the OUTx terminals in this configuration -- PULSOUT will do the trick with short pulses (up to 655ms). I also configured the code to be more flexible with other kinds of triggers (either active-high [like the Parallax PIR] or active-low [like many industrial PIRs]).

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


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Audio2          = 2
SYMBOL  Audio1          = 1
SYMBOL  StrobeLight     = PIN0


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

SYMBOL  TR_ON           = 1                     ' active-high trigger
SYMBOL  TR_OFF          = 0
SYMBOL  TR_DEBOUNCE     = 100                   ' 100ms = valid trigger

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

SYMBOL  PIT_DELAY       = 3000                  ' 3 seconds ***

SYMBOL  AUDIO1_TIME     = 5000                  ' 5 seconds ***
SYMBOL  AUDIO2_TIME     = 5000                  ' 5 seccons ***


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

SYMBOL  timer           = B2                    ' timing


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs

  PAUSE 30000                                   ' PIR warmup/delay


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

Main:
  timer = 0

Check_Trigger:
  PAUSE 5                                       ' loop pad
  IF Trigger = TR_OFF THEN Main                 ' reset timer
    timer = timer + 5                           ' update debounce timer
    IF timer < TR_DEBOUNCE THEN Check_Trigger   ' wait for debounce

  PAUSE PIT_DELAY                               ' let victim get curious

Pit_Show:
  StrobeLight = IS_ON
  PULSOUT Audio1, 3000                          ' start audio 1 (30ms pulse)
  PAUSE AUDIO1_TIME                             ' let audio 1 finish
  IF Trigger = IS_ON THEN Pit_Show              ' check PIR for victim

Walk_Away:
  StrobeLight = IS_OFF
  PULSOUT Audio2, 3000                          ' start audio 2

  GOTO Reset                                    ' 30s delay before next


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


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


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

machtoo

Good news and bad news. :o  I think the Prop-1 is doing what it is told, but it is not triggering the audio tracks on the Troll.  The code to trigger the Troll was provided by the vendor, but since the Troll needs a very brief signal to ground (0 volts), I believe the code sequence is not correct to trigger the Troll.  I believe it should be in a HIGH state, go LOW, PAUSE 25, and then go HIGH again.  I sent the code to the vendor with some questions.  I think this is the issue.  The lighting control is working fine.  I added a second relay control as my solid state relays are SPST.  They only draw 7.5 ma but can handle up to 240v at 10 amps.  One stays high normally keeping the main well light on until the PIR is triggered then it goes low and the strobe relays is activated until the PIR doesn't detect anything (victim leaves).  We're close. :)

JonnyMac

June 13, 2012, 11:39:33 AM #19 Last Edit: June 13, 2012, 11:48:15 AM by JonnyMac
If you ask the vendor will probably tell you that the trigger inputs are "open collector" type; this is why you can use the OUTx terminals.  What you also have to do is connect the GND terminal of the Prop-1 to the ground terminal on the audio device.

The OUTx terminals are inverted from the corresponding Px.W pins; when Px.W is LOW (or INPUT mode), the OUTx terminal will be "open" -- just like an open switch (we call this state "floating" in the electronics world). When a Px.W pin is HIGH the OUTx terminal acts like a closed switch to ground (GND terminal).  When using an open-collector output to another device the grounds on the devices must be connected together. 
Jon McPhalen
EFX-TEK Hollywood Office

machtoo

Thanks.  The grounds are connected.  I will ask him the others.

JonnyMac

At MHC I was doing a lot of talking about programming the Prop-1 and many times I coached people to build their program in stages.  Whenever you're dealing with a non-EFX-TEK product we suggest you just get that part working before doing the whole program.  Some of our products have 2000 - 5000 lines of code in them; I always wrote in sections that could be independelty tested.  Once you get a bit of code working then you can re-use it.

A technical detail about that device.  It should have a "pull-up" on each of the trigger pins which keeps it in the high state when the input is open (this is very traditional).  If you decide to go with the  3-wire connection (which I saw the he supports; I don't know if for more than one trigger, though), then the sequence shoudl be:

  LOW Audio1
  PAUSE 25
  INPUT Audio1


Here's why: It's not a good idea to drive a high signal from an external device into an open-collector input that is pulled-up. There can be differences in the power-supplies which will create undesirable current flow when you want the device to be off.  By setting a pin to INPUT mode your are releasing the output driver on the pin and allowing the audio device's pull-up to pull the trigger input back high.
Jon McPhalen
EFX-TEK Hollywood Office

machtoo

So, if I understand correctly, you are saying the 3 pin connectors on P1 and P2 would be connected to the Troll...only the signal (White) and Ground (Black).  (I fly R/C so a lot of servos cables).  Using the Code you listed to create the 25 msec connection to ground?

machtoo

One quick question...in your example you use the INPUT command after the LOW instead of the HIGH command in the vendor's example.  What is the difference?

Thanks

JonnyMac

INPUT releases the pin driver, effectively creating a normally-open switch in the open position. The HIGH command drives 5v into the input.  I don't like doing this because there can be variations between the Prop-1 5v supply and the other device's power supply leading to nasty and unwanted currents between the devices.  For open-collector inputs, use LOW, PAUSE, INPUT. It is the responsibility of a vendor that creates a device with open-collector inputs to have the pull-ups.  I'm sure this device does which is why it will work with a normally-open button between a trigger pin and ground.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Quote from: machtoo on June 13, 2012, 12:22:37 PM
So, if I understand correctly, you are saying the 3 pin connectors on P1 and P2 would be connected to the Troll...only the signal (White) and Ground (Black).  (I fly R/C so a lot of servos cables).  Using the Code you listed to create the 25 msec connection to ground?

Yes, but as I indicated, when using the Px.W pins with an open-collector device use this sequence:

  LOW Audio1
  PAUSE 25
  INPUT Audio1


LOW pulls the input to ground. Input releases the pin back to the pull-up on the trigger pin in the audio device.

This may in fact work better as the Px.W pins can be pulled all the way to ground. The OUTx terminals are through a transistor which does have about a 1.2v drop; this is usually low enough to go under the VIL (voltage, input low) threshold of a 5v device, but sometimes it's not.  I don't know what the internal voltage of the audio player is -- another reason NOT to drive the Px.W pin HIGH to stop the trigger pulse.
Jon McPhalen
EFX-TEK Hollywood Office

machtoo

June 13, 2012, 04:47:56 PM #26 Last Edit: June 13, 2012, 05:00:08 PM by machtoo
Hi Jon,

Well after quite a bit of experimentation, I have learned some things but I still can't get the Prop-1 to trigger the Audio Troll.  (FYI, I have 2 EE degrees, Amateur Radio Extra License, computer enthusiast , and worked with computer technology for 35+ years so not a newbie to the tech side).
I measured the voltage on the W pins while running the routine (both with and without the Troll attached, average 4.8 volts for a high, the low was 55 mv (not true zero or ground).  I tried various timings for the ground pulse (10 msec, 25 msec, 100 msec, 250 msec and 1000 msec) Did not trigger the Ausio Troll.  I tried the code with INPUT.  This resulted in the voltage staying low when it went low.  My guess is the INPUT read saw the low condition and stayed there ( I realize it is supposed to work differently based on your previous input should jsu be a pin release).  The Troll does have pullup on the trigger inputs.  I tried using the HIGH command after the low which seemed to work, I could see the voltage pulse, but could not trigger on the Troll.

FYI, here is some text from Michael...
Odd... I've tested that code before.
Maybe try a longer trigger length of time such as PAUSE  100.
The Prop-1 should be sinking OUT1 and OUT2 to ground when set HIGH and that's all it should take.
The TRIG inputs on the AudioTroll are internally pulled high and trigger a sound when momentarily pulled low.

The only other thing I can suggest is try connecting to the W (white) pin of P1 on the Prop-1, in which case you would have to reverse the HIGH/LOW transition:

LOW  AudioTroll1
PAUSE 25
HIGH AudioTroll1


Had to walk away from the bench for a bit to relieve the frustration.  I have the Prop-1 and the Audio Troll on the bench.  The grounds are connected.  I am using a single wire from the W pins on P1 and P2 to the TG1 and TG2 inputs on the Troll. 

Here is the latest version of the code...
                       ' =========================================================================
'
'   File...... bottomlesspit.bs1
'   Purpose... To Control a Bottomless Pit prop
'   Author.... Dean Taunton
'   E-mail.... dtaunton@nc.rr.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
  'This program is used to interface an Audio Troll and relay for controlling 110v A/C lights
  'to the Prop-1

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


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

SYMBOL  Trigger         = PIN6               ' SETUP = DN "PIR"
SYMBOL  Lightrelay1     = 0                  ' Light Relay
SYMBOL  Lightrelay2     = 3                  ' Light Relay
SYMBOL  AudioTroll1     = PIN1               ' Sound trigger for sound track 1
SYMBOL  AudioTroll2     = PIN2               ' Sound trigger for sound track 2


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0
SYMBOL ScanDelay        = 10                    '10 ms scan delay
SYMBOL showdelay        = 120                   'set "showdelay" here and is
                                                'set in seconds

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

SYMBOL  timer           = B2
SYMBOL  showtimer       = W6                    ' Delay variable for the show
SYMBOL pirTimer         = B2                    ' for debouncing

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

Reset:
  PINS = %00000111                              ' clear outputs  set 0,1,2 to high
  DIRS = %00111111                              ' make P0-P5 outputs
  HIGH LightRelay1                              ' Turns main well light on
  PAUSE 30000                                   ' PIR warmup delay

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

Main:
  timer = 0                                     ' reset timer

  OUTPUT AudioTroll1                   ' Set Pin as an output
  OUTPUT AudioTroll2                   ' Set Pin as an output


Check_Trigger:
  PAUSE ScanDelay
  pirTimer = pirTimer + ScanDelay * Trigger     ' advance/clear timer
  IF pirTimer < 250 THEN Check_Trigger

Pit_Show_Start:
  PAUSE 3000                         ' Pause 3 seconds while victim looks down pit
  LOW LightRelay1                    ' Turn Main Light Off
  HIGH Lightrelay2                   ' Turn bottom strobe On
  LOW AudioTroll1                   ' audio player trigger 1 connected on OUT1
  PAUSE 10                            ' delay for triggering audio player
  HIGH AudioTroll1

Pit_Show:
    IF Trigger = IsOn THEN Pit_Show

Walk_Away:
  LOW Lightrelay2
  HIGH LightRelay1
  LOW AudioTroll2                 ' audio player trigger 2 connected on OUT2
  PAUSE 10
  HIGH AudioTroll2
  GOTO Main

I know it shouldn't be this difficult  ???

Thanks for the patience and all the support!  Hopefully a breakthrough will happen  :)

JonnyMac

The Prop-1 seems to be doing what you're asking of it; the question becomes, what does the audio device actually require? I designed and coded our AP-16+ so I know exactly what it needs; I'm confused that the other vendor doesn't know the same thing about that product (could be that he's using a sub-assembly for another source that's not well documented). We have used our controllers to activate a variety of audio players using the Px.W and OUTx terminals.

Tech stuff: as you know, there will always be a small drop across a transistor junction. The ULN is actually a Darlington so it's higher than what you'd expect, yet usually low enough to satisfy the VIL requirement of the device.

That the input command didn't allow the trigger pin to go back to near Vdd is very odd.

Question: Have you tested the device with a simple mechanical switch to ensure that it will trigger at all?

I suggested earlier that you should break the program apart and test each section separately.  Once you get the trigger inputs working then the rest *should* be easy. 
Jon McPhalen
EFX-TEK Hollywood Office

machtoo

I have used a piece wire and triggered the Audio Troll successfully.  The vendor sent some things to try last night.  Thanks

bsnut

June 14, 2012, 07:49:04 AM #29 Last Edit: June 14, 2012, 07:52:30 AM by bsnut
I noticed that you made some mistakes in code, in your last post which caused your program not to work the way you want it to, which is common problem when you cut and paste programs together. We all make this kind of mistake. So, what I did for you is corrected it. To see what mistakes you made and my changes that I made look at your last post and this one below.

' =========================================================================
'
'   File...... bottomlesspit.bs1
'   Purpose... To Control a Bottomless Pit prop
'   Author.... Dean Taunton
'   E-mail.... dtaunton@nc.rr.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
  'This program is used to interface an Audio Troll and relay for controlling 110v A/C lights
  'to the Prop-1

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


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

SYMBOL  Trigger         = PIN6               ' SETUP = DN "PIR"
SYMBOL  Lightrelay1     = 0                  ' Light Relay
SYMBOL  Lightrelay2     = 3                  ' Light Relay
SYMBOL  AudioTroll1     = 1                  ' Sound trigger for sound track 1
SYMBOL  AudioTroll2     = 2                  ' Sound trigger for sound track 2


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0
SYMBOL ScanDelay        = 10                    '10 ms scan delay

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

SYMBOL pirTimer         = B2                    ' for debouncing

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

Reset:
  PINS = %00000111                              ' clear outputs  set 0,1,2 to high
  DIRS = %00111111                              ' make P0-P5 outputs
  PAUSE 30000                                   ' PIR warmup delay

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

Main:
  pirTimer = 0                                  ' reset timer
  HIGH LightRelay1                              ' Turns main well light on

Check_Trigger:
  PAUSE ScanDelay
  pirTimer = pirTimer + ScanDelay * Trigger     ' advance/clear timer
  IF pirTimer < 250 THEN Check_Trigger

Pit_Show_Start:
  PAUSE 3000                         ' Pause 3 seconds while victim looks down pit
  LOW LightRelay1                    ' Turn Main Light Off
  HIGH Lightrelay2                   ' Turn bottom strobe On
  LOW AudioTroll1                    ' audio player trigger 1 connected on OUT1
  PAUSE 25                           ' delay for triggering audio player
  HIGH AudioTroll1

Pit_Show:
  IF Trigger = IsOn THEN Pit_Show

Walk_Away:
  LOW Lightrelay2
  HIGH LightRelay1
  HIGH AudioTroll2                 ' audio player trigger 2 connected on OUT2
  PAUSE 25
  LOW AudioTroll2
  GOTO Main


Programs like this one below are what you build form and test first and after you are happy with the results than you build from there and test again. 

' =========================================================================
'
'   File...... AudioTroll_Test.bs1
'   Purpose... To test the AudioTroll audio player with the Prop-1
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
' Connect the AudioTroll audio player trigger to the Prop-1 OUT0 screw terminal
' and connect both the grounds screw terminals together so they share the grounds

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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  AudioTroll1     = 0        ' Sound trigger connected on OUT0 and GRN

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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

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

SYMBOL  timer           = B2                    ' debounce timer

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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs

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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:                                  ' checks button debounce
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 200 THEN Check_Trigger             ' wait for 0.2 sec input

Audio_Trigger:
  HIGH  AudioTroll1               ' Close trigger connected on OUT0 and GRN
  PAUSE 25                        ' delay for triggering audio player
  LOW AudioTroll1                 ' Open trigger connected on OUT0 and GRN
  GOTO Main                       ' Return to the beginning


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


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


' -----[ User Data ]-------------------------------------------------------
William Stefan
The Basic Stamp Nut