Shop OBEX P1 Docs P2 Docs Learn Events
can the BASIC Stamp control a servo, until a certain input comes along? — Parallax Forums

can the BASIC Stamp control a servo, until a certain input comes along?

MatthewMatthew Posts: 200
edited 2004-11-04 01:54 in BASIC Stamp
For example, can a BASIC Stamp hold a servo at 90 degrees, until a temperature probe tells the Stamp it is 50 degrees F? Would this be considered multitasking?

Comments

  • NewzedNewzed Posts: 2,503
    edited 2004-11-03 23:28
    Basically, it is multitasking.· However, you can work around it by having the Stamp check the temp probe during the 20ms pause between servo pulses.· Computer-wise, you can do a lot in 20ms.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    New Combo LCD Backpack

    http://hometown.aol.com/newzed/index.html
    ·
  • MatthewMatthew Posts: 200
    edited 2004-11-03 23:52
    Wow, that is so cool! So pulses from the Stamp to the servo are not constant? Meaning, a servo will keep its position until a new pulse is sent, which are 20ms apart?
  • MatthewMatthew Posts: 200
    edited 2004-11-03 23:56
    Wait, what if I decide to use an ultrasonic sensor, the data sheet to that says ranging will take 65ms? Could I still tell the Stamp to check the ultrasonic sensor between the servo pulses?
  • NewzedNewzed Posts: 2,503
    edited 2004-11-03 23:56
    Actually, the servo has no holding power after the pulse is finished, but·the power·returns so quickly it appears to be holding firm.· Once the train of pulses is completed, then the servo does lose its holding power.

    Check your temp probe and shorten the 20ms pulse to 19ms.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    New Combo LCD Backpack

    http://hometown.aol.com/newzed/index.html
    ·
  • edited 2004-11-04 00:14
    Here's an example with a simulated temperature input.· This should keep a servo (connected to P14) at its center position until the temperature measurement = 50.

    ' ServoTemperature.bs2
     
    '{$STAMP BS2}
    '{$PBASIC 2.5}
     
    servo         PIN   14
     
    temperature   VAR   Byte
     
    DO UNTIL temperature >= 50
     
      GOSUB Get_Temperature
      DEBUG ? temperature
     
      PULSOUT servo, 750
    
      PAUSE 20
     
    LOOP
     
    DEBUG "Servo disabled"
     
    END
    
    Get_Temperature:
     
      temperature = temperature + 1
     
      RETURN
    
  • MatthewMatthew Posts: 200
    edited 2004-11-04 00:37
    Okay, thanks Andy for writing that code. What if I have a device, such as an ultrasonic sensor, that takes greater than 20ms find a value. The tech papers for the sensors say it'll take about 65ms. Would a Parallax Servo Control do the job?

    Here's a quote from the Parallax Servo Controller description:
    "Luckily for you and your Parallax microcontroller, the PSC manages all of the servo pulses which enables your BASIC Stamp® module or Javelin Stamp module to take care of more important aspects of the application. "

    Does that mean I can tell the stamp to drive a motor foward or reverse until it the distance is 40 feet? For example, the ultrasonic sensor would be constantly measuring distance, and when it is >40 feet, the motor will go in reverse intil 40 feet is acquired. And when the distance is <40 feet, the motor will go foward until 40 feet is acquired. Any thoughts?

    Thanks.
  • BeanBean Posts: 8,129
    edited 2004-11-04 00:50
    A servo has a "pulse stretcher" built into it.

    You provide a pulse and the built-in pot provides a pulse (indicating the position of the servo).
    Then the circuit in the servo "sees" which pulse is longer, (indicating if the servo is too far to the left or right.
    The "difference" pulse is then "stretched" to about 20ms.

    As long as you send a pulse every 20milliseconds or so the servo will hold it's position.
    If you don't send a pulse in 20milliseconds the servo goes idle. Which means you can manually move it.

    Hope this helps.

    Bean.
  • edited 2004-11-04 00:57
    Yes, the Parallax Servo Controller is an example of a coprocessor that will free up your BASIC Stamp to listen to the range finder.

    You could potentially go certain distances if you know the speed of the continuous rotation servo because the BASIC Stamp can then control the time the Parallax Servo Controller runs.· See Robotics with the Boe-Bot, Chapter 4, Activity 2 for a distance vs. time example.· It doesn't use a coprocessor, but it's not hard to adapt.· Robotics with the Boe-Bot is available for free download from the www.parallax.com -> Downloads -> Stamps in Class Tutorials page.

    Another option would be to use the range finder, and program the BASIC Stamp to determine when it has traveled 40 ft by subtracting the current distance measurement from the distance stored before the robot started moving.·

    A third option would be to use encoders.· Enter Boe-Bot Digital Encoder into the Search field on the Parallax home page to find out more.

    Post Edited (Andy Lindsay) : 11/4/2004 1:00:16 AM GMT
  • MatthewMatthew Posts: 200
    edited 2004-11-04 01:54
    Okay, thanks you all!
Sign In or Register to comment.