November 24, 2024, 02:01:01 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.


Parallax Motion Not Working with Prop-2

Started by Spooky Dad, August 24, 2014, 01:51:24 AM

Previous topic - Next topic

Spooky Dad

Haunters - I am using a Prop-2 and Parallax 555-28027  Passive Infrared Motion Sensor.  Below is the code.  I have connected the pins on the prop-2 to a Terminal 66 block using 1/2 of a 14" cable.  My issue is that when I directly connect the prop-2 using a 14" cable to the motion sensor, it works.  When I connect it through the Terminal 66 block, it never triggers.  I have taken Ohms measurement across the 66 block and there is a low Ohm connection (sub 2 ohms) and no short across the rows on the terminal block with R-G-B.  What am I doing wrong?

' =========================================================================
'
'   File......  Skeleton G2e.bs2
'   Purpose...
'   Author....  Karlen S. Alexander
'   E-mail....  kalexander@secureworks.com
'   Started...
'   Updated...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

NOTUSED         PIN     15                      ' (I) SETUP = DN; NO ULN
SkelMot1        PIN     14                      ' (I) SETUP = DN
SkelMot2        PIN     13                      ' (I) SETUP = DN

SkelA           PIN      9                      ' (O)
SkelB           PIN      8                      ' (O)
SkelC           PIN      7                      ' (O)
SkelD           PIN      6                      ' (O)
SkelE           PIN      5                      ' (O)
SkelF           PIN      4                      ' (O)
SkelArmG        PIN      3                      ' (O)
SkelArmH        PIN      2                      ' (O)
SkelArmI        PIN      1                      ' (O)
SkelArmJ        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 = %00000011 : DIRL = %11111111           ' set outputs
  PAUSE 20000                                   ' let motions settle

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

DEBUG CLS, "Skeleton G2E Controller", CR,"-- program (re)started", CR, CR

Main:
  timer = 0
  DO WHILE (timer < 100)                        ' debounce = 100ms
    DEBUG CLS, "Stuck in Trigger Mode", CR, CR
    PAUSE 5
    IF (SkelMot1 = TR_OFF) THEN
      DEBUG CLS, "Motion is Not High", CR, CR
      timer = 0
    ELSE
      DEBUG CLS, "HIGH HIGH HIGH", CR, CR
      timer = timer + 5
    ENDIF
    PAUSE 5
  LOOP

SkelA = Is_On
SkelB = Is_On
SkelC = Is_On
SkelD = Is_On
SkelE = Is_On
SkelF = Is_On
SkelArmG = Is_On
SkelArmH = Is_On
SkelArmI = Is_On
SkelArmJ = Is_On

PAUSE 3000

OUTH = %00000000 : OUTL = %00000000

GOTO Main


JackMan

If it works when you you connect the PIR directly to the Prop-2, then there's nothing wrong with your code. I don't know what a "terminal 66" block is but I'd say your problem lies somewhere in your connections.

JonnyMac

August 24, 2014, 09:00:08 AM #2 Last Edit: August 24, 2014, 09:24:22 AM by JonnyMac
QuoteIf it works when you you connect the PIR directly to the Prop-2, then there's nothing wrong with your code.

That's a fair point. Pictures of the non-working connections will be more useful than code that does work when the PIR is connected directly to the Prop-2.

Still, there is a bit of a "gotcha." I just looked at my Prop-2 template -- which you seem to have used -- and it has two PAUSE 5 statements in the loop (at top and bottom). Remove the one from the bottom, and remove your DEBUG statements as well.

REMINDER: Putting DEBUG into your code affects timing, so you shouldn't insert DEBUG into timing-sensitive code.

Your trigger code should look like this:

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


And be sure to check the SETUP jumper on the pin used for the PIR.

REMINDER: Embedded listings are easier to read when you highlight the code and change the font to Courier. I also like to change the color to help it stand out.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

August 24, 2014, 09:05:18 AM #3 Last Edit: August 24, 2014, 09:07:52 AM by JonnyMac
Just to make my point about DEBUG, here's that sensor loop with the timing numbers where significant delays are happening.

Main:
  timer = 0
  DO WHILE (timer < 100)
    DEBUG CLS, "Stuck in Trigger Mode", CR, CR         ' ~24ms
    PAUSE 5                                            '   5ms
    IF (SkelMot1 = TR_OFF) THEN
      DEBUG CLS, "Motion is Not High", CR, CR          ' ~21ms
      timer = 0
    ELSE
      DEBUG CLS, "HIGH HIGH HIGH", CR, CR              ' ~17ms
      timer = timer + 5
    ENDIF
    PAUSE 5                                            '   5ms
  LOOP


Note how much time the DEBUG statements are inserting into the loop. Each character transmitted by DEBUG (at 9600 baud) requires just a fraction over 1ms.
Jon McPhalen
EFX-TEK Hollywood Office

Spooky Dad

Thanks JonnyMac and Jackman.  Need to get some jumpers as I do not have any installed. Got it on debug statements which I will remove once I know program works. 

A terminal 66 block is what is used for connecting phone lines to big PBXs (phone systems).  Trying to save space. 

JonnyMac

Those tend to be insulation-displacement connections, right? If this is the case, please have the correct tools for making the connections (I've never been a fan of ID connections).
Jon McPhalen
EFX-TEK Hollywood Office

Spooky Dad

Understood.  I did figure it out.  The size of conductor in the wiring harness cable wasn't large enough to make a solid connection with the block.  I spliced larger cable (22 awg) to the wiring harness and punched the 22 awg onto the block.  All worky now. 

Thanks for pointers on the debug.  Program running smoother. 

Spooky Dad

I will be taking pictures of the Prop-2 and terminal block to help everyone visualize the wiring set up, the issue and what was required to adapt and overcome. 

livinlowe

Quote from: Spooky Dad on August 25, 2014, 12:13:33 PM
I will be taking pictures of the Prop-2 and terminal block to help everyone visualize the wiring set up, the issue and what was required to adapt and overcome.

That is WAY cool, and much apprechiated!
Shawn
Scaring someone with a prop you built -- priceless!