November 23, 2024, 04:03:43 PM

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.


RC-4 and 3-Way switch

Started by Jadams, July 15, 2010, 05:35:47 AM

Previous topic - Next topic

Jadams

I want to control a 120V light with a RC-4 but also want to have an ON/OFF switch in the circuit.  I want to turn the light on or off with either the RC-4 or the switch.  The circuit would work like a common 3-way switch setup.  I can do the code but can't figure out the RC-4/switch configuration.

Thanks for your help.
Jim Adams

JonnyMac

You'd probably have to change the RC-4 firmware.  The X1-X4 inputs go directly to the relays so while you can use them to turn on a relay with a switch, you couldn't turn that circuit off with a command to the RC-4.

What I'm thinking is that you could reprogram the board with a fixed baud rate and address; then you could use a button across one of the headers (e.g., BR) to toggle the desired output. 

This is an advance project and requires you to have an SX-Key or SX-Blitz to reprogram the board.

Jon McPhalen
EFX-TEK Hollywood Office

Jadams

After reading your reply, I tried to simplify.  I can live without the 3 way switch idea so I used a SPST switch.  Here is some simple code the seems to work for my application.  Also attached is some rough art work.  I always like to ask, what can go wrong with this setup?

Thanks

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   K1             = BIT0
SYMBOL   K2             = BIT1
SYMBOL   K3             = BIT2
SYMBOL   K4             = BIT3


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00000000                              ' no direct outputs (yet)

  relays = IsOff
  SEROUT Sio, Baud, ("!!!!!RC4", %00, "X")      ' clear RC-4 outputs


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

Main:
  K2 = IsOn
  GOSUB Update_RC4                              ' activate relay(s)


IF Trigger = IsOn THEN Main
  relays = IsOff
SEROUT Sio, Baud, ("!!!!!RC4", %00, "X")
  K1 = IsOn
  GOSUB Update_RC4                              ' activate relay(s)
  PAUSE 3000                                    ' hold 3 seconds

  GOTO Reset


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

Update_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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


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


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


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


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


' -----[ User Data ]-------------------------------------------------------
Jim Adams

JonnyMac

I don't know that anything can go wrong, per se, but you do have a situation where one output can be controlled by two relays or a switch -- if that's what you want, okay.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

July 15, 2010, 06:06:25 PM #4 Last Edit: July 15, 2010, 06:15:15 PM by JackMan
Yeah, Jon is right, your wiring diagram is connected to 2 outputs of the RC-4. By your description you would only need 1 output of the RC-4 and just connect your manual switch in parallel (connect the 120v HOT to one side of K1 and the switch, connect the other side of K1 and the other side of the switch to the load). Your wiring diagram would not allow you to turn on the light with the manual switch unless the K2 output on the RC-4 is active.

Jadams

I should explain the task a little better:

There is an outside light on my shop that I want to turn on in the event the light beam on my security system is broken (NC contact).  I also want the use of the ON/OFF light switch.  I'm trying to get rid of my X10 stuff.

In the code, the first line under Main is K2=IsOn.  That allows power to the light switch and the light can then be switched on/off at anytime.  99% of the time the switch will be OFF.  When my NC switch (Trigger) goes open, K2 goes off (kills the power to the switch) and K1 turns on for 3 seconds.

All that being said, I may want to work on the logic BEFORE happy hour, but no blue smoke yet.

Thanks for looking.
Jim Adams

bsnut

If you want waste output on your RC4 that's fine, but the best way for you to do this is.  Take the 3way switch and hook-up the point on the 3way switch (dark color screw) and connect it to the light you are controlling and the one of the other 2 screws to the switch and connect it to the RC4 K1 and the last screw on the 3way switch to the hot (line) and the remaining screw on the RC4 TB to the same hot. This gives you an HOA(Hand-Off-Auto) operation.

I attached is a drawing so you can see what I am talking about in this post     
William Stefan
The Basic Stamp Nut

JackMan

July 16, 2010, 05:09:04 AM #7 Last Edit: July 16, 2010, 05:25:34 AM by JackMan
Quote from: Jadams on July 15, 2010, 09:22:50 PM
I should explain the task a little better:

There is an outside light on my shop that I want to turn on in the event the light beam on my security system is broken (NC contact).  I also want the use of the ON/OFF light switch.  I'm trying to get rid of my X10 stuff.

In the code, the first line under Main is K2=IsOn.  That allows power to the light switch and the light can then be switched on/off at anytime.  99% of the time the switch will be OFF.  When my NC switch (Trigger) goes open, K2 goes off (kills the power to the switch) and K1 turns on for 3 seconds.

All that being said, I may want to work on the logic BEFORE happy hour, but no blue smoke yet.

Thanks for looking.

That will work just fine but you really don't need to kill the power to the switch. It doesn't matter if the switch and K1 are active at the same time. The light will be on if K1, the switch, or both are active. A 3-way switch will work as bsnut has explained, but a standard toggle switch wired in parallel would be fine also.

Jadams

Both ways work perfectly as I have tested them on my bench.  This is a much simpler setup than mine.

Thanks for the tips.
Jim Adams