Gear Tooth Sensor

Hello
I need help programming the gear tooth sensors. I searched chiefdelphi but didnt find any thing that helped me. im looking for the program for the sensors. I came upon some posts but i couldnt get any thing for the sensors.

Also on the sensors there is j1 and j2 you have to wire them both. like one pwm cable for j1 and one for j2. from reading the manual i think the pwm cables go to rc_dig , right?

    Thank you

First off, download and read Kevin Watsons encoder code and encoder FAQ
http://www.kevin.org/frc/encoder/
http://www.kevin.org/frc/frc_encoder.zip

To make his code work with the gear tooth sensors you need to remove the “Phase B” logic from it.

Second you wire them to digital I/O 1 and digital I/O 2 with a pwm cable. You also need to power them on a 12volt power supply as well.

See the 2007 Sensor Manual for more information.

“Phase B” dont understand this?
“12volt power supply” for teh this do you mean like connecting a wire for the battery to the sensors. thx

  1. “Phase B” refers to the code that determines which way the encoder is spinning. Since you are using a tooth sensor and not an encoder, this code will just cause problems.

  2. to power on a 12volt supply, run a wire from one of your breaker panels.

12 Volt Power with using a victor or just straight from there. What kind of a fuse should we use 40 AMP?

Also PHASE B logic, its located inside encoder.c file however I do not know which part to uncomment directly.

You guys have been a tremendous help so far.

Go directly from the fuse panel, not from a victor. I am not quite sure but i think you should use a 20 or maybe 30 amp fuse. the 40 amp fuses are for the motors.

The phase b pins are used in if statements so that it adds to the counter if it is moving forward and subtracts when moving backward. You basically have to replace it with code that will just add to the counter whenever an interrupt is fired off.

Something like this should work:


void Encoder_3_Int_Handler(unsigned char state)
{
if(state == 1)
{
Encoder_3_Count += ENCODER_3_TICK_DELTA;
}
}

for the 12 volts on the board it says 12 and underneath it there is the letter w meanning the white cable goes there from the pwm cable. so we have to connect that whit cable to the fues to get 12volts.

Also the Encoder Handler’s are differnet from 1 and 2. like everything above 2 are differnet. is tehre something special about them? thx for all the help.

The descriptions for the different encoder handlers are in the encoder_readme.txt file included with the code.

I am not sure exactly how to wire up the sensor since i have not yet wired it up myself and have not yet done the research on how to do so.

To wire the sensor…

Take one end of a pwm cable, and solder it to J2, the black wire to GB (ground-black) the red wire to 5R (+5 volts-red) the white wire to SW (signal white). Connect the other end of this pwm to digital I/O 1.

Take a 2nd pwm cable and solder it to J1, the black wire to GB, the white wired to (12W), the red wire is unused. Connect the other end to a 20amp circut on one of your atc breaker panels.

Mount the sensor from .5 to 2.75 mm away from the gear to be measured.

Repeat this for the second one except connect it to digital I/O 2.

As for the code…
Use encoder 1 and encoder 2, disable the others. Then remove the “Phase B” logic in the interrupt handler for encoder 1 and encoder 2.

If you need more help PM me and I will try to clarify it better

Thx alot. il try to wire the senor.

Our code looks something like this for Encoder 1 and 2

void Encoder_1_Int_Handler(void)
{
// Encoder 1’s phase a signal just transitioned from zero to one, causing
// this interrupt service routine to be called. We know that the encoder
// just rotated one count or “tick” so now check the logical state of the
// phase b signal to determine which way the the encoder shaft rotated.
if(ENCODER_1_PHASE_B_PIN == 0)
{
Encoder_1_Count += ENCODER_1_TICK_DELTA;
}
}

#endif

#ifdef ENABLE_ENCODER_2

Would this work or not?

P.S. If I take away the #ifdef ENABLE_ENCODER_3 from the correct intrrupt would that correctly disable ENCODERS 3 -6. If not was would be the correct way for doing this.

Reading these posts seems to confirm my thoughts that this sensor doesn’t provide rotation direction information. CW or CCW This of course does not render this a useless sensor as one is often powering the motor from which sensor data is being generated. Meaning you already know its rotation and just need rotational speed for closed-loop feedback.

Well the sensor is quiet more usuful than that if we can get it to work.
It will provide us with a tooth count with which we can cross reference the speed of the motors and figure out what kind of a distance we traveled.

That is if we can get it to work =\

It took us a few tries last year to find and correct a small problem with this idea. When turning a small amount, the output from the direction PID can sometimes be too small to get out of the Victor deadband on one side of the 'bot but still drive the other side. What happens is that the entire robot moves forward, while the feedback routine is assuming it’s turning in place. We had to ensure that we always applied a high enough control value to the Victors to actually make the motors move in the desired direction.

A few questions:

  • How does the entire 'bot move forward with only one motor out of the deadband? I would think it would turn around that wheel.
  • In concert with the GTS, shouldn’t the I term correct for this? (since the wheel in theory shouldn’t be moving if the signal isn’t enough to turn the motor)
  • Just out of curiosty, what is this PID loop for? Is it used during autonomous or driver control?
    Thanks,
    Robinson

Actually the sensor does provide you with rotation direction information, but it is not easy, nor worth while to obtain IMO. You would need to measure the length of the pulse width of the signal. In the sensors datasheet it does say what the lengths of the pulse widths are. They are different for forward moving(CW) and reverse moving(CCW).

One of our programming mentors read this and I just can’t get my head around how this works if the sprocket teeth are symetrical:confused: Maybe a picture would help. Does the spec sheet have one?

APS

First here’s the datasheet
http://www.allegromicro.com/datafile/0642.pdf

Try to think of it this way…

When the gear is moving forward (CW), as a tooth passes, the digital signal from the GTS goes high (0 to 1 or off to on) and stays high for a specified length of time and then turns off.

When the gear is moving backward(CCW), as a tooth passes, the digital signal from the GTS goes high (0 to 1 or off to on) and stays high for a specified length of time and then turns off.

What is different between the two is the length of the time that the signal remains high. So besides noting the interrupt or the transition from 0 to 1, you would now also need to know the length of time it remained one.

Thus by knowing the time the signal reamained one, based on the datasheet you would know the direction. There is a time range for sensing forward, and a different time range for reverse. Last years sensor was 45microseconds(CW) for forward and 90microseconds(CCW) for reverse.

I hope this helps.

The GTS in the 2006 Kit of Parts did that. The 2007 one does not. The Allegro part on the board is different.

A well-built four- or six-wheel drivebase will tend to go straight when a forward force is applied to it at any location. Imagine a skateboard – when you push off with a foot to one side, you still go the way the wheels are pointing.

The PID control was only used for positioning during autonomous, though the code originally also had the ability to use speed control instead of power control for normal operation. I have yet to find a driver who prefers that option.