# Disc reader project -- quick status update

Philip Pemberton classiccmp at philpem.me.uk
Tue Dec 8 18:41:07 CST 2009

```Keith M wrote:
> My amiga disk reader doesn't sample at all.  I look for falling edges of
> the pulses, clear a timer, look for the next edge, and calculate the
> time difference between two pulses.  The time between pulses define the
> data, and I write out the associated data pattern to memory.

I think that's more or less what everyone's doing. Measure dT between
samples, 1T is '01', 1.5T is '001', 2T is '0001'...

As far as data-extraction goes, I'm doing this:
1. Calculate the histogram of the data
2. Find the peaks in the histogram. Assume the first one is the raw
timing value for 1T (a 01 sequence).
3. Set 'T' to the timing value for the first peak.

For every timing value in the buffer:
a. Calculate the absolute difference between the timing value and 1T,
1.5T and 2T.
b. Compare the errors:
If the smallest error value is 1T, add '01' to the output buffer
If the smallest error value is 1.5T, add '001' to the output buffer
If the smallest error value is 2T, add '0001' to the output buffer
c. Update the timing value accordingly -- divide the timing value by
the reference multiplier (1T, 1.5T or 2T), then multiply the result by
"update_rate_frac" (between 0 and 1, typ. around 0.05, i.e. 5%).
d. Multiply T by (1 - update_rate_frac), then add the result from
step (c).
e. Repeat for all the data bytes.

The variable update threshold makes it possible to handle fairly large
variations in speed over time. Even a "mushy" histogram should decode
fine, as long as the 1T peak can be reliably detected. And therein lies
the rub -- at the moment, I'm just detecting the mean level of the
histogram, discarding anything below 10% of that, then detecting the
peaks with a slope-detect algorithm. There's probably a better solution,
but I haven't found it yet...

--
Phil.
classiccmp at philpem.me.uk
http://www.philpem.me.uk/

```