Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user IcePic ! (Registered 2024-12-03) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Accurately Measuring Drive RPM
2020-08-03 16:07
chatGPZ

Registered: Dec 2001
Posts: 11379
Accurately Measuring Drive RPM

To bring the discussion from 1541 Speed Test into the forum....

first lets recapitulate:

The general idea is: have a "marker" on a track, then measure the time for one revolution using timers. Generally there are different ways to achieve this:

- wait for the marker and toggle a IEC line. the C64 measures the time using CIA timer. this is what eg the well known "Kwik Load" copy does, the problem is that it is PAL/NTSC specific, and it can never be 100% exact due to the timing drift between drive and C64.

- wait for the marker and measure the time using VIA timers on the drive. the problem with this is that VIA timers are only 16bit and can not be cascaded, so you either have to measure smaller portions at a time, or rely on the wraparound and the value being in certain bounds at the time you read it.

now, to make either way slightly more accurate, a special kind of reference track can be used. typically this track will contain nothing except one marker - which makes the code a bit simpler and straightforward. this is what 1541 Speed Test does. the DOS also does something similar when formatting, to calculate the gaps. This obviosly has the problem that we are overwriting said track.

Now - the question isn't how to do all this, that's a solved problem. The question is, given a specific implementation, how *accurate* is it actually, and why?

The basic math to calculate the RPM is this:

expected ideal:
300 rounds per minute
= 5 rounds per second
= 200 milliseconds per round
at 1MHz (0,001 milliseconds per clock)
= 200000 cycles per round

to calculate RPM from cycles per round:
RPM = (200000 * 300) / cycles

two little test programs are here: https://sourceforge.net/p/vice-emu/code/HEAD/tree/testprogs/dri.. ... the first reads timer values between each sector header and then the total time for a revolution is accumulated from the delta times. the second leaves the timer running for one revolution and then indirectly gets the time for a revolution from that. to my own surprise, both appear to be accurate down to 3 cycles (in theory the second one should be more accurate, at least thats what i thought. i also expected some more jitter than just 3 cycles)

1541 Speed Test writes a track that contains one long sync, and then 5 regular bytes which serve as the marker. it then reads 6 bytes and measures the time that takes, which equals one revolution. somehow this produces a stable value without any jitter, which was a bit surprising to me too (i expected at least one cycle jitter, due to the sync waiting loops) (i am waiting for the source release and will put a derived test into the vice repo too)

So, again, the question is... how accurate are those and why? (a stable value alone does not tell its accurate). Some details are not quite clear to me, eg if we are writing a reference track, how much will that affect the accuracy of the following measurement? how will the result change when the reference track was written at a different speed than when doing the measuring? Will using a certain speedzone make it more or less accurate?

Bonus question: can we use https://en.wikipedia.org/wiki/Chinese_remainder_theorem with two VIA timers to make this more accurate? or is it a pointless exercise?
 
... 263 posts hidden. Click here to view all posts....
 
2020-08-11 15:39
Zibri
Account closed

Registered: May 2020
Posts: 304
About the crystal.
The average 16MHZ crystals in 1541 have 50ppm deviation.
That is 50 clock cycles "jitter" over 16 million which translates to 3.125 cycles over one million.

And that's why it's irrelevant to the measurement.

If what you wrote until now was true (I suspect some calculation error), there would be errors all over the place since a BIT can last 4 (cycles at 1mhz) (at the slowest clock) to as little as 3.25 (cycles at 1mhz).

Probably I am not using the right terminology, but something here is not right.

I see no such deviations anywhere.
The maximum "jitter" I saw in a directly connected motor was of 0.01 and was probably induced by a very stiff new disk.
2020-08-11 15:40
tlr

Registered: Sep 2003
Posts: 1787
Quoting Krill
Quoting Zibri
Quoting Commodore service manual
The drive speed is measured by writing a sync mark on a track which is outside the normal range
of the system and measuring the time (to 100 micro-second accuracy) the period of each revolution.
The only difference is that they used a SYNC mark which gave their program less accuracy than mine.
Pretty sure the 100 cycles of accuracy don't come chiefly from using a SYNC mark (7 cycles poll loop) vs BVC * (3 cycles poll loop) but more significantly from the discussed oscillator tolerance.

That's a very good point! I didn't realise the significance of that statement.

