Shop OBEX P1 Docs P2 Docs Learn Events
SumoBot for RoboGames HELP !! — Parallax Forums

SumoBot for RoboGames HELP !!

DWinchellDWinchell Posts: 60
edited 2006-06-18 16:17 in Propeller 1
Hello All;
·
I am trying to build PropSTICK based Sumo Robots to compete in the RoboGames Mini-Sumo event at Ft. Mason NEXT WEEKEND !! I have two entries "Sumo Cog" and "King Cog".· BTW "Sumo Cog" has HiTec HS-645MG servos and Sticky Tires. "King Cog" has HSR-9559TG Robot Servos and Dually Sticky tires. Both are using modified Parallax SumoBot chassis and scoops.
·
I have the PropSTICKS built and Tested. I have Led's blinking. I have gotten the "ServoTest" Program running and controlling servos. I am not sure how to hookup the Stock#: 555-27401 QTI Sensors·and write the cog spin code. There are 4 sensors. Two in front and two in back of the robots.
·
Has anyone out there done this yet ??
·
Thank You
Dave Winchell

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank You

David Winchell

David@Winchell.com
«1

Comments

  • edited 2006-06-09 19:13
    Dave,

    Set both QTI pins high at the same time, pause for a millisecond, then set the I/O pins to input, wait for another half a millisecond, and then store the QTIs' output states in a variable.

    Assuming your QTIs are connected to P16 and P17 and you have declared a variable named temp, it should go something like this:

    outa[noparse][[/noparse]16..17] := %11
    ··· .
    ··· .
    ··· .
    · dira[noparse][[/noparse]17..16] ~~
    · waitcnt(clkfreq/1000 + cnt)
    · dira[noparse][[/noparse]17..16] ~
    · waitcnt(clkfreq/2000 + cnt)
    · temp := ina[noparse][[/noparse]17..16]

    ··CASE temp
    ··· %00:
    ····· ' your code
    ··· %01:
    ····· ' your code
    ··· %10:
    ····· ' your code

    ··· etc...

    Andy
  • edited 2006-06-09 19:32
    Dave,

    My·following Propeller Bot·makes use of infrared detection, servo control, and a number of other·objects you might find useful for your Propeller SumoBot.· The archive is attached.

    Andy
  • DWinchellDWinchell Posts: 60
    edited 2006-06-10 00:32
    Hi :-)

    · THANK YOU ANDY !! I am new to the SPIN World and the following code has my Head Spinning :-)

    · The QUI will work on 3.3 VDC only ??

    · outa[noparse][[/noparse]16..17] := %11
    · dira[noparse][[/noparse]17..16] ~~
    · waitcnt(clkfreq/1000 + cnt)
    · dira[noparse][[/noparse]17..16] ~
    · waitcnt(clkfreq/2000 + cnt)
    · temp := ina[noparse][[/noparse]17..16]
    ·
    · What does the .. mean in the expersions ??

    · What does the ~ and the ~~ mean in the expressions ??

    · Does [noparse][[/noparse]16..17] mean the same as [noparse][[/noparse]16,17] ??

    · I got the "waitcnt(clkfreq/2000 + cnt)" figured out :-)

    · Seems like the code should be:
    ·
    · ' Pin 16 is QTI Power
    · ' Pin 17 is QTI Signal

    · dira[noparse][[/noparse]16] := 1·· ' Set 16 for output
    · dira[noparse][[/noparse]17] := 1·· ' Set 17 for output
    · outa[noparse][[/noparse]16] := 0·· ' Set 16 Low
    · outa[noparse][[/noparse]17] := 0·· ' Set 17 Low
    · waitcnt(clkfreq/1000 + cnt)

    · dira[noparse][[/noparse]17] := 0·· 'set 17/Signal to input
    · waitcnt(clkfreq/1000 + cnt)
    · temp := ina[noparse][[/noparse]17] ' Get data 0 = Black and 1 = White
    · dir[noparse][[/noparse]16] := 0··· ' Turn off power to QTI









    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • edited 2006-06-10 03:22
    Hi David,

    I'm assuming a pair of QTIs, with both their W power pins connected to 3.3 V. I'm also assuming the signal pins are connected to P16 and P17. To check to find out if the QTIs are hovering over the sumo ring's black surface or its white tawara ring perimeter, start by setting set both signal pins output-high for long enough to discharge the QTIs' capacitors. The example code does it for 1 ms, but you could probably get away with 0.1 ms. Then, set the signal pins to input and wait for half a ms. When you record the states of the inputs, each will either store 1, indicating that the QTI's output voltage is still above 1.65 V, or 0 indicating it has dropped below 1.65 V. If a given QTI's state is still 1, it means not enough IR is being reflected back from the floor to open up the IR transistor to let the capacitor charge up very quickly. In other words, it's the black ring. If a given output is 0, it means the opposite, and the QTI is probably pointing down at the sumo ring's white tawara perimeter.

    Looking back at the code, somewhere before the main loop, the output states of P17 and P16 were changed to high with this command:

    · OUTA[noparse][[/noparse]17..16]~~

    The double-tilde sets all the bits in the result to 1. You would get the same result using:

    ·OUTA[noparse][[/noparse]17..16] := %11

    Keep in mind that these pins are still input because the program has not yet told the pins to be output. However, when the pins are set to output, bits 17 and 16 in the OUTA register store binary-1s, so they will send high signals as soon as they are made outputs.

    Next, inside some REPEAT loop, we are setting the I/O pins to output with this command:

    · DIRA[noparse][[/noparse]17..16]~~

    Keep in mind that the OUTA registers already store 1s, so P17 and P16 will now transmit high signals, effectively shorting themselves to the Propeller chip's 3.3 V supply. Again, we could have used the command DIRA[noparse][[/noparse]17..16] := 1.

    After this, the code pauses for 1 ms with this command:

    · waitcnt(clkfreq/1000 + cnt)

    The clkfreq register stores the number of times the Propeller's clock will have to tick to make one second elapse. So, clkfreq/1000 is the number of clock ticks it takes for 1 ms to elapse. The cnt register always stores the current number of clock ticks. Even though it rolls over at 2 to the 32nd power, the math all still works out in the wash. So, waitcnt adds clkfreq/1000 to cnt, and then waits for the cnt register to accumulate up to the result of clkfreq/1000 + cnt. The result, a 1 ms pause for that particular cog. When cnt gets up to clkfreq/100 + cnt, the program continues stops waiting and goes on to the next command.

    Now, it's time to set the I/O pins to input:

    · DIRA[noparse][[/noparse]17..16] ~

    Remember that the double tilde set the bits 16 and 17 in the DIRA register to 1. A single tilde sets the bits to 0. Yes, the result would be the same if you used the command DIRA[noparse][[/noparse]17..16] := %00.

    Now, we have to wait for half a millisecond while each QTI capacitor charges as quickly as its infrared transistor will allow it, which is controlled by the reflectivity of the surface the QTI is hovering over. 1/2 a millisecond works pretty well for most surfaces, so we'll use this command:

    · waitcnt(clkfreq/2000 + cnt)

    Remember, black doesn't reflect much, so the capacitor cannot draw current through the infrared transistor and charge. So the lower plate of the capacitor, which is connected to the I/O pin through a resistor will still have a voltage above 1.65 V, and the INA bit for that pin will store a 1. White reflects lots of infrared, which in turn opens up the IR transistor's collector-emitter channel, and allows as much current as the capacitor wants to flow through. The voltage at the lower plate drops, and the INA bit for that pin will store a 0.

    The program stores the states of INA register bits 16 and 17 with this command:

    · temp := ina[noparse][[/noparse]17..16]

    I didn't show temp being declared, but it would look something like this in the program's VAR section.

    VAR

    · Byte temp

    So, now temp stores the states of INA[noparse][[/noparse]17..16]. It coud store one of four possible combinatioins of 0s and 1s: %00, %01, %10, or %11. %11 means both QTIs are over the tawara. Assuming the P17 QTI is mounted on the bot's front-left, and the P16 QTI is mounted over the front-right, it's time to decide what to do. A CASE statement can evaluate a variable on a case-by-case basis. The code might look something like this:

    REPEAT
    · CASE temp
    ··· %11:
    ····· bot.BackUp
    ····· bot.TurnU
    ··· %10:
    ····· bot.BackUp
    ····· bot.TurnLeft
    ··· %01:
    ····· bot.Backup
    ····· bot.TurnRight
    ··· %00
    ····· bot.SearchPattern

    Andy

    Post Edited (Andy Lindsay (Parallax)) : 6/10/2006 3:26:39 AM GMT
  • edited 2006-06-10 03:24
    BTW, sorry, I didn't answer your question about the order of the bits.

    DIRA[noparse][[/noparse]17..16] and DIRA[noparse][[/noparse]16..17] are different. If I wanted to set P17 to output (1) and P16 to input (0), I could do it one of two ways:

    · DIRA[noparse][[/noparse]17..16] := %10

    ··· -- or --

    · DIRA[noparse][[/noparse]16..17] := %01

    Post Edited (Andy Lindsay (Parallax)) : 6/10/2006 3:27:25 AM GMT
  • DWinchellDWinchell Posts: 60
    edited 2006-06-10 20:44
    W O W !!

    THANK YOU ANDY !! I see you do what you do because you do it well. This was the most comprehensive problem solution I have ever read. I now understand perfectly what to do THANK YOU ANDY !!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • edited 2006-06-10 21:41
    Hey, thank you David!

    I think you might like this even better. Attached is "Propeller SumoBot - Archive...zip", an example Propeller SumoBot application. This is a bare-bones starter example with minimal competitive functionality, and with a week left before the contest, I suspect you'll be well occupied making improvements and tuning (discussed later).·

    Since you mentioned you are using a modified Parallax SumoBot, I included and used objects that take care of all the Parallax SumoBot's basic functions including:

    · - Schematic
    · - Infrared object detection
    · - QTI monitoring
    · - Servo Control
    · - Piezospeaker

    To view a schematic, open "Propeller SumoBot.spin" and then press the F8 key. Then, double-click the Propeller SumoBot Schematic folder in the Object Info window. You can also view the Propeller SumoBot Schematic after closing the Object Info window Propeller SumoBot Schematic folder in the Propeller Tool's object browser (folder icons in upper-left windowpane, right below File, Edit, etc).

    Since I did the initial work for a Propeller Boe-Bot, it's also got a couple of objects/methods that I don't typically use with SumoBots:

    · - Servo control signal ramping for smooth transitions between maneuvers
    · - IR distance detection (with 40 zones, compared to the Boe-Bot's 5 zones)

    Keep in mind that the "Propeller SumoBot.spin" demonstration program is just a bare-bones example. I would definitely recommend add a search pattern for when the SumoBot doesn't have anything in its sights. For search pattern suggestions, see Applied Robotics with the SumoBot (PDF), which is available for download from the SumoBot Robot Competition Kit page.

    I would also recommend either making the ramping steps very large, or entirely decoupling ramping from the application.

    For the sake of stealth, you'll probably want to modify the Qtis object so that the QTI power pins are controlled by Propeller I/O instead of their current schematic, hard wired to 3.3 V.

    Of course, extra sensors will also come in handy for more quickly and reliably locating your opponent.

    While I'm leaving most of these improvements up to you, I'm almost always available for hints and explanations on how the objects work and how they can be modified.

    Andy

    Post Edited (Andy Lindsay (Parallax)) : 6/10/2006 10:00:42 PM GMT
  • DWinchellDWinchell Posts: 60
    edited 2006-06-11 04:50
    Thank You ANDY !!

    I have some work to do here and this is a GREAT START !!

    Back to ya soon. Thanks again for the help !!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • DWinchellDWinchell Posts: 60
    edited 2006-06-12 01:43
    Hello Andy;

    I am almost done with the Hardware for "Sumo Cog".

    The LEDs IR & Visable = VDD = +3.3 VDC
    The QTIs "W" = VDD = +3.3 VDC

    The Servos = VDD = +6.0 VDC Schematic indicates VDD ?

    Are U sure of PNA4602 = VDD = +3.3 VDC will work ??

    VDD is the regulates VIN ?? VIN = 6 VDC and VDD = 3/3 VDC

    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • edited 2006-06-12 02:22
    David,

    Oh, thanks for letting me know; I'll update the schematic. On my board, I have a 5 V and a 3.3 V regulator. I was powering the QTIs with 3.3 V, the servos with 6 V, and the PNA4602s with 5 V.

    I know that Parallax servos will work with 6 VDC for power and 0 to 3.3V signals. If the Hitecs don't like it there are several workarounds. The PNA4602 power pins should be connected to 5 VDC for their power. They can handle 6 V for power as well, but 3.3 V probably won't work.

    Andy
  • DWinchellDWinchell Posts: 60
    edited 2006-06-12 02:57
    Thank You !!

    I was about to wrap the PNA4602's to 3.3 VDC and try it. I did not put a +5 reg on the bot. Do you think the PNA4602's will hold at 6 VDC ?? When they go HI is 10K series resister enought to not fry the Prop chip inputs ??

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • DWinchellDWinchell Posts: 60
    edited 2006-06-12 02:57
    Thank You !!

    I was about to wrap the PNA4602's to 3.3 VDC and try it. I did not put a +5 reg on the bot. Do you think the PNA4602's will hold at 6 VDC ?? When they go HI is 10K series resister enought to not fry the Prop chip inputs ??

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • edited 2006-06-12 03:04
    I put 220 ohm resistors in series between the PNA4602 signal pin and the Propeller I/O pin. The PNA4602 outputs are so wimpy, I don't think a lack of series resistor would put a propeller I/O pin at risk. Inside each PNA4602, the high signals are sent as a result of a 10 k pull-up resistor, and low signals are pulled low by a PNP transistor.
  • DWinchellDWinchell Posts: 60
    edited 2006-06-12 16:45
    Hello Andy & All :-)

    OK got a 2940 5VDC Reg in now & Batts, Caps & power on the Prop !! Loaded your code and IR LEDs are coming on :-)

    I am adding 2 red and 2 green LEDs to indicate line crossing and opponent acquisition

    Now its wire and debug. To bad I have to goto work today :-)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
    800 x 600 - 94K
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-06-12 17:36
    David: Neat project!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2006-06-12 17:42
    David,

    As far as I know, this is the first published Propeller-based robot project outside of Parallax (of course Andy has been at it for quite some time already). Nice job!

    Ken Gracey
    Parallax, Inc.
  • DWinchellDWinchell Posts: 60
    edited 2006-06-14 18:55
    Hello Andy & All smile.gif



    outa[noparse][[/noparse]25] := HI ' Left Line LED Off
    outa[noparse][[/noparse]26] := HI ' Right Line LED Off

    case qti
    %01: outa[noparse][[/noparse]25] := LOW ' Left Line LED On

    case qti
    %10: outa[noparse][[/noparse]26] := LOW ' Right Line LED On

    case qti
    %00, %01, %10: bot.go(bot#BACKWARD)
    waitcnt(clkfreq/2 + cnt)
    case qti
    %00, %01: bot.go(bot#ROTATE_RIGHT)
    %10: bot.go(bot#ROTATE_LEFT)

    case qti
    %00, %01, %10: waitcnt(clkfreq*2/3 + cnt)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • DWinchellDWinchell Posts: 60
    edited 2006-06-14 19:04
    Hello Andy & All smile.gif

    Great progress !! The IR Detectors are alive and working. Hooked the VDD to +5 VDC and added a 10k series resistor in the signal line. I have added two green LEDs to act as indicators when the IRs pick up an opponent. Main loop, IR Detector, LED indicator & Square Wave software are running like a watch.

    The QTIs are not working. They have the VDD hooked to 3.3 VDC and the signal directly to the pins on the Propeller chip. Here is the code segment. I am wondering if the VDD needs to be +5 VDC and if I need to add a resistor in the signal line.


    outa[noparse][[/noparse]25] := HI ' Left Line LED Off
    outa[noparse][[/noparse]26] := HI ' Right Line LED Off

    case qti
    %00, %01: outa[noparse][[/noparse]25] := LOW ' Left Line LED On

    case qti
    %00, %10: outa[noparse][[/noparse]26] := LOW ' Right Line LED On

    case qti
    %00, %01, %10: bot.go(bot#BACKWARD)
    waitcnt(clkfreq/2 + cnt)
    case qti
    %00, %01: bot.go(bot#ROTATE_RIGHT)
    %10: bot.go(bot#ROTATE_LEFT)

    case qti
    %00, %01, %10: waitcnt(clkfreq*2/3 + cnt)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • edited 2006-06-14 19:15
    Hi David,

    I tested the·whole thing·on a Sumo Ring to make sure it worked.· Double check your connections (The QTI's power and signal are different from a servo.)··The QTIs'·W terminals' connected to the Propeller chip's 3.3 V supply.··Each R terminal is connected to a Propeller I/O pin.· The B terminal is connected to·the Propeller's common ground.

    Also, check your QTIs' capacitors.· Do they have 103 printed on them?

    Andy
  • edited 2006-06-14 19:19
    I just measured the distance between my QTI's and the surface. Just a hair under 3/16 of an inch.
  • edited 2006-06-14 19:23
    David,

    Comment out the qti CASE statements that control the LEDs and try this instead:

    outa[noparse][[/noparse]25..26] := qti

    Andy

    P.S. You can comment out the whole block with curly braces like this:

    {

    outa[noparse][[/noparse]25] := HI ' Left Line LED Off
    outa[noparse][[/noparse]26] := HI ' Right Line LED Off

    case qti
    %00, %01: outa[noparse][[/noparse]25] := LOW ' Left Line LED On

    case qti
    %00, %10: outa[noparse][[/noparse]26] := LOW ' Right Line LED On


    }

    outa[noparse][[/noparse]25..26] := qti
  • DWinchellDWinchell Posts: 60
    edited 2006-06-14 19:29
    Hello Andy smile.gif

    Yes the caps are 103 on both QTIs

    W = 3.3VDC and hooked to the Propeller 3.3V pin directly.
    R = Connected to Propeller pins 16 & 17
    B = Conected to common ground.

    Scope time ??

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • edited 2006-06-14 19:35
    I would also try commenting your code and substituting mine. (The curly braces comment the entire block of code)

    DIRA[noparse][[/noparse]25..26] := %11
    OUTA[noparse][[/noparse]25..26] := qti

    {

    outa[noparse][[/noparse]25] := HI ' Left Line LED Off
    outa[noparse][[/noparse]26] := HI ' Right Line LED Off

    case qti
    %00, %01: outa[noparse][[/noparse]25] := LOW ' Left Line LED On

    case qti
    %00, %10: outa[noparse][[/noparse]26] := LOW ' Right Line LED On

    }

    If that doesn't fix it, and you have a scope, great, check it out. Otherwise, we have can use an RCTIME object to compare your and my QTI decay timing differences. Whichever you'd prefer.

    Post Edited (Andy Lindsay (Parallax)) : 6/14/2006 7:39:09 PM GMT
  • DWinchellDWinchell Posts: 60
    edited 2006-06-14 19:51
    Tryed in main module and LEDs stay on.

    DIRA[noparse][[/noparse]25..26] := %11
    OUTA[noparse][[/noparse]25..26] := qti

    Tryed in the Qtis module and the LEDs stay off.

    repeat

    dira[noparse][[/noparse]sPin..ePin]~~
    waitcnt(clkfreq/2000 + cnt)

    dira[noparse][[/noparse]sPin..ePin]~
    waitcnt(clkfreq/2000 + cnt)

    qtiBits := ina[noparse][[/noparse]sPin..ePin]
    long[noparse][[/noparse]address] := qtiBits

    DIRA[noparse][[/noparse]25..26] := %11
    OUTA[noparse][[/noparse]25..26] := qtiBits

    I will move to my second propstick on the Professional Development board this evening and continue experimenting. Gotta run for now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • edited 2006-06-15 04:01
    Hi David,

    I used the programs in the attached archive to test my QTIs' RC decay times.·
    • Run "Test QTIs...spin" by pressing the F12 key.· This loads the program into EEPROM, but does not run it.
    • Press the F7 key to find out which COM port your propeller is on and make a note of it.
    • Run the BASIC Stamp Editor.·
    • Open a Debug Terminal, and set the COM port to whatever value you got from pressing F7.
    • Press and release the Propeller's reset button to start the program.
    • The program should·display microsecond RC decay measurements in the Debug Terminal.
    • Try hovering your QTIs over black and white surfaces.
    Over white surfaces, I'm getting 106 us with the left QTI and 121 with the right.· Over black surfaces, I'm getting 2430 with the left and 3109 with the right.· How about you?

    IMPORTANT: Before downloading the next program, make sure to close the Debug Terminal, or set the its COM port to NONE.

    Andy
  • DWinchellDWinchell Posts: 60
    edited 2006-06-16 04:46
    Hello Andy & All :-)

    I am ready to RUMBLE !! I have a camcorder & TV camera in the BOT !! I will post video after the battle Saturday. I have 4 Parallax Sumo Bots ready to go. Well almost. Sumo Cog is stuck on the simple QTI sensors and can't see the ring line ?? Please see the attached two stand alone spin programs for QTI testing. What's wrong here ?? I have 16 QTI modules ( Bought 4 line follower sets ) and tested them all. Checked power & ground I am out of ideas. HELP !!

    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • DWinchellDWinchell Posts: 60
    edited 2006-06-16 04:51
    WOW !! OK just got the decay program will run it now !!

    THANK YOU !!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
  • edited 2006-06-16 05:01
    Good, yes, let's find out what that does.

    Andy
  • edited 2006-06-16 05:32
    David,

    Your code didn't work on my bot either.· I made a change and now it works for me; let's see if it works for you (attached).

    Andy
  • DWinchellDWinchell Posts: 60
    edited 2006-06-16 14:27
    HELLO ANDY !!

    THANK YOU !! YOU GOT IT !!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank You

    David Winchell

    David@Winchell.com
Sign In or Register to comment.