November 21, 2024, 12:01:32 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.


Prop-1 and 8 Channel relay board.

Started by Clad In Shadows, January 16, 2016, 07:49:36 PM

Previous topic - Next topic

Clad In Shadows

January 16, 2016, 07:49:36 PM Last Edit: January 16, 2016, 07:54:43 PM by Clad In Shadows
I have a simple project but have no clue where to start with a code .

What I would like to do , is hook up an 8-channel relay board ( kit 74 12VDC relays) where each channel will have its own output on the prop-1.

So , Relay 1 goes to OUT0 , relay 2 to OUT1 , etc...
To trigger the outputs , I would use a PIR sensor which would turn on all the relays and leave them on till I reset them with a momentary push button.

How would I go about doing that ?

Thanks.

bsnut

I am a little loss on what you are trying to do and I normally can figure it out :D. So, can you post a step by step of what you are wanting to do?
William Stefan
The Basic Stamp Nut

JonnyMac

January 16, 2016, 10:38:56 PM #2 Last Edit: January 17, 2016, 09:19:34 AM by JonnyMac
The KIT 74 is a parallel device. If you want SET and RESET buttons you'll need to give up two relays.

What you may be misunderstanding about the Prop-1 is that it has 8 IO (input or output) points; if you need two inputs (for buttons), then you have to give up two of the pins for outputs.

Turning on all relays simultaneously may cause a bit of surge in your power supply; I would suggest a slight delay -- as the code below.

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


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


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


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

SYMBOL  BReset          = PIN7                  ' SETUP = DN
SYMBOL  BSet            = PIN6                  ' SETUP = DN


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

SYMBOL  No              = 0
SYMBOL  Yes             = 1

SYMBOL  Is_Off          = 0
SYMBOL  Is_On           = 1


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

SYMBOL  btns            = B0
SYMBOL   btnReset       =  BIT7
SYMBOL   btnSet         =  BIt6

SYMBOL  status          = B1
SYMBOL  idx             = B2


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

Power_Up:
  ' put code here that only happens at power-up/hard reset

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00111111                              ' P5..P0 are outputs


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

Main:
  btns = %11000000                              ' enable buttons
  FOR idx = 1 TO 10                             ' debounce 50ms
    PAUSE 5
    btns = btns & PINS                          ' re-scan
  NEXT

Check_Buttons:
  IF btnSet = Yes THEN Relays_On
  IF btnReset = YES THEN Relays_Off
  GOTO Main

Relays_On:
  IF status = Is_On THEN Release_Btn
  FOR idx = 0 TO 5
    HIGH idx
    PAUSE 25
  NEXT
  status = Is_On
  GOTO Release_Btn

Relays_Off:
  IF status = Is_Off THEN Release_Btn
  FOR idx = 0 TO 5
    LOW idx
    PAUSE 25
  NEXT
  status = Is_Off
  GOTO Release_Btn

Release_Btn:
  PAUSE 50
  btns = PINS & %11000000
  IF btns > 0 THEN Release_Btn
    GOTO Main
Jon McPhalen
EFX-TEK Hollywood Office

Clad In Shadows

Thank you for the fast replies and Jon , thank you for the code.
I didn't realize that I have to sacrifice two outputs in order to use 2 input pins.
Now , that isn't a problem since I might not use all relays anyway.
I will give it a shot and report back.

I have one more question about this setup .
Do I have to cut a leg off of my ULN or not in this setup ?


Bsnut : the setup is simple. A PIR is turning all my relays ON and they will stay on until I push a button.
             As for the code , I would have never figured that out by myself.

JonnyMac

January 17, 2016, 09:18:49 AM #4 Last Edit: January 17, 2016, 09:20:39 AM by JonnyMac
No, you don't -- that's only required when using a pin (usually P7) for serial coms. In your case you will connect N.O. buttons between P7.R and P7.W (Reset) and P6.R and P6.W (Set). OUT0..OUT5 connect to your relays.

Because of the nature of pre-canned controllers, many people misunderstand a standard SBC type product. Again, the Prop-1 has 8 IO points; that could be 8 inputs, or 8 outputs, or [as usual] a mix of the two -- still there are only 8 points. The male pin headers (marked W) provide for 5v input or output (depending on program configuration); the OUTx terminals provide open-collector (active low) output only.

BTW, I just fixed a copy-and-paste error in the code above. Make sure that the Relays_Off section uses LOW idx (to turn the outputs off)
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

Doesn't the Kit 74 already have a ULN or 8 transitors for sinking the relay coils? If so, you would need to use 5v postitive to each channel to energize each relay, not the OUT's from the Prop-1. In addition, couldn't you just double up or even connect all of the Kit 74 inputs if all 8 relays are to be on or off? Unless I'm looking at this wrong, 6 outputs from the Prop-1 wouldn't be necessary.

livinlowe

From what I can see it only has flyback diodes across the relays
Shawn
Scaring someone with a prop you built -- priceless!

JackMan

Quote from: livinlowe on January 18, 2016, 08:26:24 PM
From what I can see it only has flyback diodes across the relays
This one has a ULN.

JackMan

And here's a PDF I found with a schematic. I have no idea if this is what Clad In Shadows is using.

livinlowe

Quote from: JackMan on January 19, 2016, 10:53:03 AM
Quote from: livinlowe on January 18, 2016, 08:26:24 PM
From what I can see it only has flyback diodes across the relays
This one has a ULN.

Weird. The schematic they provide doesn't match with a ULN. Oh, well, it'd be cool if they had one of these that was serial or USB.
Shawn
Scaring someone with a prop you built -- priceless!

JackMan

January 19, 2016, 03:19:32 PM #10 Last Edit: January 19, 2016, 03:24:04 PM by JackMan
Quote from: livinlowe on January 19, 2016, 11:22:41 AM

Weird. The schematic they provide doesn't match with a ULN.
Yah, but the circuit is basically the same. The ULN is just a more compact method of building the board. The ULN also has the clamp diodes built in.

bsnut

QuoteOh, well, it'd be cool if they had one of these that was serial or USB.
Velleman vellemanusa.com has these types of kits that you can build.
William Stefan
The Basic Stamp Nut