100 us (+/- 50 us) would be explained by a frequency tolerance of around +/- 250ppm if I'm not miscalculating.
2020-08-11 15:43
tlr

Registered: Sep 2003
Posts: 1787
Quoting Zibri
About the crystal.
The average 16MHZ crystals in 1541 have 50ppm deviation.
That is 50 clock cycles "jitter" over 16 million which translates to 3.125 cycles over one million.

Where did you get the 50ppm (+/- 50ppm?) specification? The parts lists all seem to just specify "16 MHz crystal" or "16 MHz crystal oscillator".

Also, +/- 50 ppm would translate to +/- 10 cycles per nominal rotation, no?
2020-08-11 15:46
chatGPZ

Registered: Dec 2001
Posts: 11379
Quote:
Where did you get the 50ppm (+/- 50ppm?) specification?

indeed, it sounds very precise for that era. citation needed :)
Quote:
That is 50 clock cycles "jitter" over 16 million

https://en.wikipedia.org/wiki/Parts_per_million
2020-08-11 15:52
tlr

Registered: Sep 2003
Posts: 1787
Quoting Zibri
Probably I am not using the right terminology, but something here is not right.

I see no such deviations anywhere.
The maximum "jitter" I saw in a directly connected motor was of 0.01 and was probably induced by a very stiff new disk.

The terminology isn't the most important, the concepts are. From your last statement I suspect what the misconception is. The accuracy of the crystal (i.e +/- x ppm) is something that is fairly constant to each individual crystal. Some will be +10ppm, some -100ppm, some + 25ppm, and so on... They will _not_ sweep around randomly within that interval, hence the _precision_ is much better.
The important point is that these are two completely different aspects of the crystal's behaviour.
2020-08-11 15:55
Krill

Registered: Apr 2002
Posts: 2971
Quoting Zibri
If what you wrote until now was true (I suspect some calculation error), there would be errors all over the place since a BIT can last 4 (cycles at 1mhz) (at the slowest clock) to as little as 3.25 (cycles at 1mhz).
[...]
The maximum "jitter" I saw in a directly connected motor was of 0.01 and was probably induced by a very stiff new disk.
Note that the oscillator's frequency changes very slowly over time, and also that it might be quite stable at some frequency close to but not quite at 16 MHz sharp.
It will not produce "jitter" as in something you can see flicker in a short amount of time.

It will still cause an error in measurement of the absolute RPM figure with regard to a clock that is more precise than the oscillator.
2020-08-11 15:55
chatGPZ

Registered: Dec 2001
Posts: 11379
Yeah, over time the deviation will only change a little bit, and slowly - see Unseens diagram.
2020-08-11 16:08
Krill

Registered: Apr 2002
Posts: 2971
Quoting Groepaz
Yeah, over time the deviation will only change a little bit, and slowly - see Unseens diagram.
About that... this is from power-up of a cold device, then idling in room temperature while the oscillator asymptotically approaches zero deviation? Needs a bit more context, i'm afraid.
2020-08-11 16:11
chatGPZ

Registered: Dec 2001
Posts: 11379
Its exactly that :) deviation from 16Mhz on Y and seconds after powerup on X (so roughly 2.5h)
2020-08-11 16:11
tlr

Registered: Sep 2003
Posts: 1787
Quoting Krill
Quoting Groepaz
Yeah, over time the deviation will only change a little bit, and slowly - see Unseens diagram.
About that... this is from power-up of a cold device, then idling in room temperature while the oscillator asymptotically approaches zero deviation? Needs a bit more context, i'm afraid.

...and it would be good form to state roughly which setup was used to measure it. I assume Unseen did it right, but if done wrong, some of the curve could easily come from the test equipment itself.
Previous - 1 | ... | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Guests online: 94
Top Demos
1 Next Level  (9.7)
2 What Is The Matrix 2  (9.7)
3 13:37  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.7)
6 Mojo  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Wonderland XIV  (9.6)
10 Comaland 100%  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Libertongo  (9.5)
6 Rainbow Connection  (9.5)
7 Dawnfall V1.1  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 It's More Fun to Com..  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Nostalgia  (9.3)
5 Triad  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Veto  (9.6)
3 Facet  (9.6)
4 The Sarge  (9.6)
5 Carrion  (9.5)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.058 sec.