November 23, 2024, 05:46:33 PM

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.


Coffin lid open/close with extending/retracting hand

Started by retiredfireguy, October 26, 2010, 03:08:09 PM

Previous topic - Next topic

retiredfireguy

October 26, 2010, 03:08:09 PM Last Edit: October 26, 2010, 03:17:49 PM by retiredfireguy
I am looking for some program help for a animated display for a charity Halloween party this Saturday. Unfortunately I wasn't given much time to do this in. The display is a coffin with lid opening device and a reaching hand. I am using two 120 Vac shaded pole geared motors that move at about 4.8 rpm. I need to move each motor 1 revolution per cycle. I have two normally open micro switches for each motor to detect position. For the lid, one detects full open position and the one for fully closed. The arm ones would detect fully extended and fully retracted. Because of the the nature of the shaded pole motor being driven from 120 Vac, there is a small amount of overtravel after the limit switches are made so they will supply only a momentary closure. I am using 12 Vdc coil relays to switch the motors. Coil current is about 65 mA.

My basic sequence would be:
1. Start ( have either a momentary or hold type switch to use)
2. Start casket lid opening.
3. After some delay start extending hand (about a 2 second delay)
4. Stop lid when lid open switch is made and wait for hand to fully extend.
5. Stop hand extension when hand fully extend switch is made.
6. Wait some random time delay.
7. Start hand retraction.
8. After some delay start lid closing. (about 2 seconds)
9. Stop hand retraction when retraction switch is made.
10. Stop lid closing when lid closed switch is made.
11. Wait some random time delay.
12. Repeat cycle from step 2

I should mention that I have two aux relays wired in parallel to the motor relays to home each motor prior to starting the program.

JonnyMac

This will get you going.  Hopefully, you bought some of our 14" (or 68") 3-pin extender cables as you'll need them to connecting your trigger and N.O. switches to the Prop-1.  If you didn't order from us, pop into a hobby shop that supports RC cars and planes; you can get similar cables there.

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


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  HandUp          = PIN5                  ' N.O. switch = P5.W/P5.R
SYMBOL  HandDown        = PIN4                  ' N.O. switch = P4.W/P4.R

SYMBOL  LidOpen         = PIN3                  ' N.O. switch = P3.W/P3.R
SYMBOL  LidClosed       = PIN2                  ' N.O. switch = P2.W/P2.R

SYMBOL  HandMotor       = PIN1                  ' relay = V+/OUT1
SYMBOL  LidMotor        = PIN0                  ' relay = V+/OUT0


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

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

SYMBOL  Yes             = 1                     ' for active-high inputs
SYMBOL  No              = 0


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

SYMBOL  timer           = B2
SYMBOL  check           = B3

SYMBOL  delay           = W4
SYMBOL  lottery         = W5


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

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

  PAUSE 30000                                   ' re-trigger delay


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

Main:
  timer = 0                                     ' reset timer

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

  LidMotor = IsOn                               ' start opening lid
  PAUSE 2000                                    ' let lid start to open
  HandMotor = IsOn                              ' start raising hand


Check_Lid:
  IF LidOpen = No THEN Check_Hand               ' lid open?
    LidMotor = IsOff                            '  yes, stop motor

Check_Hand:
  IF HandUp = No THEN Check_Motors              ' hand up?
    HandMotor = IsOff                           '  yes, stop motor

Check_Motors:
  PAUSE 50
  check = PINS & %00101000                      ' isolate extended sensors
  IF check <> %00101000 THEN Check_Lid          ' try again if not both
    PINS = %00000000                            ' make sure both are off


Pgm_Hold:
  RANDOM lottery
  delay = lottery // 2001 + 1000                ' 1 to 3 seconds
  PAUSE delay                                   ' hold


Drop_Hand:
  HandMotor = IsOn                              ' retract hand
  PAUSE 50
  IF HandDown = No THEN Drop_Hand
    HandMotor = IsOff


Close_Lid:
  LidMotor = IsOn                               ' close lid
  PAUSE 50
  IF HandDown = No THEN Close_Lid
    LidMotor = IsOff


  GOTO Reset


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


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


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

retiredfireguy

Jon,

