On Sep 8, 2013, at 1:15 PM, Chris Elmquist <chrise at pobox.com> wrote:
On Saturday (09/07/2013 at 03:44PM -0700), Al Kossow
wrote:
On 9/7/13 12:57 PM, shadoooo wrote:
Clearly the 12-sectors will have 12 dents, while
the 16 -sectors 16 dents
Slots in the hub ring.
There are actually 13 and 17, one extra midway between the 12'th and 1'st for the
index.
I think your micro has to be a little smart and isolate the index
pulse from all the others and become synchronous with it. Then it
can synthesize the 12- or 16- sector pulses by simple "dead reckoning"
timing after using the leading edge of the index pulse as the trigger.
The sector to sector duration will be one value but the sector to index
duration will be half of that and then you know you just found the
index mark.
The micro then generates an outbound index pulse and the 12- or 16-
synthetic sector pulses, the first of which comes sooner than the others,
and then goes back to finding the next inbound index pulse... rinse
lather repeat.
That's actually not too far off from how digital TVs/monitors generate
the pixel clock from incoming sync lines; the assumption is that the
frequency of the pixel clock is an integer multiple of the horizontal
scan frequency (generally a safe assumption), so it multiplies the
horizontal scan up by the active pixels plus the effective blanking
pixels.
So just taking the index pulse time and dividing that time constant by
240, you'd have a time constant that could then be multiplied up by 15
(16-sector), 20 (12-sector) or even 10 (24-sector). Ideally, you'd go
for a multiplier of 480 instead, since it would let you get exactly
half a sector time off for the 16-sector case. Handy. You'd probably
need a higher-precision timer than most PICs offer, but it's been a
while since I've looked at the things they offer because I find them
to be rather distasteful, personally.
Either way, you could probably get it done with a very small amount of
code.
- Dave