Log in

View Full Version : Answers for Dead Reckoning... FOR BEGINNERS


actorindp
20-02-2004, 21:10
Figured I'd throw in my 2 cents.
I don't know C, I'm just flying by the seat of my pants manipulating code. So hopefully this post will help out others like me, the ones that are just trying to get by.

First start by creating the interrupt timer. Use the Innovation First White Paper to do this. http://www.innovationfirst.com/FIRSTRobotics/pdfs/Timers_White_Paper_2004-Jan-14.pdf

The only thing i didnt use was the t25msdelay, theres no need to. I also just changed the printf statement to show the value of secondCount , nothing more.

If everything works you should now just have a basic second timer, however you might see it moves a lot quicker than 1 second. At least mine does... (hopefully this occurs across the board or the rest of this post means crap)

It actually moves in quarter second intervals. So every tick is .25 of a second.

Then just start creating if statements to drive yourself around.

Your last if statement should read something like this;

if (secondCount > 60) since the timer goes at quartersecond intervals, theres your 15 seconds. You might want to bring it down to say 56 or what have you just to play it on the safe side. at that statement you can turn off the timer and continue the rest of your program.

Once I get back to the bot on monday I'm gonna start some trial and error on our replica field. I'm gonna use a joystick button to start and stop the timer and movement so I can plug those values in the code.


Like I said before, I don't know what I'm doing. This is a very basic approach, heck I'm not even sure if It'll work :p, but I'd figure I'd put in my two cents, so other teams in my position can have a starting point for dead reckoning.

Enjoy!!

-Nick

Be glad to try and help, gimme a shout!
AIM: Actorindp

Please, if you have anything to add don't hesitate to post!!

KenWittlief
20-02-2004, 21:30
Im not sure a quarter second is fine enough resolution for doing dead recogning code - when you are turning a quarter second is a long time

its very easy to have a variable that you increment everytime you loop through your auton code, and use that as a rough timer - if it increments in the main loop it will have a 26mS period - If you increment it in the user_fast code it will be even smaller (I forget the period off the top of my head)

and you dont have to mess with interrupts that way.

actorindp
20-02-2004, 21:33
Well, remember I don't know what I'm doing. hehehehe
It seems simple enough, and seems to work.

But you also dont have to put ur drive motors at full (255 or 0 depending on direction) for that quarter of a second.

It's all about tweaking. :D

-Nick

KenWittlief
20-02-2004, 21:46
if you want to use the HW timers thats great - my only point is you might want finer resolution on the interval period

remember that there will be a bot coming towards the center of the field from the other direction - you should try to get their first, so it doesnt get in your way and prevent you from reaching your release ball

and if you are running your motors at low speeds and something is in your path, you wont have any chance of pushing it out of your way

actorindp
20-02-2004, 21:47
All great points.
Something I'll def. try to keep in mind when I'm trying to code it on monday!

Alan Anderson
20-02-2004, 23:23
its very easy to have a variable that you increment everytime you loop through your auton code, and use that as a rough timer - if it increments in the main loop it will have a 26mS period
I'm doing something even simpler -- I'm simply zeroing a specific variable every time through the 26ms loop. The fast loop code just checks to see when it becomes zero, and maintains its own timers.
If you increment it in the user_fast code it will be even smaller (I forget the period off the top of my head)
Doesn't user_fast just go "as fast as possible"? The period will just depend on how much time it takes to execute the function.
and you dont have to mess with interrupts that way.
Messing with interrupts is, um, messy. :)

mightywombat
20-02-2004, 23:56
I haven't read the white paper but I have found an excellent timer example at www.kevin.org/frc (http://www.kevin.org/frc) it rocks! Interrupts aren't really that bad and you can get an incredible timer resolution from them. Right now our dead reckoning runs by tenth seconds but it could easily go by hundreth or milli-seconds.