![]() |
Re: Rookie help
Quote:
Code:
if (counter < 59) // About a second |
Re: Rookie help
Ok, that is how i had to do it
Thanks, and it worked [edit] I almost fully understand how everything works, but what is that sensor for? [/edit] |
Re: Rookie help
Quote:
More has been posted on gyro's than I care to imagine. Do an Advanced Search on gyro in just the "Programming forum" and start reading through the 70 or so threads you'll get. |
Re: Rookie help
No, I mean I know what they are for, but in my setup i mean
|
Re: Rookie help
Quote:
The example you're using could wave a flag I suppose... On the EDU robot a servo could be used in this way to move an arm to a precise position to scoop something up then another position to carry that something around. On the full size robot it can be used to change gears in a drive train from low to high or vice versa. In 2004, many robots used a servo to detect the direction to the IR beacons. |
Re: Rookie help
I was changing values and learning how it worked, but I got confused on one of my changes and how it worked
This is the code for 1 of my servos, but why does it look like it moves regularly from 255 towards zero and then it goes back to 255, back to 0, and then back to 255 to count down again Code:
if (counter2 < 59) |
Re: Rookie help
Quote:
What you're doing here results in: counter2=0 counter2=58 counter2= 116 counter2=0 etc. This pretty much means that servo2 will get changed every 4 times through this loop ~1/15 sec. That's right on the edge of giving the servo enough time to complete a full movement. If you want to change the timing just change the "59" to something else. servo2 produces stranger results: servo2=0 servo2=253 servo2=506 //but it wraps around at any value over 255 so it ends up ~251 servo2=504 // ditto |
Re: Rookie help
Ok, that is what I thought
I have the one servo running through the code to go 1 degree a second and the other one doing the start and reset loop What else what I program for other things(other then user_routines) I have nothing specific because I am still getting my second job, but I know I'll need help :) |
Re: Rookie help
Quote:
You can play with reading toggle switches attached to the RC to control which type of servo movement to do. You’ll need external switches later on to be able to select between two different autonomous programs for example, or to tell your program which side of the playing field your robot is starting on. What you actually have is your first autonomous program. The next thing is to make it perform multiple sequential steps, such as -moving slowly for 5 seconds, -then doing your “start and reset” for 5 seconds, -then do a third action for 5 seconds. One way to do this is to use another “counter,” but do different things as it increases in value (as time goes by), like this: Code:
static int counterX=0; // Use int for larger numbersCode:
static char servoState=0; |
Re: Rookie help
so for the states, how would I make each one run 5 seconds later?
|
Re: Rookie help
Quote:
ServoState++; //or better “ServoState = 1;” with something like: Code:
if (ServoCounter > 295)Eventually you should move to a clock based scheme instead of the more primitive use of counters to time your loops. The counters don’t transition easily from the Robovation controller to the FRC, since the loop times are different, and it isn’t as difficult to keep track of many different counters. Using one of the built-in timers you could maintain a “clock” variable that just kept the current time. Then the logic might look something like: Code:
#define STATE1_DURATION 5 //in seconds |
| All times are GMT -5. The time now is 02:29. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi