|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
programing the vex optical shaft encoder
i'm having a small problem w/ optical shaft encoders on the vex swervebot i'm building. the encoders tell the rc how far the drive pods have turned.
in the program, i start all the encoders, and have them retrive to variables. once the vairables reach a the right value, the pods stop turning, then i reset the variables when the pods need to turn back. my problem is that i allign all the pods, but when i test the program, they don't all turn the same amount, so they're off when they come back. i think it might be how i set up the motors to run. can anyone help me fix this? i'm including a copy of my code |
|
#2
|
||||
|
||||
|
Re: programing the vex optical shaft encoder
I may be able to help, however I think we need to know a little more about your bot, for example does one motor turn all of the pods or do they turn seperately, also how much different is the amount that the encoders report and how much different is the amount that the actual pods turn.
I tried to look at your code but the file formats are .bds and .ecp which I don't recognize at all, I assume you are using easy C but is there any way you can give us .c or just txt files? |
|
#3
|
|||||
|
|||||
|
Re: programing the vex optical shaft encoder
umm, i'm not sure. the pods turn on separate motors, but all the encoders are mounted exactly the same
|
|
#4
|
|||
|
|||
|
Re: programing the vex optical shaft encoder
your program assumes that all the motors go exactly the same speed and stop/start immediately.
you need to take inertia of your system into account. looks like a typo for the compare value of rot_encoder2: rot_encoder2 < 2 should probably be rot_encoder2 < 20 (in several places) try evaluating each encoder value separately and turn the corresponding motor off when that encoder reaches the desired value. you may also need to accelerate and decelerate the motors rather than just a hard stop and start to reduce overshoot. |
|
#5
|
|||||
|
|||||
|
Re: programing the vex optical shaft encoder
thanks, i just copy/paseted that part of the code ^.^;
how do i get the motors to accelerate/decellerate? i don't have to put in a bunch of blocks stepping up to the speed i want, do i? |
|
#6
|
|||||
|
|||||
|
Re: programing the vex optical shaft encoder
ok now i have another problem:
Code:
while (swerve == 0)
{
Tank4 (0 , 2 , 2 , 3 , 4 , 1 , 2 , 1 , 0 , 1 , 0);
swerve = GetRxInput (1 , 5);
}
Last edited by youngWilliam14 : 09-11-2007 at 14:07. |
|
#7
|
||||
|
||||
|
Re: programing the vex optical shaft encoder
Quote:
I still can't read the rest of your code since I don't have EasyC on my laptop but it sounds like you are just driving the motors until you get to a certain number of pulses from the encoder then stopping them. If this is the case you may be able to get (read as will get) better results if you use PID control (or any of many other control algorithms) there is a code paper on here that outlines how to do it, I'll find it and edit this post with a link as soon as I can. James http://www.chiefdelphi.com/media/papers/1823 - That is a good reference to get you started on PID control if you have never used it before. Last edited by JamesBrown : 09-11-2007 at 14:20. Reason: Found the white paper |
|
#8
|
|||||
|
|||||
|
Re: programing the vex optical shaft encoder
ok, i put in print statements before, in, and after the loop. before the loop, 'swerve' is zero. the first time though the loop, it's still zero, but the second time through it says 127!?!? so it quits the loop.
***EDIT*** i forgot to say that the print statement in the loop is AFTER it checks for the button Last edited by youngWilliam14 : 10-11-2007 at 13:24. |
|
#9
|
||||
|
||||
|
Re: programing the vex optical shaft encoder
Quote:
|
|
#10
|
|||||
|
|||||
|
Re: programing the vex optical shaft encoder
ok, i'll try that. it's defined as an integer right now
|
|
#11
|
|||||
|
|||||
|
Re: programing the vex optical shaft encoder
defining it as character made the program not record the value, but i fixed the loop thing
i still need a way to get evrything to turn the same amount though |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem using VEX shaft encoder | jskene | Programming | 15 | 28-10-2007 22:33 |
| VEX Shaft Encoder Kit | jeffmorris | FIRST Tech Challenge | 1 | 19-05-2006 12:23 |
| VEX Optical Shaft encoders in FRC | sanddrag | FIRST Tech Challenge | 8 | 04-10-2005 07:52 |
| Hollow Shaft optical encoders | magical hands | Robotics Education and Curriculum | 0 | 03-02-2005 22:56 |
| Rotary Encoder (optical etc.) | Gary C | Technical Discussion | 4 | 16-01-2005 18:23 |