![]() |
programing the vex optical shaft encoder
1 Attachment(s)
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 |
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? |
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
|
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. |
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? |
Re: programing the vex optical shaft encoder
ok now i have another problem:
Code:
while (swerve == 0) |
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. |
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 |
Re: programing the vex optical shaft encoder
Quote:
|
Re: programing the vex optical shaft encoder
Quote:
|
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 |
| All times are GMT -5. The time now is 18:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi