December 03, 2024, 10:27:12 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.


Triggering not working

Started by davisgraveyard, August 01, 2024, 04:55:26 PM

Previous topic - Next topic

davisgraveyard

I have a audio relay circuit that listens for audio and when it it hears a loud signal it triggers a relay switch for a few seconds.   

I wired this to to Pin14 and set the jumper to DM.   I wired the WB pins to the relay COM and NO.
cebek-pm-11-audio-signal-controlled-relay-switch-module-v2.jpg

but this code never exits.  What am I doing wrong?


Trigger      PIN  14 
timer        VAR  Byte

Reset:
  OUTS = $0000                                  ' clear all outputs
  DIRS = $3FFF                                  ' make P0-P13 outputs

Main:
  timer = 0
  DO WHILE (timer < 100)                        ' wait for 0.1s signal
    PAUSE 5                                     ' loop pad
    timer = timer + 5 * Trigger                 ' update timer
  LOOP

' prop code here

Jeff Haas

First I would set up the OUTS and the DIRS the usual way:

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

Reset:
  OUTH = %00000000 : OUTL = %00000000           ' preset IOs
  DIRH = %00100000 : DIRL = %00000000           ' set outputs (1s)

Then I've always done the button check like this, it's a bit different than what you have:

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

 Main:

  'Debounce - Wait for pushbutton activity
  PAUSE 10
  timer = timer + TRIGGER * TRIGGER             ' increment or clear
  IF timer < 10 THEN Main                       ' hold 0.1 s (10 ms x 10)
    timer = 0

This also works, it's from an old PIR template by Jon - it doesn't reset the pirTimer to 0 but you can easily add that:

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

Main:
  DO
    pirTimer = (pirTimer + PIR) * PIR
    PAUSE 10
  LOOP UNTIL (pirTimer > 25)

Jeff Haas

Also, you should be able to test the code with just a regular button connected to the headers.

Just caught this:
QuoteI wired the WB pins to the relay COM and NO.

Connect to the W and R pins on the Prop-2 header.  Here's Jon's Prop-2 template:

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


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


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


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

Sio             PIN     15                      ' no ULN, SETUP = UP
Trigger         PIN     14                      ' SETUP = DN


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

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

TrOn            CON     1
TrOff           CON     0

Yes             CON     1
No              CON     0

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T1200       CON     813
    T2400       CON     396
    T4800       CON     188
    T9600       CON     84
    T19K2       CON     32
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T1200       CON     2063
    T2400       CON     1021
    T4800       CON     500
    T9600       CON     240
    T19K2       CON     110
    T38K4       CON     45
  #CASE BS2PX
    T1200       CON     3313
    T2400       CON     1646
    T4800       CON     813
    T9600       CON     396
    T19K2       CON     188
    T38K4       CON     84
#ENDSELECT

SevenBit        CON     $2000
Inverted        CON     $4000
Open            CON     $8000

Baud            CON     Open | T38K4            ' for EFX-TEK accessories


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

timer           VAR     Word


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

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


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

Main:
  timer = 0                                     ' Prop-2 version of the debounce loop
  DO WHILE (timer < 100)                        ' debounce = 100ms
    PAUSE 5
    IF (trigger = TrOff) THEN
      GOTO Main
    ELSE
      timer = timer + 5
    ENDIF
  LOOP

  ' program code here

  GOTO Reset

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


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


' -----[ User Data ]-------------------------------------------------------

davisgraveyard

I used the W and R wires and its working.  I used your code for the debounce trigger detect too.   

I seem to be having another issue.  The Audio trigger board is detecting the polarity switch as noise and triggering again when the relay is switching the polarity.  I was trying to wire all the boards off of the Prop2 12v power. 

Is there a way I can isolate the 12v for the relay power?

Jeff Haas

I don't have one of those to test with, but you could try a different 12V adapter for each section.  First try a different one for the audio trigger board instead of powering it from the Prop-2, see if having its own power supply will fix the problem.  The relay is powered from the audio trigger board so that may be enough.

What is the audio board listening for?

davisgraveyard

I REALLY don't want to have to use a separate power supply (which would work).  Right now I am using a 12V 4A supply for the Prop2 so that gives each of the boards and the 7 LED's plenty of power.  The problem is the relay board that inverts the polarity for the acutator is causing too much noise on the V+ line which is activating the audio relay board which is my trigger.    The audio board is wired to a projector playing a looping video.  The audio track on the video is silent except for 1 spot with a loud footstep (could be any loud 1 sec noise) that the board is listening for and then triggers the relay.  I have a an EE friend that says I need a diode or a capacitor +resistor on the V+ to the relay board for the acutator to isolate the noise.  Just wondered if there was a simpler way?

 

davisgraveyard

This is a response from Cebek that makes the audio signal Activated Relay switch board.

https://cebek.co.uk/Item/cebek-pm-11-audio-signal-controlled-relay-switch-module

"The motor and secondary relay are inductive loads so you should fit a flyback diode across each as described at Flyback diode - Wikipedia (in the same way a diode is fitted across the coil of the PM-14 relay)."

I purchased a diode online and will try this out.

Jeff Haas

That makes sense, you should probably get a small bag of diodes as part of your inventory.