SumoBot for RoboGames HELP !!
DWinchell
Posts: 60
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
·
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
Comments
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
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
· 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
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
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
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
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
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
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
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
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
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Just tossing my two bits worth into the bit bucket
KK
·
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.
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
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
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
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
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
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
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
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
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
THANK YOU !!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank You
David Winchell
David@Winchell.com
Andy
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
THANK YOU !! YOU GOT IT !!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank You
David Winchell
David@Winchell.com