Shop OBEX P1 Docs P2 Docs Learn Events
Program Scan Time and Servo Motor Control — Parallax Forums

Program Scan Time and Servo Motor Control

Scott2HotScott2Hot Posts: 10
edited 2009-03-02 20:38 in BASIC Stamp
I want to be able to control·multiple servo motors and at the same time·monitor the inputs and make the adjustments to the servos position and speed with the BS2. If I know how long it took for the program to scan I could subtract this from the 20ms pause and set it at the end of the program. Assuming the program scan time is less than 20ms. Just wondering if anyone knows how to do this or if there is a better way?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-02 18:09
    What you have outlined is the way to accomplish this task. There are any number of examples in the Robotics with the BoeBot tutorial which you can download from Parallax. The 20ms period is approximate. Servos require a control pulse at least once every 20ms and can't tolerate too many control pulses in that timeframe. A range of 10-20ms is reasonable.

    A BoeBot with a PING bracket and PING can handle 3 servos plus the PING sensor plus two touch bumpers and even IR distance sensing all in a 20ms cycle with some time left over for simple logic to turn to the direction of the longest path.

    Post Edited (Mike Green) : 3/2/2009 6:14:42 PM GMT
  • Scott2HotScott2Hot Posts: 10
    edited 2009-03-02 19:34
    I was looking for an answer last night in the "Robotics with the Boe Bot Student Guide". They had an example where the code did check the sensors and just reduced the pause command to 15ms. No logic as to how they figured it would take 5ms for the scan. I thought it would be a good idea to have the program measure its scan time if possible and adjust the pause automatically. Good to know that the 20ms pulse is approximate. I just purchased a PWMPAL and know this should solve any timing issues once I figure out how the thing works. The PWMPAL is brand new and one of the pins broke off of it already. Not sure how that happened or if it came in like that. So if I can create the code without the PWMPAL it would be a lot cheaper than buying a chip that the pins break off too easily.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-02 19:58
    The PWMPAL is normally pretty robust. You might put in a phone call to Parallax support about this.
  • Scott2HotScott2Hot Posts: 10
    edited 2009-03-02 20:38
    Thanks for the advice. I haven't even powered the PWMPAL up yet. I can't find the broken pin either. I did email the purchasing department but they have not responded yet. Photos attached.
    1024 x 768 - 52K
    1024 x 768 - 51K
    1024 x 768 - 47K
Sign In or Register to comment.