Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Coding the Gear Tooth Sensor (http://www.chiefdelphi.com/forums/showthread.php?t=62989)

compwiz2008 31-01-2008 17:57

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.

Jon Stratis 31-01-2008 18:17

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.

timville 31-01-2008 19:52

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!

xrabohrok 01-02-2008 15:17

Re: Coding the Gear Tooth Sensor
 
When you say "Doesn't count", do you mean the output displays only zero, or some other crazyness?


All times are GMT -5. The time now is 23:52.

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