|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
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? ![]() |
|
#2
|
|||||
|
|||||
|
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. |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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.
|
|
#5
|
|||
|
|||
|
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
|
|
#6
|
|||||
|
|||||
|
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 ). 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. |
|
#7
|
||||||
|
||||||
|
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. |
|
#8
|
|||||
|
|||||
|
Re: Missing teeth with kit tooth counter
Quote:
Quote:
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.) |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MISSING VIRTUAL KIT PARTS!!! | Hershey | Inventor | 3 | 20-01-2005 15:26 |
| Who is missing stuff from KOP? | Matthew_H | Kit & Additional Hardware | 52 | 05-02-2004 19:52 |
| Anyone missing as many parts as we are? | Drew Hopman | Technical Discussion | 4 | 19-01-2004 19:06 |
| Anyone missing the EDU kit? | Adam Shapiro | Kit & Additional Hardware | 3 | 11-01-2004 15:03 |
| missing kit parts | Stephen Kowski | Kit & Additional Hardware | 57 | 22-01-2003 12:27 |