April 20, 2024, 03:49:41 AM

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 for my prop1

Started by Lynn, January 21, 2010, 01:56:58 PM

Previous topic - Next topic

Lynn

I am going to have 2 servos that will be triggered with a pressure mat.  One will be a continuous rotation servo, the other a standard servo.
The standard servo will actually be glued to the side of the continuous servo.  When trggered, the standard servo will turn so that the servo horn faces down.   This will allow a string that is attached to the continuous servo to drop.  This will drop a severed head prop.  After about 3-4 seconds the standard servo will go back to its starting position, and the continuous servo will turn,  rolling up the string.
I pretty much know nothing about programming this.   I know that the values on the continous servo depends on the length of the string and as long as I have a program written and know what value needs adjusted for the string length....  I should be good.    Any help I can get would be really appreciated!!!!!
Oh,....   probably a pause in this of about 20 seconds or so would be good so that the prop isnt triggered again too soon.

JonnyMac

Lynn,

We're at a disadvanatge here because we don't know -- and you didn't tell us -- what values to use for tilting the servo and the speed/direction for the C/R servo to "haul in the head."

Give this a try without the head to see if the servos move in the correct direction.  You may need to swap the up and down values for the tilt servo, and the speed setting for the reel servo.  The setting of "delay" controls how long the program wait after the drop, and then how long it takes to reel in the head.   Set the reel-in speed first, then adjust the timing.

Have fun!

' =========================================================================
'
'   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  Rotate          = 1                     ' rotation servo
SYMBOL  Tilt            = 0                     ' tilt servo


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  timer           = B2
SYMBOL  pos             = B3                    ' tilt servo position
SYMBOL  speed           = B4                    ' rotating servo speed


SYMBOL  delay           = W5


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

Reset:
 PINS = %00000000                              ' clear all
 DIRS = %00000011                              ' set output pins

 pos = 100                                     ' up position
 speed = 150                                   ' stopped


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

Main:
 timer = 0                                     ' reset timer

Check_Trigger:
 PULSOUT Tilt, pos                             ' update servos
 PULSOUT Rotate, speed
 PAUSE 17                                      ' loop pad
 timer = timer + 20 * Trigger                  ' update timer
 IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Drop:
 pos = 200                                     ' tilt for drop
 delay = 4000                                  ' set for 4 seconds
 GOSUB Servo_Pause

Roll_Up:
 pos = 100                                     ' back t up position
 speed = 125                                   ' adjust for roll-up speed
 delay = 4000                                  ' adjust for roll-up time
 GOSUB Servo_Pause

 GOTO Reset


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

' Use instead of PAUSE
' -- put pause value (ms) in "delay" before calling

Servo_Pause:
 PULSOUT Tilt, pos                             ' update servos
 PULSOUT Rotate, speed
 IF delay < 20 THEN SP_Exit
   PAUSE 17
   delay = delay - 20
   GOTO Servo_Pause

SP_Exit:
 PAUSE delay
 RETURN

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


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


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

Lynn

This will be perfect!    I can figure out the speed/time thing and the direction.   Since I dont have it built yet, I can make most of it work!!!

Lynn

Jonny....   This program is working pretty well but for some reason the continuous rotation servo doesnt stop rotating.  When it is 'realing in' the head is goes faster but then it goes slower and doesnt stop.
When powered,  the contin. rotation servo starts right up.  When triggered it contiues to rotate as the tilt servo tilts then tilts back after 4 seconds, then the rotation servo speeds up to real in the head then slows down but doesnt stop.

JackMan

Just a shot in the dark here but it sounds as though your "continuous rotation servo" is acting more like a simple motor than a servo. My guess is that it doesn't need a position signal from the Prop-1 but just an On/Off/Speed execution.

JonnyMac

C/R servos are in fact standard servos that have had the mechanical stops removed and the position pot replaced with two resistors.  This means they still need to be treated like servos.

