May 11, 2024, 02:01:45 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.


RC4 Board - Relay 1 (K1) permanently on

Started by mnewmanholden, October 28, 2010, 10:11:15 PM

Previous topic - Next topic

mnewmanholden

Hi All,

I have RC 4 connected to a Prop1 (ULN 2003). Running 2 wiper motors and a light via RC4. Also have a CAR/P 325 connecetd to Out0 and V+ and also taking 12v power from the Prop 1 on GND and V+. The CAR/P has 2 tracks recorded and is set to MM mode.

I ran the test code from publication "RC-4 Relay Board (#31204)" and everything seemed to be good.

My first problem is that when the Prop 1 and RC 4 are powered the motor on relay K1 is permanently on.

When I run my code (below) the audio is triggered (1st track) and then nothing else happens. I assume I have a communication/configuration issue with the RC 4, but the 2nd track on the audio board is not triggered. (I have a separate audio test code that does trigger the audio.

Ay help on this would be appreciated...thanks...
Mark

Code is:

'======================================================================
'   File..... RC4_Head+Bed.bs1
'   Author... Mark NH
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' -----[ Program Descripton ]------------------------------------------
' Exorcist - Linda Blair
' On push of button, bed rocks, groans play, light shines, head spins,
' vomit AUDIO, voimit comes out of mouth.

' BedRock Motor on Relay 1  (DC)
' Head Motor on Relay 2   (DC)
' Pump on Relay  3 (AC)
' Light on Relay 4 (AC)
' CAR/P 325 on OUT 0 (12v) trigger
'======================================================================

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

  SYMBOL Audio = PIN0         ' PIN0 connected to AUDIO board  - OUT0
  SYMBOL RC4 = PIN7           ' PIN7 connected to RC4 board  - PIN HEADER
  SYMBOL Trigger = PIN6       ' push button on PIN6

  ' RC4 Settings
  SYMBOL RC4Baud     = OT2400     ' set the baud rate at 2400 for the Prop-1 to RC-4 serial connection
  SYMBOL RC4Addr     = %11        ' address #11 (both A0 and A1 jumpers are on both pins)

  '       76543210            ' bit positions
  DIRS = %10111111            ' make P7-P6 inputs, P7 &
  P5-P0 outputs
  PINS = %00000000            ' all outputs off
  SEROUT RC4, OT2400, ("!RC4", RC4Addr, "X") ' reset all relays to OFF



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

Main:

  IF Trigger = 1 THEN Run
  GOTO Main

Run:


' ********BED ROCKING********


  GOSUB Play_Sound         ' Make groaning sound play
  PAUSE 2000               ' wait 2 seconds - need to test
  SEROUT RC4, RC4Baud, ("!RC4", RC4Addr, "R", 1, 1)    ' Power to bed rock motor
  PAUSE 4000               ' wait 4 seconds - need to test
  SEROUT RC4, RC4Baud, ("!RC4", RC4Addr, "R", 1, 0)    ' Stop bed rock motor

  PAUSE 6000               ' wait 6 seconds - need to test

  SEROUT RC4, RC4Baud, ("!RC4", RC4Addr, "R", 1, 1)    ' Power to bed rock motor
  PAUSE 7000               ' wait 7 seconds - need to test
  SEROUT RC4, RC4Baud, ("!RC4", RC4Addr, "R", 1, 0)    ' Stop bed rock motor

  PAUSE 4000               ' wait 4 seconds - need to test

' ********HEAD SPINNING********

  SEROUT RC4, RC4Baud, ("!RC4", RC4Addr, "R", 4, 1)

  SEROUT RC4, RC4Baud, ("!RC4", RC4Addr, "R", 2, 1)    ' power to head motor
  PAUSE 4000               ' wait 4 seconds - need to test
  SEROUT RC4, RC4Baud, ("!RC4", RC4Addr, "R", 2, 0)    ' Stop head motor

  PAUSE 2000               ' wait 2 seconds

' ********VOMIT********

  SEROUT RC4, RC4Baud, ("!RC4", RC4Addr, "R", 3, 1)               ' open vomit valve
  GOSUB Play_Sound          ' Make vomiting sound play
  PAUSE 1000               ' wait 1 seconds - need to test
  SEROUT RC4, RC4Baud, ("!RC4", RC4Addr, "R", 3, 0)                ' close vomit valve

' ********RESET********

  PAUSE 5000               ' wait 5 seconds - need to test
  SEROUT RC4, RC4Baud, ("!RC4", RC4Addr, "R", 4, 0)

  GOTO Main   ' repeat forever

END

' -----[ Subroutines ]-----------------------------------------------------
Play_Sound:
HIGH Audio
PAUSE 100
LOW Audio
RETURN

JonnyMac

If you're using the Crydom relays that we sell for the RC-4 to control DC devices, that's a problem.  Those relays won't turn off (once on) with DC; it has to do with the triac circuitry used.  We're presently out of stock on our Opto-22 DC relay.  In a pinch you can get a couple standard relays from RadioShack and use two outputs from the Prop-1 to control your DC devices.

You have some symbol definition problems in your program that seem to work, but are not doing what you want.  Here's a rewrite that's easier to follow, and actually uses about a third less program space.

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


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


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


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

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

SYMBOL  Audio           = PIN0


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   BedMotor       =  BIT0                 ' K1
SYMBOL   HeadMotor      =  BIT1                 ' K2
SYMBOL   Pump           =  BIT2                 ' K3
SYMBOL   Light          =  BIT3                 ' K4

SYMBOL  timer           = B2


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

Power_Up:
 PAUSE 100                                     ' let RC-4 power up

Reset:
 PINS = %00000000                              ' clear all outputs
 DIRS = %00111111                              ' make P0-P5 outputs

 relays = IsOff
 GOSUB Set_RC4


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

Main:
 timer = 0                                     ' reset timer

Check_Trigger:
 PAUSE 5                                       ' loop pad
 timer = timer + 5 * Trigger                   ' update timer
 IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

 GOSUB Play_Sound
 PAUSE 2000


 ' bed rocking

 BedMotor = IsOn
 GOSUB Set_RC4
 PAUSE 4000
 BedMotor = IsOff
 GOSUB Set_RC4
 PAUSE 6000

 BedMotor = IsOn
 GOSUB Set_RC4
 PAUSE 7000
 BedMotor = IsOff
 GOSUB Set_RC4
 PAUSE 4000


 ' head spinning

 Light = IsOn
 HeadMotor = IsOn
 GOSUB Set_RC4
 PAUSE 4000
 HeadMotor = IsOff
 GOSUB Set_RC4
 PAUSE 2000


 ' vomit

 Pump = IsOn
 GOSUB Set_RC4

 GOSUB Play_Sound
 PAUSE 1000

 Pump = IsOff
 GOSUB Set_RC4
 PAUSE 5000


 GOTO Reset                                    ' everything off


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

Play_Sound:
 Audio = IsOn
 PAUSE 100
 Audio = IsOff
 RETURN

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

Set_RC4:
 SEROUT Sio, Baud, ("!RC4", %11, "S", relays)
 RETURN

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


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

BigRez

One knows They're getting better at coding this stuff when they also create a rewrite which is nearly identical to the master.    ;)

mnewmanholden

I am using a Crydom CMX60D5 DC relay for each of the 2 motors. I am going to run through some test routines again today.....

Please confirm ULN 2003 placement...notch is up towards P7?

Thanks for the rewrite.  Seems much nicer code...i'll give it a try!!

JonnyMac

Jon McPhalen
EFX-TEK Hollywood Office