I have a question on the program and wiring the Trigger input. Does this require just a N.O momentary closure or a maintained to have the program continuously run?

Retiredfireguy

JonnyMac

No, it takes a clean, 100ms (0.1s input) to run -- you can press-and-release a button to get it going.  That all happens in the Check_Trigger section.
Jon McPhalen
EFX-TEK Hollywood Office

retiredfireguy

Jon,

The program hangs up at ;

Check_Motors:
  PAUSE 50
  check = PINS & %00101000                      ' isolate extended sensors
  IF check <> %00101000 THEN Check_Lid          ' try again if not both
    PINS = %00000000                            ' make sure both are off

I can not keep these switches both closed (maintained) because of the loads I am driving. The switches are made but the motor will coast by them after hitting them. I know you are looking for both motors to be off but this is not working.
I have tried holding the switches closed and then the program moves forward.

Also, I had wanted the retraction and the closing to be coordinated with a the lid starting to close after a delay  of 2 second  of the motor retracting.

My time is running out Help!

bsnut

What seems to be your problem is, that your limit switches are not set right. Try to set your limits, so you can account for the coasting of the motor. Also, need to make sure that you have whatever the limit switches stopping on is longer than you need them or it will over travel the limit switch when the spot where the limit switch is activated on is not long a enough.
QuoteI have tried holding the switches closed and then the program moves forward.
That is what Jon did for you and that is what the program is doing.
William Stefan
The Basic Stamp Nut

JonnyMac

Okay... here's an updated version that doesn't force the limit switches to be closed and does the two-second offset on closing.

WARNING: Use at your own risk.  EFX-TEK is not responsible for any damage done to your prop by using this code.  We provide code as requested and that's where it ends.  If it breaks because you gave us bad info.... it's on you!  ;D

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


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  HandUp          = PIN5                  ' N.O. switch = P5.W/P5.R
SYMBOL  HandDown        = PIN4                  ' N.O. switch = P4.W/P4.R

SYMBOL  LidOpen         = PIN3                  ' N.O. switch = P3.W/P3.R
SYMBOL  LidClosed       = PIN2                  ' N.O. switch = P2.W/P2.R

SYMBOL  HandMotor       = PIN1                  ' relay = V+/OUT1
SYMBOL  LidMotor        = PIN0                  ' relay = V+/OUT0


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

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

SYMBOL  Yes             = 1                     ' for active-high inputs
SYMBOL  No              = 0


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

SYMBOL  timer           = B2
SYMBOL  check           = B3

SYMBOL  delay           = W4
SYMBOL  lottery         = W5


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

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

  PAUSE 30000                                   ' re-trigger delay


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

Main:
  timer = 0                                     ' reset timer

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

  LidMotor = IsOn                               ' start opening lid
  PAUSE 2000                                    ' let lid start to open
  HandMotor = IsOn                              ' start raising hand

  check = 0                                     ' reset ched

Check_Lid_Open:
  IF LidOpen = No THEN Check_Hand_Up            ' lid open?
    LidMotor = IsOff                            '  yes, stop motor
    check = check | %00000001                   '  mark motor

Check_Hand_Up:
  IF HandUp = No THEN Check_Motors              ' hand up?
    HandMotor = IsOff                           '  yes, stop motor
    check = check | %00000010                   '  mark hand

Check_Motors:
  PAUSE 25
  IF check <> %00000011 THEN Check_Lid_Open     ' check for both marked


Pgm_Hold:
  RANDOM lottery
  delay = lottery // 2001 + 1000                ' 1 to 3 seconds
  PAUSE delay                                   ' hold


Goodnight:
  HandMotor = IsOn                              ' retract hand
  PAUSE 2000                                    ' hold 2s
  LidMotor = IsOn                               ' close lid

Check_Hand_Down:
  PAUSE 25
  IF HandDown = No THEN Check_Hand_Down         ' hand down?
    HandMotor = IsOff                           '  yes, kill motor

Check_Lid_Closed:
  PAUSE 25
  IF LidClosed = No THEN Check_Lid_Closed       ' lid closed
    LidMotor = IsOff                            '  yes, kill motor


  GOTO Reset


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


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


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