November 23, 2024, 08:29:39 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.


Program to operate double acting cylinder.

Started by pbronson, March 06, 2008, 09:51:02 AM

Previous topic - Next topic

pbronson

Jon,
This is what I would like to accomplish. Any help would be appreciated.

Step 1 - Activate 12 VDC door solenoid to release door handle latch. On for about 1 second should do it. A simple 12VDC short stroke pull actuator will be used. A push button switch will begin sequence.

Step 2 - Energize a 12VDC 4 way solenoid to entend pneumatic cylinder, hold for 15 seconds, then deactivate first solenoid and activate second solenoid to retract cylinder. Again, hold for 15 seconds them deactivate. This set up will use a double acting cylinder ie.. power open - power close.

A second switch will be set up on the outside of the building to repeat the sequence to re-enter the site.

This is for Handicap access so I may, in the future, change the trigger to RFID or PIR.

Any suggestions would be welcome.

Thanks
Pete

pbronson

I will be using a PROP -1 if it will handle it. Wattage of the valve is 5.4 W and only one solenoid will be active at a time.

JonnyMac

Give this a look.  You can add a second trigger input in parallel across the first; this will let the door be open from either side.

' =========================================================================
'
'   File...... Door_Access.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   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
SYMBOL  Retract         = PIN2
SYMBOL  Extend          = PIN1
SYMBOL  Door            = PIN0


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

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


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

SYMBOL  timer           = B2


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

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

  timer = 0                                     ' reset timer


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

Main:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 200 THEN Main                      ' wait for 0.2 sec input

  Door = IsOn                                   ' activate actuator
  PAUSE 1000
  Door = IsOff

  Extend = IsOn
  Retract = IsOff
  PAUSE 15000

  Extend = IsOff
  Retract = IsOn
  PAUSE 15000

  GOTO Reset                                    ' reset everything


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


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


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

pbronson

Thanks Jon, I will let you know how it works when I finish my prototype build.

Pete

pbronson

Jon, if I wanted to use the Pot to vary the duration that the door would be help open, how would it fit into the program?

Pete

JonnyMac

You have to tell me the duration span (min and max points) you want -- I'm a good programmer, not such a good mind reader...  ;D  All kidding aside, details count, and when you're asking someone else to assist with code it is always better to give more details than you think necessary.
Jon McPhalen
EFX-TEK Hollywood Office

pbronson

I'm just guessing at this point so lets go with min. = 10 sec. and a max. of 60 sec.

Thanks as I am learning much from your help.

Pete

JonnyMac

March 06, 2008, 11:54:53 AM #7 Last Edit: March 07, 2008, 07:47:13 AM by JonnyMac
You may want to read up on the POT instruction in the help file so you can learn how to determine the correct scale number for the command -- I'm presently using 103 which works on my Prop-1 Trainer.  Also, you'll need to change the ULN2803 for a ULN2003 so that P7 is clear.

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


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


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


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

SYMBOL  Delay           = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Retract         = PIN2
SYMBOL  Extend          = PIN1
SYMBOL  Door            = PIN0


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

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


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

SYMBOL  timer           = W5


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

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

  timer = 0                                     ' reset timer


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

Main:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 200 THEN Main                      ' wait for 0.2 sec input

Read_Delay:
  POT Delay, 103, timer                         ' read pot, 5..255
  timer = timer / 5 + 9 * 1000                  ' scale to 10000 to 60000

Open_Sesame:
  Door = IsOn                                   ' activate actuator
  PAUSE 1000
  Door = IsOff

  Extend = IsOn
  Retract = IsOff
  PAUSE timer

  Extend = IsOff
  Retract = IsOn
  PAUSE timer

  GOTO Reset                                    ' reset everything


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


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


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

pbronson

Thanks,

I have been reading up on the Pot command and am practicing with my trainer.

It helps to see how you set up the program.

Pete

pbronson

Jon,

I am a little confused about the Read Delay portion of the program as it is different than the "Using the Prop-1 Pot Function" example that you listed in the Forum.

Using the Prop-1 Pot Function example:

Pot range value 1000 to 10000
Raw output from Pot 5 to 255

POT 7, 106, delay
  delay = delay - 5
  delay = delay * 36 + 1000



My Program:

Read_Delay:

  POT Delay, 105, timer                         ' read pot, 0..255
  timer = timer / 5 + 10                        ' scale to ~10 to ~60



Could you describe what is happening? I don't understand the timer = timer / 5 + 10.

Following your example I came up with the following:

Scale Factor 108 to 255
Pot Value (raw output from Pot?) 12 to 255

delay = delay - 12                         'zero adjust Pot range
delay = delay * 210 + 10000        'value span 238 (255-12) divided into output span of 50000 = approx. 210 added to minium output value of 10000

What am I doing wrong?

Thanks,
Pete



JonnyMac

Forgive me, I was ill yesterday and just blasted out the program.  The results are correct, 10 to 60, but that won't work for PAUSE.  The fix is easy: change timer to a Word variable (use W5).  Then add '* 1000' to the final equation.  This will bump the 10 to 60 to 10000 to 60000 for PAUSE.  I have fixed the the listing above, and the Scale value from my Prop-1/P1-T POT setup.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

March 25, 2008, 10:22:52 PM #11 Last Edit: March 25, 2008, 10:59:57 PM by JonnyMac
Per our conversation earlier today I've created a state-driven version of the program that will use a servo for the latch instead of the the solenoid that was giving you problems.  Remember, servos must be updated every 20 milliseconds so this program is setup such that the servo gets updated every 20 ms (approximately) and that timing is used for all other processes.  The only program state not timed is the Get_Delay state that reads to pot for the door open timing.  The POT instruction takes 10+ milliseconds but this extra timing won't bother the servo, especially since it is for a single cycle and the servo is in the neutral position.

State-driven programs can be a challenge at first; read up on the BRANCH instruction (a fancier version of GOTO) and things should make sense.

You may be wondering how I determined the PAUSE 15 in the Main section -- with a 'scope.  I worked to make all state sections have close-to-identical code so that they'd consume the same amount of time.  Then I adjusted the PAUSE value to and checked the servo updating; while waiting for a trigger it's dead-on 20 ms; while opening or closing the door it's 20.4 ms -- I think that's probably close enough for this kind of work.

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


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


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


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

SYMBOL  DelaySet        = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Retract         = PIN2
SYMBOL  Extend          = PIN1
SYMBOL  Servo           = 0


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

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

SYMBOL  ExtendOn        = %00000010             ' extender active
SYMBOL  RetractOn       = %00000100             ' retracter active

SYMBOL  ClosureTime     = 10000                 ' door closure time


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

SYMBOL  state           = B2                    ' program state
SYMBOL  pos             = B3                    ' door latch servo position

SYMBOL  delay           = W4                    ' door open delay
SYMBOL  timer           = W5                    ' timer for states


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

Reset:
  PINS = RetractOn                              ' clear all except retract
  DIRS = %00111111                              ' make P0-P5 outputs

  state = 0                                     ' look for trigger
  pos = 150                                     ' center servo
  timer = 0                                     ' reset timer


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

Main:
  PULSOUT Servo, pos                            ' refresh servo
  PAUSE 15                                      ' trimmed for 20 ms loop

  BRANCH state, (Get_Trigger, Get_Delay, Open_Latch, Extend_It, Retract_It)
  GOTO Reset

Get_Trigger:
  pos = 150                                     ' at center
  PINS = RetractOn                              ' door is closed
  timer = timer + 20 * Trigger                  ' update timer
  IF timer < 200 THEN Main                      ' wait for 0.2 sec input
    state = 1
    timer = 0
    GOTO Main

Get_Delay:
  POT DelaySet, 109, delay                      ' read pot, 5..255
  delay = delay / 5 + 9 * 1000                  ' scale to 10000 to 60000
  state = 2
  timer = 0
  GOTO Main

Open_Latch:
  pos = 200                                     ' relase latch
  PINS = RetractOn
  timer = timer + 20                            ' update timer
  IF timer < 1000 THEN Main                     ' 1 second elapsed?
    state = 3                                   '  yes, next state
    timer = 0                                   '  reset the timer
    GOTO Main

Extend_It:
  pos = 200
  PINS = ExtendOn                               ' open door
  timer = timer + 20
  IF timer < delay THEN Main
    state = 4
    timer = 0
    GOTO Main

Retract_It:
  pos = 150                                     ' relase latch
  PINS = RetractOn                              ' close door
  timer = timer + 20
  IF timer < ClosureTime THEN Main

  GOTO Reset                                    ' reset everything


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


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


' -----[ User Data ]-------------------------------------------------------

Jon McPhalen
EFX-TEK Hollywood Office

pbronson

Jon, Thanks

Another quick question. Can a Crydom SSR be used for no voltage switching (as in making continuity in a unpowered circuit) and /or 12 volt switching? The specs mention a 24V min operating range.

Pete

JonnyMac

Pete,

Please re-post your question in a separate thread -- in order to keep the threads clean and easily searched, we really don't want to mix topics in a single thread.  Thanks for understanding and helping us keep our forums useful for newcomers.
Jon McPhalen
EFX-TEK Hollywood Office

pbronson

Jon,
I am considerating incorporating an RF key fob (433 mHz) and a Parallax RF Receiver into my project. The fob would be used as an additional form of trigger along with the mat switch. How would I include the RF into the programming that you have already provided? I am new to the RF environment and, so far, any literature explaining it has been well over my head. I checked witht Parallax about the usage of their receiver with a fob and was told that as long as I had a 433 mHz fob, it should work. DigiKey had a 433 fob that I have on order.

Thanks, Pete

P.S. I found a linear solenoid strong enough to open the latch so I am not using the servo program.