![]() |
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 |
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.:ahh: Something to look out for.
Joey |
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 |
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.
|
Re: Robot Drive for 10 seconds
Quote:
|
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. |
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); |
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.
|
Re: Robot Drive for 10 seconds
One other thing to note is that your counter will need to be static.
|
| All times are GMT -5. The time now is 09:23. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi