|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Coding the Gear Tooth Sensor
We need help with the code to the sensor. We have tried many things but cannot get it to function. If you can help it is greatly appreciated.
This is our code if (rc_dig_in05 > 0) { counter = counter + 1; } printf("counter %d", counter); And it still won't count. p.s. Please show us some code. Last edited by compwiz2008 : 31-01-2008 at 17:59. |
|
#2
|
||||
|
||||
|
Re: Coding the Gear Tooth Sensor
First, a question - do you have digital_io_05 set as an input? if not, that may be part of your problem...
Next, i would highly recommend using Kevin Watson's encoder code (see the sticky at the top of the forum) for doing the gear tooth sensors. It needs a small amount of modification, but not much, and it sets up the GTS as interrupts, which help ensure you won't miss information. If your code above is in the main user part of your code, the line will only execute once every 26.2ms, which may or may not fall on a pulse from the GTS. an Interrupt, however, will force the code to be called to increment the counter every time the input changes from a 0 to a 1, so you shouldn't miss any information from the GTS. |
|
#3
|
||||
|
||||
|
Re: Coding the Gear Tooth Sensor
Try ROBOTC... it takes care of handling the encoders as interrupts without any additional coding and is easier to use than MPLab!
|
|
#4
|
||||
|
||||
|
Re: Coding the Gear Tooth Sensor
When you say "Doesn't count", do you mean the output displays only zero, or some other crazyness?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Gear Tooth Sensor | Maria*61806* | Electrical | 0 | 30-01-2008 09:07 |
| Gear Tooth Sensor | Zoom | Programming | 46 | 22-01-2008 08:05 |
| How do you wire the gear tooth sensor? | 1594code | Electrical | 5 | 12-01-2008 16:24 |
| Quick question regarding the gear tooth sensor... | Brad Voracek | Electrical | 3 | 12-01-2007 01:07 |
| Mounting the Gear Tooth Sensor??? | blue_crew | Electrical | 3 | 09-02-2006 13:53 |