|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Robot Drive for 10 seconds
unsigned int timer = 0;
//Forward for 10 seconds if(timer < 382){ pwm01 = pwm02 = 225; timer++; } since the autonomus loops every 26.2ms 10 / 0.0262 = ~382 would this work to drive the robot forward for 10s/ thanks |
|
#2
|
|||
|
|||
|
Re: Robot Drive for 10 seconds
I am not sure about the 382, but other than that it looks good. The only thing that I see is that on most robots the motors are faced different directions, so if that is your case, you just made your robot spin in a circle for 10 seconds.
Something to look out for.Joey |
|
#3
|
|||
|
|||
|
Re: Robot Drive for 10 seconds
We're not sure how we did this, that code is right for drive straight
we first tried pwm01 = 200; pwm02 = 54; and it just spun |
|
#4
|
|||||
|
|||||
|
Re: Robot Drive for 10 seconds
Have you got your IR board working yet, personally I think that having forward and stop functions mapped to two buttons is a better solution to driving forward a said time or distance then a solution like this. However this is a good start in the right direction for autonomous. If you need help with hybrid coding for the IR give a shout.
|
|
#5
|
|||||
|
|||||
|
Re: Robot Drive for 10 seconds
I'd suggest stopping the motors after the 10 seconds are up.
![]() |
|
#6
|
|||
|
|||
|
Re: Robot Drive for 10 seconds
Quote:
Sudocode: pwm_2 = pwm_1; static int counter = 0; counter++; if (counter <= 10) { pwm_1 = 137; } else if (counter > 10 && counter <= 20) { pwm_1 = 157; } etc... We did this one year and it seemed to work pretty well. There might be a better way to do it, but this was simple and we wrote it in about 10 minutes. |
|
#7
|
||||
|
||||
|
Re: Robot Drive for 10 seconds
If you have access to encoders, you may want to have your robot drive a certain distance rather than for a certain length of time.
That way, you could write a function like Drive(distance, speed); |
|
#8
|
||||
|
||||
|
Re: Robot Drive for 10 seconds
They most likely reversed the polarity of one motor when they connected it to a Victor. This has been a common practice for 364 for a number of years, so in fact, setting both motors to 254 will make it drive forward.
|
|
#9
|
||||
|
||||
|
Re: Robot Drive for 10 seconds
One other thing to note is that your counter will need to be static.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| where can I find the code for the first 15 seconds? | CompMaster | Programming | 2 | 16-02-2005 16:23 |
| counting in seconds for the autonomous mode?? | Pattyta | Programming | 22 | 31-03-2004 12:55 |
| pic: Four Seconds | CD47-Bot | Extra Discussion | 9 | 30-03-2003 15:31 |
| Numbers for thought: Are 10 black balls worth 30 seconds? | archiver | 2001 | 6 | 23-06-2002 22:42 |
| about how Drive Train push the robot... shouldn't the force accelerate the robot? | Ken Leung | Technical Discussion | 12 | 26-11-2001 09:39 |