@Lynn: If you have a Parallax C/R servo there should be a small hole in the the side that will let you adjust the stop position.  You can start the program (remove the trigger so it doesn't activate) and adjust the pot that it stops when 150 is the command value.  If you can't adjust it then you'll need to change the 150 value to find the stop point. 
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

QuoteC/R servos are in fact standard servos that have had the mechanical stops removed and the position pot replaced with two resistors.  This means they still need to be treated like servos.

Ahhh.......This old R/C nut learned something new about servos!  ;)

Lynn

Well, I have a Hitec servo.... I'll see if there is an adjust on it....  if not I'll play with the value!
I'm guessing that a larger value will slow it down...   
at 150 it goes slower than when its at the roll up speed of 125.


I'll give that a shot.

Thanks a lot!

JonnyMac

It it's a C/R servo that you made yourself, probably not.  Parallax sells a servo for robotics that includes an adjustment.  In your case, you just have to experiment with the value until you find the stop point -- which should be close to 150. 

With a regular servo you send it values of 100 to 200 (with Hitec you can go 60 to 240) to move it from one side to the other.  With a C/R servo the direction is based on the change from 150 -- lower than 150 goes in one direction, higher that 150 and the servo turns the other way.  The difference between your setting at the stop point (150) determines the speed.
Jon McPhalen
EFX-TEK Hollywood Office

Lynn

OK is changed the speed on the CR servo to 155 and that stopped it !!!   First try !  How lucky was that ?

thanks so much for the help.
Next project with be for a pneumatic pop up !

Lynn

Have one issue with this routine.....    I need a delay between triggers.    It will trigger right away right after the routine is finished.   I would like a pause or delay before it can be triggered again.   Maybe about a minute or so.  Thanks!

Lynn

Also,  I think a light would be great too.....

Trigger the light just a 1/2 second before the head drops.  Then goes out when it rolls up.

Thanks,   Hope I,m not asking too much!   I gotta learn this myself!    I am understanding most of it though.

JonnyMac

Light?  What light?  Since it's not in the original program I added it on P2/OUT2.

The re-trigger delay is built into the reset section as this ensures the light is out and the servos are in the correct position before the trigger is scanned.  There is a 500ms delay between the light going on and the head drop.

Yes, it would be a good idea to learn yourself.  I walk 5 miles every day (yes, in Los Angeles, and this can be dangerous) -- yesterday I was inches from being run down by a driver ignoring the crossing light.

' =========================================================================
'
'   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  Light           = PIN2
SYMBOL  Rotate          = 1                     ' rotation servo
SYMBOL  Tilt            = 0                     ' tilt servo


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  timer           = B2
SYMBOL  pos             = B3                    ' tilt servo position
SYMBOL  speed           = B4                    ' rotating servo speed


SYMBOL  delay           = W5


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000111                              ' set output pins

  pos = 100                                     ' up position
  speed = 150                                   ' stopped

  delay = 60000
  GOSUB Servo_Delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PULSOUT Tilt, pos                             ' update servos
  PULSOUT Rotate, speed
  PAUSE 17                                      ' loop pad
  timer = timer + 20 * Trigger                  ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Light_On:
  Light = IsOn
  delay = 500
  GOSUB Servo_Pause

Drop:
  pos = 200                                     ' tilt for drop
  delay = 4000                                  ' set for 4 seconds
  GOSUB Servo_Pause

Roll_Up:
  Light = IsOff
  pos = 100                                     ' back t up position
  speed = 125                                   ' adjust for roll-up speed
  delay = 4000                                  ' adjust for roll-up time
  GOSUB Servo_Pause

  GOTO Reset


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

' Use instead of PAUSE
' -- put pause value (ms) in "delay" before calling

Servo_Pause:
  PULSOUT Tilt, pos                             ' update servos
  PULSOUT Rotate, speed
  IF delay < 20 THEN SP_Exit
    PAUSE 17
    delay = delay - 20
    GOTO Servo_Pause

SP_Exit:
  PAUSE delay
  RETURN

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


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


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

Lynn

Thanks Jon!
Sorry about the light.... I hadnt thought about that when I first asked for help. :-[

Lynn

Hoping this is the last I need ........

Have an LED light attached to the pinouts on the prop1.   Pin2, red and white out pins.   Is this correct?
The light stays on constantly.

Thanks