November 22, 2024, 09:05:28 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.


Prop1 - RC4 help

Started by RHoward, October 27, 2007, 09:04:00 PM

Previous topic - Next topic

RHoward

I had planned on learning how to monitor a port off my servo controller so I could trigger different actions based on the servo position.  That will have to wait until next year. 

Could you get me started with a simple (I think) application with a series of toggle switches I have.  I would like to hookup 4 switches to my prop 1 to trigger 4 pneumatic props.  All are looking for 48VDC which I have.
I want to flip switches 1, 2, 3 or 4 and trigger pneumatic 1, 2, 3 and 4 from the RC4

Can you get me started?  I Plan to re-purpose the controller kit I got for the recent CalHaunts Nor Cal meeting.

Thanks

Bob

JonnyMac

Do you have 48 VDC relays for the RC-4? And an appropriate power supply for the valves?

Here's a program that will refresh the relays when you change the state of the switches on P0..P3.  Note that the switch connects between Px.W (I/O pin) and Px.R (+5 vdc).  The ULN2x03 provides a weak pull-down on the pins.  You will, however, need to change the ULN2803 to a ULN2003 for serial comms between the Prop-1 (P7) and RC-4.  See this thread for details: http://www.efx-tek.com/php/smf/index.php?topic=130.0


' =========================================================================
'
'   File...... RC4_Switcher.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2007 EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Map switches on P0..P3 to relays K1..K4 on RC-4


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Switches        = PINS                  ' active-high in on P0..P3


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  swCheck         = B2
SYMBOL  last            = B3


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

Reset:
  SEROUT Sio, Baud, ("!!!!!!RC4", %00, "X")     ' clear on reset
  last = %0000                                  ' all off


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

Main:
  PAUSE 75
  swCheck = PINS & %00001111                    ' check P0..P3
  IF swCheck = last THEN Main                   ' any change?

Update_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", swCheck)
  last = swCheck                                ' save for next cycle
  GOTO Main                                     ' scan again


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


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


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

RHoward

It must have been my frustration but my valves need a 24VDC power supply (not a 48VDC) which I have.  I have a prop1 with the ULN2803 and 1 with the ULN2003.  Can't believe my luck!  My RC 4 has 4 Crydom D2W203F relays. I believe these will work.  If not please let me know.

Thank you for the unbelievably quick response.

Bob

JonnyMac

October 28, 2007, 11:28:13 AM #3 Last Edit: October 28, 2007, 11:35:11 AM by JonnyMac
The Crydom D2W203 relays will not work with DC as they are AC relays (solid state relays differ from mechanical relays in this regard, that is, SSRs for AC don't work properly with DC).  No worries, though, you cans switch them directly with the Prop-1 so long as they are 6 watts or less (at 24 VDC).  To be candid, though, what you're doing doesn't require a controller, just four switches in line with the valves and a power source.

If you want to use your Prop-1 as a connection/power distribution point, here's a simple program to do it.  Again, the switches are between Px.W and Px.R.

' =========================================================================
'
'   File...... EZ_Switcher.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2007 EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Map (active-high) switches on P4..P7 to valves on OUT0..OUT3


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


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

SYMBOL  Trigger4        = PIN7                  ' SETUP = DN
SYMBOL  Trigger3        = PIN6                  ' SETUP = DN
SYMBOL  Trigger2        = PIN5
SYMBOL  Trigger1        = PIN4
SYMBOL  Valve4          = PIN3
SYMBOL  Valve3          = PIN2
SYMBOL  Valve2          = PIN1
SYMBOL  Valve1          = PIN0


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

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


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


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

Reset:
  PINS = %00000000
  DIRS = %00001111


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

Main:
  Valve1 = Trigger1
  Valve2 = Trigger2
  Valve3 = Trigger3
  Valve4 = Trigger4
  PAUSE 100                                     ' minimize fast cycling
  GOTO Main


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


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


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

For fun, here's another approach.  Instead of using toggle switches you could use push-buttons; this program gives you push-on-push-off control of four valves with four push-buttons. 

' =========================================================================
'
'   File...... Push_On_Push_Off.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2007 EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Map (active-high) buttons on P4..P7 to valves on OUT0..OUT3.  This
' program toggles the associated output with each button press.


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


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

SYMBOL  Trigger4        = PIN7                  ' SETUP = DN
SYMBOL  Trigger3        = PIN6                  ' SETUP = DN
SYMBOL  Trigger2        = PIN5
SYMBOL  Trigger1        = PIN4
SYMBOL  Valve4          = 3
SYMBOL  Valve3          = 2
SYMBOL  Valve2          = 1
SYMBOL  Valve1          = 0


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

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


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

SYMBOL  xBtns           = B0                    ' new button presses
SYMBOL   Ctrl1          =  BIT0                 ' control for valve 1
SYMBOL   Ctrl2          =  BIT1
SYMBOL   Ctrl3          =  BIT2
SYMBOL   Ctrl4          =  BIT3

SYMBOL  nBtns           = B2                    ' new scan
SYMBOL  oBtns           = B3                    ' old scan

SYMBOL  idx             = B4


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

Reset:
  PINS = %00000000                              ' clear pins
  DIRS = %00001111                              ' configure P0..P3 outputs


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

Main:
  GOSUB Scan_Buttons

Check1:
  IF Ctrl1 = IsOff THEN Check2                  ' skip if no new press
    TOGGLE Valve1

Check2:
  IF Ctrl2 = IsOff THEN Check3
    TOGGLE Valve2

Check3:
  IF Ctrl3 = IsOff THEN Check4
    TOGGLE Valve3

Check4:
  IF Ctrl4 = IsOff THEN Loop_Pad
    TOGGLE Valve4

Loop_Pad:
  PAUSE 25
  GOTO Main


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

Scan_Buttons:
  nBtns = %1111                                 ' assume all pressed
  FOR idx = 1 TO 5
    nBtns = PINS / 16 & nBtns                   ' scan P4..P7
    PAUSE 5
  NEXT
  xBtns = nBtns ^ oBtns & nBtns                 ' look for 0 --> 1 change
  oBtns = nBtns                                 ' save this scan
  RETURN


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office