We have coded the gear tooth sensor correctly (at least according to what everything says). They are wired correctly too but we get inaccurate and random readings from them.
We have the sensors placed correctly, approx. 1mm away, and it senses to gear but it seems to be random. No pattern has been found to how it reads the pulses so we can’t even work around that.
Has anybody else had this issue or are we just doing something wrong?
well, we are encountering the similiar problem, We also connected everything right, and connected the snsor in Digital INput 1,also the code is fine.but when you run the code, The terminal window gives 0 values from E1 to E6.But cant find the problem
Thanx a lot.
Bilal Shahid
Team 1219.
Do you have a good backup battery plugged in when you are doing these tests? The GTS use both the 12 VDC from the main battery and the 5 VDC from the digital input. We made this mistake last weekend and found that one GTS seemed to work fine with no backup battery while the second would not.
Charlie
What code are you using to read the sensor? You claim it’s correct, but it would help if we could verify that for ourselves.
Can you observe the GTS output directly using an oscilloscope? Doing that could either point to or rule out hardware problems.
Our Team is using the IFI Default Code and have the counter in user_routines_fast.c. We have the Gear Tooth Sensor plugged into rc_dig_in01 and are using the interrupt code that comes with the user_routines_fast.c default code.
#pragma code
#pragma interruptlow InterruptHandlerLow save=PROD /* You may want to save additional symbols. */
void InterruptHandlerLow ()
{
unsigned char int_byte;
if (INTCON3bits.INT2IF && INTCON3bits.INT2IE) /* The INT2 pin is RB2/DIG I/O 1. */
{
INTCON3bits.INT2IF = 0;
}
else if (INTCON3bits.INT3IF && INTCON3bits.INT3IE) /* The INT3 pin is RB3/DIG I/O 2. */
{
INTCON3bits.INT3IF = 0;
}
else if (INTCONbits.RBIF && INTCONbits.RBIE) /* DIG I/O 3-6 (RB4, RB5, RB6, or RB7) changed. */
{
int_byte = PORTB; /* You must read or write to PORTB */
INTCONbits.RBIF = 0; /* and clear the interrupt flag */
} /* to clear the interrupt condition. */
else
{
CheckUartInts(); /* For Dynamic Debug Tool or buffered printf features. */
}
}
Our Counter Code is:
if (rc_dig_in01 >0) {
counter = counter + 1;
}
Thanks for showing us your code. As I feared, it confirms that you aren’t doing it correctly.
Note that the default interrupt handler doesn’t do anything except clear the interrupt when your GTS sends its pulse:
if (INTCON3bits.INT2IF && INTCON3bits.INT2IE) /* The INT2 pin is RB2/DIG I/O 1. */
{
INTCON3bits.INT2IF = 0;
}
You’ll need to add a line in there to increment your counter.
Our Counter Code is:
if (rc_dig_in01 >0) {
counter = counter + 1;
}
The input pulse from the GTS is very short. You’ll not be able to catch it reliably that way. You have to put the counter increment into the interrupt service routine.
Look at Kevin Watson’s encoder support files ( http://www.kevin.org/frc ) to see an example of how to initialize the interrupt, update the counter value, and read the value while protecting it from being changed in the middle of being read.
What part of kevin’s code do I actually need? It looks to me that I need everything in encoder.c, the interrupts in ifi_frc.c, and ADC.c from kevin’s files, which I don’t even understand why I need that one. We’re trying to use IFI’s default code and want to make the encoder code as simple as possible. could anyone please give us some code that works with IFI’s Default Code
If you want to use the Gear Tooth Sensor with the IFI default code, it will probably be easiest to follow the detailed directions from Kevin Watson’s encoder support code. To start with, select an unused digital input for the Phase B signal. Later, once you’ve verified that it works, you can investigate changing the interrupt service routine to remove the Phase B test entirely.