Wheel Encoder

Hey Guys,

I have made a wheel encoder (to sense the wheel position) which gives me a logic level output, the encoder detects the holes in a wheel and generates a pulse every time a hole is detected. There are 6 holes in the wheel thus 6 pulses = 1 rotation. I need to use these pulses to determine the distance covered by the wheel, one very easy way to implement this would be to just interrupt on every rising edge and increment a variable by one every 6 interrupts. Are there other ways i can do this....using a PIC16F877

Suggestion will be highly appreciated Nav

Reply to
Nav2u
Loading thread data ...

If you are sure that your detector has no bounce (oscillations near a transition) then the method that you described is a simple and adequate method. But if noise is a factor, then you will have to consider either time-domain filtering or the use of multiple detectors to generate quadrature signals that can be decoded noise-free.

Robert Scott Ypsilanti, Michigan

Reply to
Robert Scott

Do you REALLY mean it generates a pulse once and only once every time a hole transits into the sensor, or do you REALLY mean that the output is x when the sensor - a light gate, I guess - is interrupted, and ~x when the sensor is not interrupted?

I suspect the latter, in which case you need to consider what happens in boundary conditions (e.g. if the wheel stops with half a hole inside the sensor).

Reply to
larwe

You should look to add a second optical sensor path, so you can do full quadrature counting. That allows you to go backwards, subtracting counts, and also the quadrature state engines are more edge-uncertainty tolerant. This also doubles the resolution for a given number of holes, and if you make the holes slots (not so simple..), then you can count also on both slot edges :)

-jg

Reply to
Jim Granville

It is only a waste if you need to be doing something else with your processor and this counting task is preventing it. I would not use a pre-scaler because that precludes the intelligent use of software time-domain filtering, should that become necessary. I hope your detector circuit has some hysteresis.

You mention capture mode. That may not be appropriate for this application, at least not all by itself. You have to ask yourself what would happen if the wheel slowed down so much that Timer 1 wrapped around between one sensor pulse and the next.

Robert Scott Real-Time Specialties

Robert Scott Ypsilanti, Michigan

Reply to
Robert Scott

Thankyou 4 ur input guys....please see the following link

formatting link
My circuit is basically an IR LED and an IR Phototransistor placed next to each other. The Phototransistor basiclly turns on as soon as the reflected IR light falls on the gate. Accuracy is not of much importance at the moment...all i need to do is have some sort of feedback system.

What are my options if i were to use a PIC....If i interrupt on every pulse i will waste a lot of processor time....Is there a way to interrupt every 6 pulses?....page 59

formatting link
of data sheet talks abt capture mode operating at every 4 pulses, could this be an option???

Thanks in advance

Reply to
Nav2u

The approach depends on the wheel speed and how often you need data. I am not familiar with the PIC but it probably has a counter/timer input. This may be better than an interrupt and software counting. At high speeds the interrupt overhead may be a problem. If you are getting lots of counts during your sampling interval counting pulses works well. If you are getting so many that your counter overflows you can extend the counter in software. I have used a second counter in the main loop that read the fast counter and if the new count was less than the previous count it incremented the software count. This has the advantage that the extended software counter doesn't have to be synchronizesd to the fast counter and you only have to be sure that you read the fast counter a couple of times between overflows.

If you don't get many counts a timer has better resolution. It gives you the time between pulses which you invert to get speed. If you have lots of memory a lookup table may be the way to invert the data. You also scale the input in the same table. I have written controls where I used both methods and picked the one with the best resolution.

- stephenvb

Reply to
stephenvb

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.