Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
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: 11327
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-12 19:23
Zibri
Account closed

Registered: May 2020
Posts: 304
Quoting Compyx
Quoting Zibri
In this version is also possible to disable/enable the reference track writing.


Yay! Amazing it only took 251 posts :)

Yep.. it takes time to comply to idiotic requests.
And that's just it.
The official version is still the first one.
2020-08-12 19:25
Zibri
Account closed

Registered: May 2020
Posts: 304
Quoting Joe
Lol, this is called trolling perhaps. But out of curiousity, what will you all guys do now when you found out measuring this and that from a drive named this and that on that and that revision of a computer. à quoi ça sert?

For me it was a programming exercise.
For a few people I know it is a good tool to asses the status of a drive when they buy it or when they fix one.
For some idiots was just an excuse for arguing about nothing.
Pick yours :D
2020-08-12 19:33
tlr

Registered: Sep 2003
Posts: 1777
Quoting Joe
Lol, this is called trolling perhaps. But out of curiousity, what will you all guys do now when you found out measuring this and that from a drive named this and that on that and that revision of a computer. à quoi ça sert?

:)

I guess there are a few interesting technical bits in here, although no major new techniques really materialized.

As for the accuracy of the crystals, I think the most interesting thing it could be used for is calibrating a transfer routine for a much faster block transfer, c64 to/from drive.

... oh, and it could be used to subtly improve a few emulation aspects.
2020-08-12 19:35
Joe

Registered: Apr 2002
Posts: 226
Great enough answer. Great work! I'm not picking one ;D I have the third pill ;D (The Exit without exit).
2020-08-12 20:10
Zibri
Account closed

Registered: May 2020
Posts: 304
Quoting Joe
Great enough answer. Great work! I'm not picking one ;D I have the third pill ;D (The Exit without exit).

LOL :D
2020-08-12 20:16
Oswald

Registered: Apr 2002
Posts: 5084
who would have thought that measuring drive RPM will be one of the best threads ever :D
2020-08-12 21:22
tlr

Registered: Sep 2003
Posts: 1777
Quoting Oswald
who would have thought that measuring drive RPM will be one of the best threads ever :D

Maybe you should write your own prg? Chicks dig measuring drive RPM!
2020-08-12 21:31
chatGPZ

Registered: Dec 2001
Posts: 11327
They also dig jittering =D
2020-08-12 22:06
Krill

Registered: Apr 2002
Posts: 2957
Quoting tlr
As for the accuracy of the crystals, I think the most interesting thing it could be used for is calibrating a transfer routine for a much faster block transfer, c64 to/from drive.
Please do elaborate. :)
2020-08-12 23:11
Zibri
Account closed

Registered: May 2020
Posts: 304
Small update:
I finally had time to do some testing of "rpm4.prg" and as I thoretically suspected, it works but it "misbehaves" if the speed difference is too big.
Starting the test att 300 gives bad results below 260 and vice versa.
This does not happen with the official version.
The official version does not "wait for a certain byte" to pass (like many of you implied) and it works.
RPM4.prg instead awaits for a certain byte to pass and it fails like many other programs out there.
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
bugjam
E$G/HF ⭐ 7
Mason/Unicess
Grue/Extend
Han
Zartan/Unit 5
Steffan/BOOM!
Acidchild/Padua
Case/Padua
Brush/Elysium
sebalozlepsi
Dipswitch/Up Rough
Neotec/Padua
Airwolf/F4CG
Guests online: 103
Top Demos
1 Next Level  (9.7)
2 Lethal Display 6  (9.7)
3 13:37  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Mojo  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Comaland 100%  (9.6)
10 Unboxed  (9.6)
Top onefile Demos
1 Dame Kitty and the M..  (9.8)
2 Layers  (9.6)
3 Party Elk 2  (9.6)
4 Cubic Dream  (9.6)
5 Copper Booze  (9.6)
6 Libertongo  (9.5)
7 Moving Balls  (9.5)
8 Rainbow Connection  (9.5)
9 Morph  (9.5)
10 Dawnfall V1.1  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Fossil  (9.3)
5 Nostalgia  (9.3)
Top Webmasters
1 Slaygon  (9.6)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

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