Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Missing teeth with kit tooth counter (http://www.chiefdelphi.com/forums/showthread.php?t=42457)

Astronouth7303 22-01-2006 20:06

Missing teeth with kit tooth counter
 
I'm having problems with the kit tooth counters. I've attached one to digital input 1, enabled the interrupt, etc.

The interrupt works. But it seems to not fire all the time, like it's not firing all the time. When I get the value to the user by dashboard (User_Byte1), it doesn't increment every time it should.

We've also got the camera hooked up and operating. (The usage of the camera is not optional.)

The code I'm using is a stripped-down version of Kevin's encoder code. (Major stripped down.)

I'm not getting the red light o' death, or any other obvious signs of problems. I'm not using PWM13-16, I've made them all USER_CCP, and I'm linking with FRC_alltimers.lib.

Any recommendations on testing this, or possible causes? :confused:

Mark McLeod 22-01-2006 20:30

Re: Missing teeth with kit tooth counter
 
How fast, or what's the maximum rate, do you figure the interrupts are coming in?

There is a certain minimum time and tooth gap required to make the gear tooth sensors work properly.

Gdeaver 22-01-2006 21:02

Re: Missing teeth with kit tooth counter
 
Are you measuring gear teeth or sprocket teeth? The sensor orientation and air gap are critical. Look at the spec sheet to confirm the mounting position.
If you are trying to measure gear teeth, they maybe too fine for the sensor.

devicenull 22-01-2006 22:37

Re: Missing teeth with kit tooth counter
 
Make sure it's not the code.. From what I remember of last year, the encoders counts are "long"'s, while the user byte is an int. I'm not sure what would happen if you didn't explicitly cast it back to int with (int)encoder_count. I know I spent about a week trying to figure out a very similar problem, only to have it be that problem.

Biff 23-01-2006 00:45

Re: Missing teeth with kit tooth counter
 
We did test the tooth sensor before sending it off to programming. It's reading a 10 tooth #35 chain steel sprocket on a Cim shaft. My scope on the signal wire showed about 839 Hz when the motor was flat out. And clean waveforms in both directions. I will have to recheck to make sure that hasn't changed. In the mean time any help with the programming would be a great help. Thanks

Astronouth7303 23-01-2006 20:33

Re: Missing teeth with kit tooth counter
 
What Biff (our electrical mentor) said.

The estimated maximum rate is 700 Hz. It's a sprocket (not a gear).

I was asking in the programming forum because I'm pretty sure it's programming.

We managed to get it working for a bit (turned out I had forgotten to set the "use prescalar" bit on TMR0 :o ). But when I restored the code that revealed this, it ceased to count at all. (PWM value ~120.)

The basic idea of the code is that at the end of the slow loop, it starts TMR0 and enables the counters. When TMR0 goes off, it disables the counters and the timer, then copies the counts and clears them.

I'm using 0 printf()'s.

I'm pretty sure it's not the sizes because it's always 0 (not sometimes 1 or something), and I also used bytes 1-3 to display a different part of the count.

Joe Ross 23-01-2006 22:04

Re: Missing teeth with kit tooth counter
 
Have you verified it worked with Kevin's default code? It's best to start with a known good program.

Since it sounds like you're getting very deep into counters and timers and such, it's going to be virtually impossible to help you without seeing the code.

Astronouth7303 24-01-2006 16:08

Re: Missing teeth with kit tooth counter
 
Quote:

Originally Posted by Joe Ross
Have you verified it worked with Kevin's default code? It's best to start with a known good program.

I didn't realize kevin had code for tooth counters.

Quote:

Originally Posted by Joe Ross
Since it sounds like you're getting very deep into counters and timers and such, it's going to be virtually impossible to help you without seeing the code.

Aye. I did find the problem.

Basically, TMR0 was set to wait longer than 26.2ms, and every slow loop I restarted it. Meaning it never went off.

As it also turns out, the counts for the timer are also screwy. We're going to look at the whole system with an oscilliscope tonight.

(BTW, this isn't very clear from the PIC18 manual and 8722 datasheet. When using TMR0, and likely other 16-bit registers, you read the low byte first and the high byte second. Writing is the opposite way, write high byte first and low byte second.)


All times are GMT -5. The time now is 01:04.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi