November 05, 2024, 12:50:09 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.


Control servo speed with Prop Pot

Started by tstamand, May 11, 2008, 11:20:44 AM

Previous topic - Next topic

tstamand

Is it possible to manually control the speed of a servo with a Prop Pot connected to a Prop-1?

JonnyMac

Servos move at a given speed, so the only control you can do is hold the servo at intermediate positions when moving from point A to point B.  You have to be a tad careful, though, as the timing resolution on the BASIC Stamp 1 is somewhat coarse (one millisecond) and this can cause stepping in the movement.

Perhaps you're actually looking to control servo position with a potentiometer -- this is pretty easy and I've included a program below to show you how to do that.

' =========================================================================
'
'   File...... Servo_Pot.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              see: http://creativecommons.org/licenses/by/3.0/us/
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  PosCtrl         = 7                     ' SETUP = out; no ULN
SYMBOL  Servo           = 0                     ' servo control pin


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


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

SYMBOL  position        = B2


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00000001                              ' make servo pin an output


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

Main:
  POT PosCtrl, 104, position                    ' raw reading, 5 to 255

  ' convert raw pot value to 100 to 200 for servo (90 degrees)
  ' a) divide target span (100) by raw span (250)
  '    100 / 255 = 0.392
  '    -- convert for ** by multiplying by 65536
  ' b) apply [fractional] multiplier to raw span for scaling
  ' c) add minimum position value (100)

  position = position ** 25700                  ' convert to 0 to 100
  position = position + 100                     ' minimum CW value

  PULSOUT Servo, position                       ' update servo
  PAUSE 15

  GOTO Main


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


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


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

Raisin-Toe

When using the Prop-1 Trainer, the P6 jumper is in DN position. But what about the P7 jumper?

JonnyMac

If using the POT circuit on the Prop-1 Trainer the SETUP jumper should be out, and the ULN2803 should have been changed to a ULN2003.  If using the P6 header on the trainer for your servo be sure you don't press the button on the Trainer as this will short the control signal to ground.
Jon McPhalen
EFX-TEK Hollywood Office