Can a STAMP do this

Hi everyone. I've been lurking for a while and decided to finally take the plunge. I'm wanting to apply motion to a sphere and make it move very similar to an owl's head. So 3 motions involved. Rotation, say 180º max, Tilt backwards and forwards say 45º and Tilt sideways to left and right again 45º max. It would need to be both a sequential movement and a combined movement and totally random interspersed with various periods of inactivity, so think owl.
What I have from my junk drawer is a Board of Education Rev B, 2 Basic Stamps BS2e Rev D, some servos 0.1sec/60degree 1.4 kg/cm torque. a bunch of various resistors and capacitors.
What I DON'T have is any programming skills or knowledge. I've been playing around trying to program the stamps with what I think are some possibilities but getting nowhere fast. Maybe I'm approaching this all wrong and need something a bit more sophisticated than the Stamp.
So any help would be really appreciated and maybe save me a lot of time going in the wrong direction.
Thanks

Comments

  • 17 Comments sorted by Date Added Votes
  • You probably have "continuous motion" servos that are typically used to spin a wheel. These will not do what you want. You want "standard" servos which use internal feedback to be able to go to a specific position in a (typically) 270 degree circle.

    A Stamp can do only one thing at a time. In this case, it has to output a 0.5 to 2.5ms control pulse to each of the three servos in turn in a 20ms cycle. During the left over time (12.5ms) in each cycle, your program has to figure out the next positions for the subsequent cycle ... not hard to do. Typically your program keeps a "current position" for each servo (a number from 250 to 1250) and an increment / decrement value for the position. Each cycle the current position is used in a PULSOUT statement to generate the control pulse, then the increment / decrement value is added to the current position limited by the bounds you place on servo position (use MIN and MAX operators). After that, your program would generate a random number and use that to figure out what to do next.
  • Mike, thanks for the quick reply.
    As far as I can tell all the servos are "standard" servos as the max amount of movement I have managed to get is about 100º.
    Here's what I've been playing with.
    '{$STAMP BS2e}
    '{$PBASIC 2.5}

    counter VAR WORD

    DO
    DEBUG "Pulse width increment by 8", CR

    FOR counter = 500 TO 1000 STEP 6
    PULSOUT 15, counter
    PAUSE 10
    DEBUG DEC5 counter, CR, CRSRUP
    NEXT

    DEBUG CR, " Pulse width decrement by 4", CR

    FOR counter = 1000 TO 500 STEP 4
    PULSOUT 15, counter
    DEBUG DEC5 counter, CR, CRSRUP
    NEXT

    DEBUG CR, "Repeat", CR

    LOOP

    Another
    'What's a Microcontroller - ServoTestbs2
    'Test the servo at three different position signals
    '{$STAMP BS2e}
    '{$PBASIC 2.5}
    counter VAR WORD

    DO
    DEBUG "Center 12 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 15, 500
    PAUSE 20
    NEXT
    DEBUG "counter 10 o'clock", CR

    FOR counter = 1 TO 500
    PULSOUT 15, 500
    PAUSE 20
    NEXT
    DEBUG "Clockwise 3 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 15, 500
    PAUSE 20
    NEXT
    DEBUG "Center 12 o'clock", CR
    FOR counter = 1 TO 150
    PULSOUT 15, 750
    PAUSE 20
    NEXT
    DEBUG "All Done."



    LOOP
    END
    All from the "What's a controller? book from Parallax
    I cannot find any way to stop the rotation. It just performs like a windshield wiper.
    Altering PULSOUT values just seems to alter speed not the distance.
    Thanks again
  • PublisonPublison Posts: 9,942
    edited December 2017 Vote Up0Vote Down
    Welcome to the forums!


    Here is some code I used to test a pan and tilt mechanism for an Owl head.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    
    
    
    ' random movements for tilt and pan movements
    ' Change the STEP command number higher to speed the scan up
    ' By: GWJax
    ' variables
     Tilt PIN 12 ' set tilt to pin 1
     Pan  PIN 13 ' set pan to pin 0
     tiltseed        VAR    Word ' set var seed for tilt
     panseed         VAR    Word ' set var seed for pan
     TPseed          VAR    Word ' set to check for tilt or pan
     tpselect        VAR    tpseed.BIT0 ' Bit0 of the random number
     tiltdelay       VAR    Word 'tiltdelay
     pandelay        VAR    Word 'pandelay
     i               VAR    Word 'counter
     tilttime        VAR    Byte 'tilttime
     pantime         VAR    Byte 'pantime
     LastDelayTilt   VAR    Word ' used to ramp down speed for tilt
     LastDelayPan    VAR    Word 'used to ramp down speed for pan
    
     ' initialization/maxline
    LOW tilt
    LOW pan
    LastDelayTilt = 750 'set for center of tilt
    LastDelayPan = 750 'set for center of pan
    tiltdelay = 400
    pandelay = 1000
    TiltSeed = 400
    PanSeed = 1000
    TPseed = 1
    TiltTime = 10
    PanTime = 30
    
    FOR i = 0 TO TiltTime 'center tilt/pan unit
    PULSOUT tilt, LastDelayTilt
    PAUSE 18
    NEXT
    FOR i = 0 TO PanTime
    PULSOUT pan, LastDelayPan
    PAUSE 18
    NEXT
    main:
    
    
    RANDOM tpseed
    IF tpselect = 0 THEN GOSUB panit 'for tilt or pan direction
    
    RANDOM TiltSeed ' give a random number
    tiltdelay = tiltseed
    DO WHILE (tiltdelay > 750 OR tiltdelay < 550 ) 'check to see if tilt is within specs
    RANDOM TiltSeed ' mixup numbers
    tiltdelay = tiltseed
    LOOP 'continue till values are right for movement
    GOSUB tiltit
    
    GOTO main ' start all over
    
    tiltIt:
    FOR i = LastDelayTilt TO TiltDelay STEP 10000 'Change Step Number Higher to go faster
    PULSOUT tilt, i 'send out pulse to servo
    PAUSE 30
    NEXT
    LastDelayTilt = TiltDelay
    RETURN
    
    PanIt:
    RANDOM panseed ' mix random number with seed value
    pandelay=panseed
    DO WHILE (pandelay > 750 OR pandelay < 500 ) ' wait till within movement specs
    RANDOM panseed ' mix numbers up again
    pandelay=panseed
    LOOP ' loop until numbers are within correct movement range
    
    FOR i = Lastdelaypan TO pandelay STEP 10000 'Change Step Number Higher to go faster
    PULSOUT pan, i
    PAUSE 30
    NEXT
    LastDelayPan = PanDelay
    RETURN
    

    I believe I was using the Servocity Pan and Tilt system at the time:

    https://www.servocity.com/spt100

    Infernal Machine
  • Mike GreenMike Green Posts: 22,601
    edited December 2017 Vote Up0Vote Down
    If changes in the PULSOUT values alters speed, you have the "continuous motion" servos. The pulse width controls the speed and direction of the motor. With standard servos, the pulse width controls the servo position.

    Do remember that some Stamp Basic statements (including PULSOUT) have timing values that vary depending on the Stamp model. Look at the chapter in the Stamp Reference Manual on the PULSOUT statement for details.
  • Do you have part numbers on the servos? Pictures?
    Infernal Machine
  • How about using an Activity Board or FLiP module with BlocklyProp?

    He mentioned that he's not a programmer and that he needs to blend servo movements. The "new processor" block in Blockly would make this really easy to program.

    Ken Gracey
  • I'm thinking you need to design (at least preliminarily) the mechanics first since that will determine what kind(s) of servos you will need.

    A turntable of some kind for rotation could be on the bottom with a continuous servo geared down or pulley arrangement.
    On top of that you have the tilt (nod) servo which may or may not need to be geared. If not, the standard servo would do. So far you have a standard "elevation over azimuth" telescope mount.
    Finally you have the tilt sideways which likely could be a standard servo with the owl mounted directly on the shaft.

    A BS-2e can easily handle three Parallax servos with 75% of its time available to decide what to do next.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Publison wrote: »
    Welcome to the forums!


    Here is some code I used to test a pan and tilt mechanism for an Owl head.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    
    
    
    ' random movements for tilt and pan movements
    ' Change the STEP command number higher to speed the scan up
    ' By: GWJax
    ' variables
     Tilt PIN 12 ' set tilt to pin 1
     Pan  PIN 13 ' set pan to pin 0
     tiltseed        VAR    Word ' set var seed for tilt
     panseed         VAR    Word ' set var seed for pan
     TPseed          VAR    Word ' set to check for tilt or pan
     tpselect        VAR    tpseed.BIT0 ' Bit0 of the random number
     tiltdelay       VAR    Word 'tiltdelay
     pandelay        VAR    Word 'pandelay
     i               VAR    Word 'counter
     tilttime        VAR    Byte 'tilttime
     pantime         VAR    Byte 'pantime
     LastDelayTilt   VAR    Word ' used to ramp down speed for tilt
     LastDelayPan    VAR    Word 'used to ramp down speed for pan
    
     ' initialization/maxline
    LOW tilt
    LOW pan
    LastDelayTilt = 750 'set for center of tilt
    LastDelayPan = 750 'set for center of pan
    tiltdelay = 400
    pandelay = 1000
    TiltSeed = 400
    PanSeed = 1000
    TPseed = 1
    TiltTime = 10
    PanTime = 30
    
    FOR i = 0 TO TiltTime 'center tilt/pan unit
    PULSOUT tilt, LastDelayTilt
    PAUSE 18
    NEXT
    FOR i = 0 TO PanTime
    PULSOUT pan, LastDelayPan
    PAUSE 18
    NEXT
    main:
    
    
    RANDOM tpseed
    IF tpselect = 0 THEN GOSUB panit 'for tilt or pan direction
    
    RANDOM TiltSeed ' give a random number
    tiltdelay = tiltseed
    DO WHILE (tiltdelay > 750 OR tiltdelay < 550 ) 'check to see if tilt is within specs
    RANDOM TiltSeed ' mixup numbers
    tiltdelay = tiltseed
    LOOP 'continue till values are right for movement
    GOSUB tiltit
    
    GOTO main ' start all over
    
    tiltIt:
    FOR i = LastDelayTilt TO TiltDelay STEP 10000 'Change Step Number Higher to go faster
    PULSOUT tilt, i 'send out pulse to servo
    PAUSE 30
    NEXT
    LastDelayTilt = TiltDelay
    RETURN
    
    PanIt:
    RANDOM panseed ' mix random number with seed value
    pandelay=panseed
    DO WHILE (pandelay > 750 OR pandelay < 500 ) ' wait till within movement specs
    RANDOM panseed ' mix numbers up again
    pandelay=panseed
    LOOP ' loop until numbers are within correct movement range
    
    FOR i = Lastdelaypan TO pandelay STEP 10000 'Change Step Number Higher to go faster
    PULSOUT pan, i
    PAUSE 30
    NEXT
    LastDelayPan = PanDelay
    RETURN
    

    I believe I was using the Servocity Pan and Tilt system at the time:

    https://www.servocity.com/spt100
    Awesome!!! I think I can definitely tune it a little to suit my needs. I have 2 different servos. Here's the label from the packaging and a picture of the other. The KS-30 seems to be defunt as there's nothing at all on the 'net
    Once again many thanks to all, you guys are great. Now for some serious construction
    640 x 360 - 23K
    640 x 360 - 22K
  • Actually, I believe I used this Pan/Tilt kit:

    https://www.servocity.com/spt200

    The owl head was just at 2 lbs, so you need to use the servos they recommend. Those small 9 gram ? servos will not cut it.
    Infernal Machine
  • The head I'm using is less than 12 ounces. But I think I need continuous rotation servos.
    I've used the program and connected 2 servos but the amount of movement on both of them is very small, less than 5º. Also there are no long pauses on the pan. Is there any way to pause the pan for something like 2 minutes?
    Here's the prototype. The body can be made bigger to accommodate a tilt and pan mechanism plus servos and batteries with a slide switch underneath. Head is 5" diameter and is solid wood. Weighs 12 ounces but can be hollowed.
    480 x 640 - 41K
  • Continuous rotation servos are for wheeled robots. You don't want them for this situation. A standard servo should give at least 180 degree movement, (+90/-90), some a little more. You are going to have to start with some much bigger servos.
    Infernal Machine
  • On the Servocity site you linked to they recommend an HS485HB servo which according to it's spec sheet is "Continuous Rotation Modifiable" as are all the other recommended servos. So I'm really confused! Also they quote the HS485HB suitable for loads up to 1lb and I'm below that.
    I tried to upload a small video but unfortunately the forum doesn't allow it. I would definitely like to make the pan move in bigger increments up to 180º right now the max seems to be about 15º
    Thanks

  • Kinectricity,

    Check your batteries because servos use a lot of power especially when they are trying to maintain their position.

    In the old days you needed to modify a servo to make it rotate continuously but today you can buy servos that were built for continuous rotation.
  • Genetix wrote: »
    Kinectricity,

    Check your batteries because servos use a lot of power especially when they are trying to maintain their position.

    In the old days you needed to modify a servo to make it rotate continuously but today you can buy servos that were built for continuous rotation.
    Right now I'm running off a 9v power supply with 470 ohm resistors to the servos. But thanks for the heads up as the intention was to use batteries in the finished project

  • GenetixGenetix Posts: 1,150
    edited December 2017 Vote Up0Vote Down
    Kinectricity,

    What is the rating of your power supply and is it regulated?

    You could drop the voltage using a voltage divider or diodes but using batteries or a 6V REGULATED power supply is much simpler.
    This is using a voltage divider:
    9V ___/\/\/\___.___/\/\/\___.___/\/\/\___ Ground or Vss
          330 ohm  ^  330 ohm       330 ohm
                   |
                   |_ Get 6V from here since 2/3 of 9 is 6
    
    This is using diodes:
    9V ---|>|---.---|>|---.---|>|---.---|>|--- 6.2V   (Each diode drops about 0.7V)
        1N400x     1N400x   1N400x    1N400x
    
  • Genetix wrote: »
    You could drop the voltage using a voltage divider
    This is using a voltage divider:
    9V ___/\/\/\___.___/\/\/\___.___/\/\/\___ Ground or Vss
          330 ohm  ^  330 ohm       330 ohm
                   |
                   |_ Get 6V from here since 2/3 of 9 is 6
    
    That only works if the current drawn is very small, otherwise the voltage drop over the first 330 ohm resistor is much more than 3 V, resulting in much less than 6 V for the servo.

    --
    MH
    BS2Sx
  • Q: Can a STAMP do this
    A: There is nothing a Stamp can't do.

    As you have found, Kinectricity!
    "When you make a thing, a thing that is new, it is so complicated making it that it is bound to be ugly. But those that make it after you, they don’t have to worry about making it. And they can make it pretty, and so everybody can like it when others make it after you."

    - Pablo Picasso
Sign In or Register to comment.