Shop OBEX P1 Docs P2 Docs Learn Events
line following with stingray — Parallax Forums

line following with stingray

KayduhKayduh Posts: 9
edited 2013-08-08 15:03 in BASIC Stamp
So I had my line follower (boe bot kit + qti sensors) working perfectly, I decided to get the sting ray chassis and two HB25 motor controllers after modifying the code for the HB25's it just seems out of wack. From what I am thinking, the way the servos was working was that each time you would pulsout it would turn the wheels a few degrees then stop and wait for the next pulsout. The fact that it would stop and go so quickly made it seem very smooth. Now with the DC motors, I think each time it sends the pulsout it seems to start the wheels moving but it doesnt stop after each pulsout like the servo's did it just keeps moving.

The boebot was very accurate in that it would scan then move a little, scan then move a little again. But with the stingray chassis and DC motors, its scanning at the same speed but moving much to fast that it keeps getting ahead of its self. If anyone can help out at all it'd be greatly appreciated!


This is the old code, pretty much it only moved forward when the two middle sensors both detected the line (0110) and any other sensor combination would have the robot adjust untill it was completely centered.
' {$STAMP BS2}
' {$PBASIC 2.5}


qtis VAR Nib
OUTB = 11


DO
  GOSUB Check_Qtis


  SELECT qtis




    CASE 00
      PULSOUT 12, 750
      PULSOUT 13, 650


    CASE 00
      PULSOUT 12, 750
      PULSOUT 13, 650


    CASE 00
      PULSOUT 12, 750
      PULSOUT 13, 650


    CASE 10
      PULSOUT 12, 750
      PULSOUT 13, 650


    CASE 10
      PULSOUT 12, 850
      PULSOUT 13, 650


    CASE 10
      PULSOUT 12, 850
      PULSOUT 13, 750


    CASE 11
      PULSOUT 12, 850
      PULSOUT 13, 750


    CASE 01
      PULSOUT 12, 850
      PULSOUT 13, 750


    CASE 11                                 
      PULSOUT 12, 850
      PULSOUT 13, 750


    CASE ELSE


  ENDSELECT
LOOP


Check_Qtis:


  DIRB = 11
  PAUSE 0
  DIRB = 00
  PAUSE 0
  qtis = INB


  RETURN

This is the new code, first adjustment i had to make was to force the robot to turn sharper by having both wheels rotate the same direction so it would pivot other wise the turn radius was much to large. the second was to adjust the speed because the power from the dc motors is so strong that it wasnt slowing down fast enough at the corners and it would just shoot off the track.
' {$STAMP BS2}
' {$PBASIC 2.5}


HB25        PIN   15


qtis VAR Nib
OUTB = 11


DO : LOOP UNTIL HB25 = 1
LOW HB25
PAUSE 5
PULSOUT HB25, 750
PAUSE 1
PULSOUT HB25, 750


DO
  GOSUB Check_Qtis


  SELECT qtis


    CASE 00
      PAUSE 5
      PULSOUT HB25, 700
      PAUSE 1
      PULSOUT HB25, 700


    CASE 00
     PAUSE 5
      PULSOUT HB25, 700
      PAUSE 1
      PULSOUT HB25, 700


    CASE 10
     PAUSE 5
     PULSOUT HB25, 700
     PAUSE 1
     PULSOUT HB25, 700


    CASE 00
     PAUSE 5
      PULSOUT HB25, 800
      PAUSE 1
      PULSOUT HB25, 700


    CASE 10
     PAUSE 5
      PULSOUT HB25, 800
      PAUSE 1
      PULSOUT HB25, 700


    CASE 10
     PAUSE 5
      PULSOUT HB25, 800
      PAUSE 1
      PULSOUT HB25, 700


    CASE 01
     PAUSE 5
      PULSOUT HB25, 800
      PAUSE 1
      PULSOUT HB25, 800


    CASE 11
     PAUSE 5
      PULSOUT HB25, 800
      PAUSE 1
      PULSOUT HB25, 800


    CASE 11
     PAUSE 5                               
      PULSOUT HB25, 800
      PAUSE 1
      PULSOUT HB25, 800


    CASE ELSE


  ENDSELECT
  LOOP


Check_Qtis:


  DIRB = 11
  PAUSE 0
  DIRB = 00
  PAUSE 0
  qtis = INB


  RETURN

Also, just thought i should mention the corners i'm having trouble with are 90 degree turns.

Comments

  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-08-07 13:00
    Have you checked your I think some encoders might help out a lot since you are using regular DC motors.

    Edit: Some how a portion of my post was deleted!!!! What I meant to ask was have you checked your HB-25's for a dead stop at 750? I have in the past noticed that a couple of mine are off a bit like an uncentered servo.
  • ercoerco Posts: 20,257
    edited 2013-08-07 13:52
    A stock Stingray is too undergeared (too much speed, not enough torque) to react like a hobby servo. There's not much motor braking going on. This is a classic overcontrol problem and quite frankly it's not easy to solve. I would like to see someone write out the Laplace transform for that control system. :) A few options for you to consider:

    1) Switch to lower gear motors for faster control response and more braking
    2) Slow way down on your PWM and/or lower your motor voltage to reduce overcontrol
    3) Adjust the location of your sensors front & back and spacing for better response

    Per #3, take a tip from the FAST line follower robots. Instead of 2 or 3 sensors, have an array of 8 or 10 sensors so you can react faster when the line moves/curves. Of course there's more processing involved to use more sensors.
  • PublisonPublison Posts: 12,366
    edited 2013-08-07 15:24
    Here's a post of a Stingray using 8 QTI's. I have not drilled down to see if Kye shared his code, but the video's show that it can be done.



    http://forums.parallax.com/showthread.php/131242-Parallax-Stringray-Robot-1st-Place-at-Carnegie-Mellon-University-Mobot-Race-2011?highlight=Stingray
  • KayduhKayduh Posts: 9
    edited 2013-08-08 15:03
    erco wrote: »
    A stock Stingray is too undergeared (too much speed, not enough torque) to react like a hobby servo. There's not much motor braking going on. This is a classic overcontrol problem and quite frankly it's not easy to solve. I would like to see someone write out the Laplace transform for that control system. :) A few options for you to consider:

    1) Switch to lower gear motors for faster control response and more braking
    2) Slow way down on your PWM and/or lower your motor voltage to reduce overcontrol
    3) Adjust the location of your sensors front & back and spacing for better response

    Per #3, take a tip from the FAST line follower robots. Instead of 2 or 3 sensors, have an array of 8 or 10 sensors so you can react faster when the line moves/curves. Of course there's more processing involved to use more sensors.

    1. where can i buy motors other than online, hobby stores? im also in the LA area

    2. I have been playing with the slower speeds, my goal isnt to have a fast robot but even with slower speeds the braking is still a problem =/

    3. what type of sensor position would make for better response?
Sign In or Register to comment.