Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Simple Autonomous Code (http://www.chiefdelphi.com/forums/showthread.php?t=35181)

Team620 21-02-2005 21:47

Simple Autonomous Code
 
Im having trouble doing autonomous mode. My team and I have agreed to go with dead reckoning. I was wondering if anyone can help me with a simple code to make the motors drive for 1 second and stop i just need help getting started.
After I see a sample code for the motors then I can figure it out this would be appreciated thanks.
-Ryan

His Eminence 21-02-2005 22:02

Re: Simple Autonomous Code
 
Set a simple counter that is incremented every time. Then use conditional statements (like an if statement) to do certain things within a set time. As for actually running the motors, you have to find out which PWM you are using. Then, do something like this:

pwm01=235;

assuming pwm01 is the PWM you are using on your robot.

ConKbot of Doom 21-02-2005 22:10

Re: Simple Autonomous Code
 
I don't have any example code, but you could use the fact that the code is executed once every 26.2 milliseconds and use some decrementing (or incrementing) counters and some if statements...

well, sort of an example, but definitely needs refinement
Code:

count = count + 1;
if (count = 15)
  {
  pwm01 = 180;
  pwm02 = 180;
  }
if (count = 45)
  {
  pwm01 = 255;
  pwm02 = 0;
  }

If I have the idea correct, as count reaches 15, the bot will go forward at a medium speed, then when it reaches 45, it will turn, one side full speed forward, one side full speed back. You get the idea? Just remember that every "count" is 1/38 of a second.

EDIT: got beaten to it... oh well I'll leave it there for the code

TMHStitans 21-02-2005 22:33

Re: Simple Autonomous Code
 
You can find a very good, yet simple autonomous code on this innovation first link. It not only allows you to go forward, but you can turn in any direction. It is based on time as well so I think it would be perfect for what your looking for. You just have to change the timing, speed, and pwm settings. Its really very simple and useful. You can modify it anyway you like by simply inserting or deleting times, speeds, and directions. You can also use if statements to create switches on the robot wired to the digital inputs that will allow you to write several different autonomous modes. Consider it an improved version of dead reckoning. (dead reckoning++)?

http://www.ifirobotics.com/forum/viewtopic.php?t=75

Team620 21-02-2005 23:14

Re: Simple Autonomous Code
 
thank you i think i can program autonomous now
-Ryan


All times are GMT -5. The time now is 04:41.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi