I was wondering if it is possible to use the gear tooth sensor to set predetermined heights for an elevator? for example, set it to go and stop at X amount of teeth that we know is the amount of rotations needed to get our elevator to level 1, 2 and 3 to more precisely place tubes on the pegs.
I have done research and I have found that people use it to determine relative speed, but we are not sure if it can be used this way… Can it?
I am aware that the sensor does not know direction :eek:
It is possible, legal, and should work fine. Just have the code reset the ‘known’ position at the start of each match.
A PID loop is used to control a setpoint. One example is a car cruise control (maintains constant speed), another is a kitchen oven (maintains constant temperature).
What you may want to use is called an “Interrupt”. This is a special hardware connection (to the Digital sidecar) that signals the cRio’s processor “STOP Whatever you are doing and run this piece of code. Immediately. Now”. In your case, that code might add +1 (or subtract -1 if the lift motor is running backwards) to a counter that keeps track of lift position. Clearly, the code must be as brief as possible, since your processor is literally unable to do ANYthing else while the interrupt is active. (The interrupt gets activated by the sensor signal)
Do your own research on the highlighted words to understand and do it.
I would be worried about using a gear tooth sensor as you only check for height. If there is anything that interferes with your robots elevator extension problems could arise. Some potential problems I can think off hand is if your gear slips (or more likely a belt or chain later down the line) or if your elevator gets hit and is knocked out of wack. While these scenarios are not that likely (depending on construction of said elevator) it might be worthwhile to have an additional check on elevator height.
For an application like this, an interrupt is unnecessary… the FPGA design has counter logic in it that will deal with counting up or down as you wish. It is much faster and has no impact on your robot code’s execution speed. Use interrupts only as a last resort.
Sean - the danger in using a gear tooth counter in this manner is that it is a ‘relative’ measurement system.
That means that where ever your lift happens to be when you power it on is the zero point. If the lift is set 3 inches high, then you may run the lift too high at the end of the motion. Or, worse, if you have a power fluctuation on the field, the lift will lose it’s ‘zero’ position.
You are better off if you use something that is absolute. To that end, there are absolute encoders and multi-turn potentiometers that you could use. In 2008 we used a 10 turn pot from radio shack that worked very well. In 2010, we did as you are suggesting and used the encoder to measure how far we unwound our winch. It was a constant hassle to make sure the winch always started in the same position.