![]() |
Rookie help
I am new to programming and extremely new to a lot of mechanical stuff in general, so my team gave me something to work on over the holidays, but I am very confused.
I will try and be as specific as possible to receive help They gave me an edubot controller, a battery, a charger, 2 servos, a serial to usb converter, and something called a BEI GyroChip I know what the battery, charger, and serial -> usb cable do/are for, but how would i hook up the rest of thie stuff to the control Thanks |
Re: Rookie help
Quote:
The gyro plugs into an analog input on the controller (one of the first inputs based on User_Initialization() in user_routines.c). If it doesn’t already have a connector attached you’ll have to make one out of a PWM cable. You get values from it doing something like “x = Get_Analog_Value(rc_ana_in01);“ The neutral position of the gyro will be close to 512. When the gyro is twisted slowly in one direction you’ll get numbers between 0 and 512 only while you are twisting it. Do the same in the other direction and you’ll get numbers between 512 and 1023. If you keep track of these numbers you can tell if your robot is driving straight or not and correct. It can also be used to make precise turns, to say 45 degrees if you calibrated it. This particular gyro is no longer "street legal" to use on your competition robot, but it's good to learn with. This one will be overly sensitive to turns or sudden movements that are too quick, and will more easily lose track of the original robot heading. Do a search on “gyro” for a lot of threads on the subject. |
Re: Rookie help
the gyro has a pwm, and my only job is to make the sensors move or something
sensors go to pwm out? if so, the black is on top right the gyro goes to analog in with the black on botton? if all this is correct thank you and i will probably have questions later about what all these do and what / how to code |
Re: Rookie help
Quote:
The gyro is a sensor and the servos are specialized motors. |
Re: Rookie help
um, i have 4 pwm out pins, but only three holes, does the closest one not matter for these servos?
|
Re: Rookie help
Quote:
|
Re: Rookie help
I can use any 2 pwm out pins right
And I just put the gyro in the first digital in spot |
Re: Rookie help
Quote:
If you are starting with the default EDU code, that arranges for the first two inputs to be analog, so either 1 or 2 will work. |
Re: Rookie help
Will the default EDU code have stuff that i can just upload and make it work, just to learn the workings?
|
Re: Rookie help
Quote:
http://innovationfirst.com/FIRSTRobo...04-Jan-14a.pdf http://innovationfirst.com/FIRSTRobo...10-15-2003.pdf http://innovationfirst.com/FIRSTRobo...t_02-16-04.zip |
Re: Rookie help
And I just use MPLAB IDE to mess with it right?
Also, what kind of code am i looking for just to make these things move for starters What code(s) will I have to upload as well? |
Re: Rookie help
Quote:
How about putting something like this where it says "/* Add your own code here. */" in the file "user_routines.c" in the routine "Process_Data_From_Master_uP" Code:
static unsigned char servo1=0; //Put these two lines right before the "Getdata" call |
Re: Rookie help
Thank you, i will fiddle and learn from that code (is user routines akin to autonomous cause i dont know how im gonna make them move if it isnt)
1 more question (i hope) how and what do i upload to my controller now? |
Re: Rookie help
Quote:
|
Re: Rookie help
C:\...\EDU_Default_02-16-04\user_routines.c:249:Error: syntax error
Halting build on first failure as requested. BUILD FAILED: Mon Dec 20 16:36:48 2004 here is the snippet i edited Code:
/******************************************************************************* |
Re: Rookie help
Variable declarations must be at the very beginning of a routine. I noted that above in an edit after my original post. Sorry about that.
Quote:
|
Re: Rookie help
Error - Source file 'C:\...\ifi_utilities.c' name exceeds file format maximum of 62 characters.
:) silly mplab [edit] hmm, do i need to install my usb to serial converter? [/edit] |
Re: Rookie help
Quote:
|
Re: Rookie help
yeah, but i have a keyspan usb -> serial
does xp not auto add it? [edit] Build Succeeded! now to add it to the controler :( [/edit] |
Re: Rookie help
Quote:
Are you getting a download error using IFI_Loader? Sometimes those adaptors auto connect to a different COM port than it advertises. You can run through and try all the possible COM ports in IFI_Loader by choosing "PortSettings" and COM1, try to download, then COM2, and try to download, etc. [edit] I misunderstood. Do you have the controller or will you try that later? For those of you reading along... The error doyler got was because one of the path and filenames was too long for MPLAB to handle. Combined they cannot be more than 62 characters or so. The usual solution is to keep the directory for all your FIRST code at the top level of the C drive, i.e., "C:\FIRST" not on your desktop because that's really at "C:\Documents and Settings\doyler\Desktop\" which is already 41 characters long. |
Re: Rookie help
Quote:
http://www.keyspan.com/downloads/win/ |
Re: Rookie help
2 questions
For that code do i have to plug them into certain pwm outs? Also, will my code just start? |
Re: Rookie help
Quote:
Code:
pwm03 = servo1;The code should start immediately after the download has completed. |
Re: Rookie help
I charged my battery and the chargers light turned green
I plugged it in, the battery power and fault status lights blinked, but then nothing [edit] now battery power, program state, and fault status are blinking green while pwn in/radio is a constant red is this good? [/edit] |
Re: Rookie help
Quote:
Now press the Prog button to get a solid orange LED. |
Re: Rookie help
Ok it works
Now i just need to learn how, why, and how to change it First off: How would i make the program loop somewhat faster |
Re: Rookie help
Quote:
The servo will then take 1.4 minutes to move very slowly through a 60 degree turn before it quickly whips back to the "0" position and repeats. You can speed this up by changing the delay we built in. Code:
if (counter < 20) // about 1/3 second in the slow loop for one ~60/255 degree turn |
Re: Rookie help
Code:
static unsigned char servo1=0;(i will go through it step by step) |
Re: Rookie help
Quote:
Yes, servo1 is the position you set for the servo to move to. You can actually set it to any value you like. For instance if you have an RC unit, you could use that to move the servo. The variable "servo1" could be completely replaced in this code sample with the system variable "pwm03" if you wanted. It isn't strictly needed, but it does make it easy to switch to a different pwm without having to change all your code. This routine (Process_Data_From_Master_uP) in the default code is called the slow loop. It executes about 59 times per second (in the EDU, FRC is 38 times per sec.), because that's how fast the radio packets come in. We're using that characteristic of the loop to make "counter" a cheap timer. Each loop equals 1/59 second, so "counter<59" , for example, will equal one second. [edit] P.S. You can also change "servo1++;" to something like "servo1 += 5;" to make the servo move faster still. But be careful that the logic of the check "if (servo1 < 255)" catches servo1 before it tries to become larger than 255. When that happens servo1 cannot hold a value larger than 255, so it will suddenly become a completely unexpected value. |
Re: Rookie help
Yes, it worked
So 38 is 1 second? Then why is 2 faster then 20 I understand the variables part (except for the counter which is covered in the below code) Code:
if (counter < 2) // about half a second in the slow loop for one 60/255 degree turn (2 = 7 seconds, 20=2 minutes)[edit] i dont understand your edit fully [/edit] |
Re: Rookie help
[edit] I confused the issue by mixing up the number of slow loops per second between the EDU (59) and the FRC (38) [/edit]
Well, we’re moving the servo a tiny bit (servo1++; equals approx. 60/255 degrees) each time counter adds up to: - 59 loops = 1 second (counter < 59) - 59/2 or ~30 loops = ½ second (counter < 30) - 59/19 or 1 loop = 17ms (counter < 2) We don’t have to move servo1 (+1) each time. A servo is made to jump immediately to an exact position. It just happened to be convenient for our example to move it slowly through it’s entire range of motion. You could have servo1 make bigger jumps like +5 or +10 if you like. You will have to become aware of what values the different variable types are made to hold. We declared servo1 to be an unsigned char. An unsigned char is only big enough to store the values 0 through 255. If you try to make it equal something outside this range, such as 300, you won’t get any error message, but you will get what seems to be a random number instead. |
Re: Rookie help
Ok, i understand the whole counter except how to calculate it
- 38/2 or 20 loops = ½ second (counter < 20) - 38/19 or 2 loops = .05 sec. (counter < 2) how do you know counter < 20 is equal to 38/2 and how do you know that is 1/2 a second [edit] and how/why is 1 second equal to 38 loops /************************************************** ***************************** * FUNCTION NAME: Process_Data_From_Master_uP * PURPOSE: Executes every 17ms when it gets new data from the master * microprocessor. [/edit] |
Re: Rookie help
The confusion is my fault. I'm mixing the numbers between the FRC and the EDU controller.
The EDU receives radio packets once every 17ms or approx 58.8 times per second. The FRC receives packets once every 26.2ms or approx 38 times per second. I'll go back and correct my examples above to reflect: ~59 = 1 second ~30 = 1/2 second ~15 = 1/4 second etc. |
Re: Rookie help
So how would i calculate whatever number i put in here
Code:
if (servo1 < 254)also here: Code:
if (counter < 2) // about half a second in the slow loop for one 60/255 degree turn (2 = 7 seconds, 20=2 minutes)[edit] also, where does my output go from Code:
printf("PWM OUT 7 = %d, PWM OUT 8 = %d\n",(int)pwm07,(int)pwm08); /* printf EXAMPLE */[/edit] |
Re: Rookie help
(counter < n) is the time between each distinct movement of the servo. Where n/59 = the time seconds. For example,
n= 59 is 1 second, n=118 is 2 seconds, n=30 = ½ second (servo1 += y) is how large a movement the servo will make each time (according to the above). For example, y=1 position and is the smallest movement the servo can make, y=5 moves 5 servo positions and because of this will appear to be 5 times as fast. You’ll have to change the limit check “if (servo1 < 254)” to match whatever number you use, to make sure servo1 will never end up greater than 255. For instance, if y=5 the check should become “if (servo1 < 250)” if y=10 the check should become “if (servo1 < 240)” The range of motion depends on the actual servo model you have. |
Re: Rookie help
Ok, for the servo +=5 is the little movements it makes before it resets?
If so i understand all that Code:
pwm03 = servo1;if so then 1 question not pertaining to the servos how does Code:
printf("PWM OUT 7 = %d, PWM OUT 8 = %d\n",(int)pwm07,(int)pwm08); /* printf EXAMPLE */ |
Re: Rookie help
Quote:
Quote:
In this case the statement probably shows up in the terminal window as: PWM OUT 7 = 127, PWM OUT 8 = 127 Do a search in Chiefdelpi for printf and you'll get a lot of information about it. You need to pick up a C programming book. printf is a standard C function. |
Re: Rookie help
So I can do pwm08 = servo1 and they will both moved if plugged in 3 and 8?
Also, I can just change the 7 and 8 to the 2 i am using and just load ifi loader to see whats happening? |
Re: Rookie help
Quote:
|
Re: Rookie help
Quote:
There are some PWM Ins along the top (the female connectors) for a hobby radio (similar to expensive RC cars or planes). Since I don't think you have one, don't worry about it. [edit]Sorry, that's a little old.[/edit] |
Re: Rookie help
I was messing with it last night and just got stuck on one thing
How would I make it go to the end, and then reset without stopping in the middle at times |
Re: Rookie help
Quote:
What you are seeing could be due to the servo not being given enough time to reach the requested position. The electronic controller operates much faster than the mechanical servo and could be sending position requests too quickly. |
Re: Rookie help
I wasn't seeing anything
I was just trying to make it go straight to the end and then reset and then loop |
Re: Rookie help
Quote:
What kind of delay do you have between changing positions (i.e., counter)? |
Re: Rookie help
Yeah like that, but i didnt put in a counter because I couldn't figure out how to time it
|
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