Shop OBEX P1 Docs P2 Docs Learn Events
Simple filtering with Basic Stamp? — Parallax Forums

Simple filtering with Basic Stamp?

ArchiverArchiver Posts: 46,084
edited 2004-02-28 21:37 in General Discussion
I have added a compass sensor to my robot project(cmps03) and want
to turn the robot in a specified heading. Even though the compass is
fast the robot will overshoot the desired heading since there is a
delay when reading the heading from the compass.

This must be a common problem with a number of sensors. does anyone
have any suggestions on a solution to my problem. Has anyone
implemented som kind of simple filtering algorithm?

Rightnow im only testing if current heading is larger or smaller
than the desired heading.

Current code:

IF (turnangle>bearing) THEN
PWM_REG1 = turnSpeed
PWM_REG2 = -turnSpeed
GOSUB SETDC
DO
GOSUB ReadDir
LOOP UNTIL (bearing>=turnangle)
ENDIF


best regards

Magnus, Stockholm, Sweden

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-02-28 20:16
    At work we run motors to a specific elevation (radars) and we use slopes to
    assist (or desist) with overshoot.

    Say...if the heading is more than 10degrees off, the robot moves at X speed.
    If the robot is between 3 and 10degrees off it moves at Y speed. If the
    robot is less than 3degrees off, it moves at Z speed. (I'm sure you get the
    idea!)

    We need the dishes to 'settle' at it's specified elevation within a certain
    amount of time. If it takes too long to settle, the data will be old and
    useless and the weather guys will never get the forecast right...oh
    wait...uh....nevermind!! haha

    I don't know what kind of output you have from the cmps03....does it give
    you any sort of 359 point resolution? I've seen some that just remark on
    the cardinal directions....

    sb
    Original Message
    From: "skogsvargen" <skogsvargen@h...>
    To: <basicstamps@yahoogroups.com>
    Sent: Saturday, February 28, 2004 2:49 PM
    Subject: [noparse][[/noparse]basicstamps] Simple filtering with Basic Stamp?


    > I have added a compass sensor to my robot project(cmps03) and want
    > to turn the robot in a specified heading. Even though the compass is
    > fast the robot will overshoot the desired heading since there is a
    > delay when reading the heading from the compass.
    >
    > This must be a common problem with a number of sensors. does anyone
    > have any suggestions on a solution to my problem. Has anyone
    > implemented som kind of simple filtering algorithm?
    >
    > Rightnow im only testing if current heading is larger or smaller
    > than the desired heading.
    >
    > Current code:
    >
    > IF (turnangle>bearing) THEN
    > PWM_REG1 = turnSpeed
    > PWM_REG2 = -turnSpeed
    > GOSUB SETDC
    > DO
    > GOSUB ReadDir
    > LOOP UNTIL (bearing>=turnangle)
    > ENDIF
    >
    >
    > best regards
    >
    > Magnus, Stockholm, Sweden
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    > Yahoo! Groups Links
    >
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2004-02-28 20:27
    You might want to scale your turning rate based on the difference
    between your current heading and the desired heading -- further away
    means faster turn; as you get closer you slow down. This should help
    solve your overshoot problem.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office



    Original Message
    From: skogsvargen [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=2-w39juxxLy4300gzasOMminHpAYjrSEvMXxLuy7BCcJodxweXWUZiJx4cu2JemaOXoVMcYh5tfbIjFh6owsYWvg]skogsvargen@h...[/url
    Sent: Saturday, February 28, 2004 1:49 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Simple filtering with Basic Stamp?


    I have added a compass sensor to my robot project(cmps03) and want
    to turn the robot in a specified heading. Even though the compass is
    fast the robot will overshoot the desired heading since there is a
    delay when reading the heading from the compass.

    This must be a common problem with a number of sensors. does anyone
    have any suggestions on a solution to my problem. Has anyone
    implemented som kind of simple filtering algorithm?

    Rightnow im only testing if current heading is larger or smaller
    than the desired heading.

    Current code:

    IF (turnangle>bearing) THEN
    PWM_REG1 = turnSpeed
    PWM_REG2 = -turnSpeed
    GOSUB SETDC
    DO
    GOSUB ReadDir
    LOOP UNTIL (bearing>=turnangle)
    ENDIF


    best regards

    Magnus, Stockholm, Sweden
  • ArchiverArchiver Posts: 46,084
    edited 2004-02-28 21:37
    By the way, this is a classic control problem.
    The typical solution to this is a "PID" algorithm.
    This algorithm describes how to build a correction
    factor for your control output based on your sensor
    input. The other answers you've gotten have been
    simple quick-and-dirty approaches to a PID.

    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > You might want to scale your turning rate based on the difference
    > between your current heading and the desired heading -- further away
    > means faster turn; as you get closer you slow down. This should
    help
    > solve your overshoot problem.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    >
    Original Message
    > From: skogsvargen [noparse][[/noparse]mailto:skogsvargen@h...]
    > Sent: Saturday, February 28, 2004 1:49 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Simple filtering with Basic Stamp?
    >
    >
    > I have added a compass sensor to my robot project(cmps03) and want
    > to turn the robot in a specified heading. Even though the compass
    is
    > fast the robot will overshoot the desired heading since there is a
    > delay when reading the heading from the compass.
    >
    > This must be a common problem with a number of sensors. does anyone
    > have any suggestions on a solution to my problem. Has anyone
    > implemented som kind of simple filtering algorithm?
    >
    > Rightnow im only testing if current heading is larger or smaller
    > than the desired heading.
    >
    > Current code:
    >
    > IF (turnangle>bearing) THEN
    > PWM_REG1 = turnSpeed
    > PWM_REG2 = -turnSpeed
    > GOSUB SETDC
    > DO
    > GOSUB ReadDir
    > LOOP UNTIL (bearing>=turnangle)
    > ENDIF
    >
    >
    > best regards
    >
    > Magnus, Stockholm, Sweden
Sign In or Register to comment.