|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Programming Loops
Hey all! Alright I have a question about measuring the values in the code. When you put the program into the bot and your using a motor to rotate you put in the number that will rotate the motor the right amount right? Well suppose that U put on a pully to the motor (in this case the globe) and figure out the exact number to make the globe rotate 1/4 of a rotation or 90*. Well if you divide the number you get by 90 (the degree achieved) then you SHOULD get the numerical value that sould represent how many program loops are needed to achive this distance, correct? Please tell us if we are right, thanx.
Jason and Mike Team 384 |
|
#2
|
|||
|
|||
|
Sounds right to me. FYI, in one second the pbasic code will loop about 40 times, depending on the amount of code and probably the temperature (cold=faster).
We did something similar in our robot this year, but we rely on hard stops so the motor will stall for a little while (no more than 1/2 sec) before the program tells it to stop. This way if it gets hung up for a second or the loop executes are slightly different speeds, we should still get the needed rotation from the motor. |
|
#3
|
|||||
|
|||||
|
that is one way to do it but if you want to go with the fun way you could get yourself a potentiometer and attach it to the shaft of the motor. starting at lets say 127 you would turn 90 degrees and use debug to find out the value of the pot at that angle. you then find a speed that you can tell it to turn until you get to that angle. the correct speed would be whatever the highest speed you can make the motor turn without it passing the point. globe motors arent that fast and stop pretty quickly.
if you want to get a bit more advanced you can have the speed go on a curve according to the pot value. (ie when the motor is furthest away from the value you want the faster it spins and the closer it is the slower it spins) if you want to try this and need some help with it feel free to ask me. my team is using this same scenario for our crab drive and it works really really well. |
|
#4
|
|||||
|
|||||
|
Our team had a very similar problem last year, when we were trying to write our autobalancing code. We tried about a billion different meathods, my favorites being: a pedulum on a pot, and stopping the motors when the pot was 127; magnetic switches on one wheel as well as the frame next to it, and counting the number of trips of that switch (we found that this did not have good enough resolution, since we had to be within a few inches), but finally, we simply decided on this: We use a gyrochip to measure when it starts tilting, after this moment, we run the motors backward for a certain amount of loops. This gave us a resolution of 1/40 of a second, more than enough. This is nice because you can debug it really nice:
RUNTIME con (# of loops) counter var byte counter = 0 serin ... other code here serout ... serin ... pwm1 = 150 pwm2 = pwm1 counter = counter + 1 if counter = RUNTIME then mainloop serout ... This way, we could calibrate in a second to any bridge at the comp during the practice round by adjusting RUNTIME at the top of our code. This gives you the resolution you need. You could put it in your mainloop as well, if you want to. |
|
#5
|
||||
|
||||
|
Re: Programming Loops
Quote:
Now a better way. As was referred by the other members, feedback control. Try using limit switches or a potentiometer input to limit the travel of the motor. Limit switches can be used if the travel distance is fixed. Potentiometer feedback can be used if the distance will be variable. I hope this helps |
|
#6
|
|||
|
|||
|
Potentiometers and limit switches would solve this problem.
We chose to use hard stops with timeouts. This is a more robust solution (less parts to break.. limit switches are very cheap & weak, especially in a hardcore compeition like this year) and could be implemented quickly. It's pretty much foolproof.. you don't have to worry about overextending your motor because a limit switch fails. It works great, and anyone going to the New Haven, CT regional can stop by and visit team 562 for a demo! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Programming Compatition | Angela06 | Programming | 30 | 08-04-2005 23:12 |
| Hooking up Controller to computer for programming. | Dragon45 | General Forum | 3 | 30-01-2003 00:22 |
| Pneumatics electrical wiring and programming | archiver | 2001 | 1 | 23-06-2002 23:10 |
| Error found in programming for the pump and pressure switch | sjharobotics | Programming | 4 | 06-02-2002 17:46 |
| pbasic programming | punarhero | Programming | 4 | 21-01-2002 23:32 |