May 01, 2024, 09:03:35 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Prop-2 RC4 help

Started by time2dive, August 31, 2014, 07:13:24 PM

Previous topic - Next topic

time2dive

I am having problems with my RC4.
I am either:
(A) using it incorrectly
(B) it has stopped working
(C) I have not programmed the Prop2 correctly
(D) all of the above

I am using a RC4 to control a fog machine.... the fog machine wiring is correct.
I was using a three wire jumper from pin 8 to X2 trying to control the relay directly rather that serially (which may be the using it incorrectly part)
The white wire does go high when it is supposed to in the program at pin 8.
There are no LEDs lit up on the RC4.
I thought at one time this setup worked.

Should this setup work or do I need to control the RC4 via the serial port.?
Is there a simple way to test the RC4 to see if it is dead?
If I do need to control it via the serial port what  changes do I need to make to my code?

here is the program:

' =========================================================================
'
'  ' =========================================================================
'
'   File...... Tim01--Doors From Hell.BS2
'   Purpose...
'   Author.... Timothy Ewing
'   E-mail.... time2dive@hawaii.rr.com
'   Started... 15 Feb 09
'   Updated... 27 Oct 09
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Doors from Hell controller
' output pneumatic solenoid
' output MDFLY
' output light
' output fog machine


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

Sio             PIN      8                      ' no ULN / SETUP = UP
Trigger         PIN     14                      ' no ULN / SETUP = DN
TX              PIN     13                      ' no ULN / SETUP = UP
RX              PIN     12                      ' no ULN / SETUP = UP

'
'
'
'



Pir             PIN     6                    ' PIR sensor
doors           PIN     0                    ' doors is connected to P5 to simulate pneumatic solenoid
outside         PIN     4                    ' lights are connected to P4
inside          PIN     9                    ' output to a relay to control the inside lights
fog             PIN     8                    ' output to a relay to control a fog machine
audio           PIN     1                    ' turn on mp3
' -----[ Constants ]-------------------------------------------------------

IsOn            CON     1
IsOff           CON     0
t9600    CON  84
open     CON  $8000
baud     CON  open + t9600


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

PAUSE 4000                                      MDFLY to intialize

