Shop OBEX P1 Docs P2 Docs Learn Events
Building A Cruise Control — Parallax Forums

Building A Cruise Control

G McMurryG McMurry Posts: 134
edited 2009-12-24 01:19 in BASIC Stamp
I have a BS24P running a speedometer and also running a hobby servo that operated the throttle on a gasoline engine.

My speedometer operates from 0 to 25.5 miles per hour (0 to 255) and my Throttle control operates in much the same range. Almost exactly the same on level ground.

I would like to take the feedback from the Speedometer and use it to create the hobby servo signal based on the command number I am now sending directly to the hobby servo.

Basically I want to close the velocity loop so that when I go up a hill and the speedometer slows down, the throttle command will automatically increase.

Does anyone have any idea how I should begin this experiment?

This system will be used on my large scale locomotive. A hobby servo operates the carburetor. An ADC reads a throttle control pot. I am using COUNT to measure my speed from a hall effects sensor on a drive sprocket.

Just wondering if anyone has done something like this before or as seen any writeups around that deal with making a software cruise control.

THANKS

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
AUTOMATE EVERYTHING
http://www.trainyard.net

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2009-12-16 16:01
    You've basically described in words what you need the program to do. Now just get the program to do the job.

    As a start, the throttle pot becomes the target speed pot.

    The program loops, comparing the actual speed to the pot setting. If actual <target then increase servo position. If actual > target then decrease servo position.

    The loop probably needs to do 5 things:
    measure target speed pot
    measure actual speed
    compare actual and target
    adjust the servo
    repeat

    The details include how fast to adjust the servo and what to do when a sudden change in target speed pot occurs.

    Sounds like a neat project!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • G McMurryG McMurry Posts: 134
    edited 2009-12-21 16:22
    The technique I am looking for is how to create an adjustable loop. I would like to be able to adjust how fast the "adjust the servo" portion will respond. I have never done anything with a built in timing loop. I guess that is really my question.

    I need something to limit the "adjust the servo" or throttle with some control. I don't want the throttle to accelerate so fast that it overshoots the target speed.

    Greg

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    AUTOMATE EVERYTHING
    http://www.trainyard.net
  • FranklinFranklin Posts: 4,747
    edited 2009-12-21 16:46
    How about something like (this is not real code just the idea)

    If target - actual > 10
    Move_fast
    else
    Move_slow
    endif

    Move_fast
    servo = servo + 50

    Move_slow
    servo = servo + 2

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • yarisboyyarisboy Posts: 245
    edited 2009-12-24 01:19
    One of the Propeller objects has a rough set of notes in the comments about proportional integral derivative (PID) error correction controls.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    MOORE'S LAW: The capabilities of electronics shall double every 18 months.
    cloyd's corollary: Hardware is easy, software is hard.
Sign In or Register to comment.