Main:
  IF (Pir = IsOff) THEN Main                    ' wait for PIR activity
  HIGH outside                                  ' turn on outside lights
  HIGH audio
  PAUSE 3000                                    ' hold for 3 seconds          3 seconds
  HIGH doors                                    ' doors open
  PAUSE 600                                     ' hold for 1/2 second
  LOW doors                                     ' doors closed
  PAUSE 600                                     ' hold for 1/2 second
  HIGH doors                                    ' doors open
  PAUSE 600                                     ' hold for 1/2 second
  LOW doors                                     ' doors closed
  PAUSE 600                                     ' hold for 1/2 second
  HIGH doors                                    ' doors open
  PAUSE 600                                     ' hold for 1/2 second
  LOW doors                                     ' doors closed                5.5 seconds
  PAUSE 4500                                    ' hold for 5 seconds          10.5 seconds
  HIGH doors                                    ' doors open
  PAUSE 600                                     ' hold for .3 second
  LOW doors                                     ' doors closed
  PAUSE 600                                     ' hold for .3 second
  HIGH doors                                    ' doors open
  PAUSE 600                                     ' hold for .3 second
  LOW doors                                     ' doors closed
  PAUSE 600                                     ' hold for .3 second
  HIGH doors                                    ' doors open
  PAUSE 600                                     ' hold for .3 second
  LOW doors                                     ' doors closed
  PAUSE 600                                     ' hold for .3 second
  HIGH doors                                    ' doors open
  PAUSE 600                                     ' hold for .3 second         12.6 seconds
  LOW doors                                     ' doors closed
  PAUSE 1600                                    ' hold for 3 seconds         15.6 seconds
  HIGH doors                                    ' doors open
  PAUSE 700                                     ' hold for .7 second
  LOW doors                                     ' doors closed
  PAUSE 700                                     ' hold for .7 second
  HIGH doors                                    ' doors open
  PAUSE 700                                     ' hold for .7 second
  LOW doors                                     ' doors closed
  PAUSE 700                                     ' hold for .7 second
  HIGH doors                                    ' doors open
  PAUSE 700                                     ' hold for .7 second         19.1 seconds
  LOW doors                                     ' doors closed
  PAUSE 4400                                    ' hold for 4.4 seconds       23.5 seconds
  HIGH doors                                    ' doors open
  PAUSE 500                                     ' hold for 1/2 second
  LOW doors                                     ' doors closed
  PAUSE 500                                     ' hold for 1/2 second
  HIGH doors                                    ' doors open
  HIGH inside                                   ' inside lights on 1.5 seconds
  PAUSE 500                                     ' hold for 1/2 second
  LOW doors                                     ' doors closed
  PAUSE 500                                     ' hold for 1/2 second
  HIGH doors                                    ' doors open
  PAUSE 500                                     ' hold for 1/2 second
  LOW doors                                     ' doors closed               26 seconds
  LOW inside                                    ' inside lights off
  PAUSE 2000                                    ' hold for 2 seconds         28 seconds
  HIGH inside                                   ' inside lights on 3.1 seconds
  HIGH doors                                    ' doors open
  PAUSE 700                                     ' hold for .7 seconds
  LOW doors                                     ' doors closed
  PAUSE 500                                     ' hold for .5 seconds
  HIGH doors                                    ' doors open
  PAUSE 700                                     ' hold for .7 seconds
  LOW doors                                     ' doors closed
  PAUSE 500                                     ' hold for .5 seconds
  HIGH doors                                    ' doors open
  PAUSE 700                                     ' hold for .7 seconds        30.9 seconds
  LOW doors                                     ' doors closed
  LOW inside                                    ' inside lights off
  PAUSE 1000
  HIGH inside                                   ' inside lights ON FOR 1.5 seconds
  PAUSE 1500
  LOW inside                                    ' inside lights off for 1 second
  HIGH doors                                    ' doors open
  PAUSE 1000
  LOW doors                                     ' doors close
  HIGH inside                                   ' inside lights on for 1.5 seconds
  HIGH doors                                    ' doors open
  PAUSE 1000
  LOW doors                                     ' doors close
  PAUSE 500
  LOW inside                                    ' inside lights off for 1 second
  HIGH fog                                      ' Fog machine on for 3.5 seconds
  PAUSE 1000
  HIGH inside                                   ' inside lights on for 1.5 seconds
  PAUSE 1500
  LOW inside                                    ' inside lights off for 1 second
  HIGH doors                                    ' doors open
  PAUSE 1000
  LOW doors                                     ' Doors close
  HIGH inside                                   ' inside lights on for 1.5 seconds
  PAUSE 1500
  LOW fog                                       ' Fog machine off
  LOW inside                                    ' inside lights off
  PAUSE 750
  HIGH inside                                   ' inside lights on 1second
  PAUSE 1000
  LOW inside                                    ' inside lights off
  PAUSE 750
  HIGH inside                                   ' inside lights on 1second
  HIGH fog                                      ' Fog machine on for 2.5 seconds
  PAUSE 1000
  LOW inside                                    ' inside lights off
  LOW outside                                   ' Turn off outside lights
  PAUSE 1500
  LOW fog
  PAUSE 2000
  LOW audio                                       ' Fog Machine off
  PAUSE 20000                                   ' hold for 20 seconds
  GOTO Main                                     ' back to main

time2dive

Bother...took a wire brush to the relay pins and everything is now working.  I may get some conductive lubricant for the contacts on the board.

JonnyMac

I just posted some season-beginning maintenance tips in the Announcements section.

Notes:
  -- for trigger and serial controller, use P12..P15 (these are the only pins with SETUP jumpers)
  -- use a debounce loop to prevent false positives with the trigger inputs


The top of your program should probably look something like this:

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

timer           VAR     Word


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

Power_Up:
  PAUSE 40000                                  ' let MDFLY initialize

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

  PAUSE 20000                                  ' reset delay


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

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

  ' program code here


  GOTO Reset
Jon McPhalen
EFX-TEK Hollywood Office