Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Critikill ! (Registered 2024-09-19) 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: 11290
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-05 20:34
chatGPZ

Registered: Dec 2001
Posts: 11290
Quote:
I didn't test all possible values, but I had similar results with the early versions of my program until I accidently reached metastability.

fixed
2020-08-05 20:46
Jammer

Registered: Nov 2002
Posts: 1333
Quoting Zibri
LOL! Me neither :D


I refer mainly to your purely narcissistic reactions which are really, really cringy :D With all respect to your knowledge on the field ;)
2020-08-05 22:00
tlr

Registered: Sep 2003
Posts: 1762
Quoting Zibri
The method has been already discussed but I can summurize it for you:

Test track creation:

1) create a test track made of all "1".
2) write 5 bytes (starting and ending with a 0) to the track.

Measurement:
1) skip "data" (not really needed but in a rare situation it can make the program fail)
2) read one byte and start (reset to FFFF) the timer.
3) read 5 bytes (the fifth will be the first we skipped)
4) stop the timer and send the value back to the front-end.

On the fron-t end side my program just subtracts 5 to the rotation time (because my program stops the time 5 cycles after the last read) then divide 6000000000 by the calculated time and get the integer part that will be 100 times the real value.

This is the method used and this is the only method that will give you this accuracy.

I understand the method, but I'd love an explanation on why it is more accurate.

When I've done speed tests in the past I've used the seek sector 0 appoach. Although it's obvious that your method of not actually checking the sync is different, it's not obvious to me as to why that makes a difference in result.

Quoting Zibri
And I find the rpm display beautiful and perfect for laboratory use since it can be read from far.

I agree, the presentation is nice.
2020-08-05 22:08
hedning

Registered: Mar 2009
Posts: 4696
I don't know shit about this, and should shut up, but I get strangly aroused by it, so keep on talking. :D

2020-08-05 22:11
Zibri
Account closed

Registered: May 2020
Posts: 304
Quote: Quote:
I didn't test all possible values, but I had similar results with the early versions of my program until I accidently reached metastability.

fixed


1) I never wrote such a thing.
2) I am not your beta (alpha) tester.
3) I don't agree with anything you said about this subject.

Sure you can use trick, fixes and patches. That happens when code is wrong.
My code has no fixes. No value corrections. It just counts right.

End of story.
I won't fuel anymore this useless debate.
I was hoping to find a different environment from which even learn something.
I just found some curious persons (and that's fine) and someone bragging without bringing a shred of code or evidente to his claims.
And filling the gaps with "I don't know why your program is stable or accurate" or other useless childish phrases.

I have to prove nothing to you or anyone else.
Prove my program is wrong or that there was a BETTER program before I released mine.
Or just shut up or continue this "debate" alone.
Bye bye
2020-08-05 22:15
chatGPZ

Registered: Dec 2001
Posts: 11290
_I_ was bragging? =D

Quote:
I understand the method, but I'd love an explanation on why it is more accurate.

When I've done speed tests in the past I've used the seek sector 0 appoach. Although it's obvious that your method of not actually checking the sync is different, it's not obvious to me as to why that makes a difference in result.

this.
2020-08-05 23:18
Silver Dream !

Registered: Nov 2005
Posts: 108
Quoting Jammer
I had no fuckin' idea that thread about measuring drive RPMs might be THAT exciting :D

I thought of suggesting the continuation of this mesmerising thread inside new demos' scrolltexts :-) Wow - nostalgia...
2020-08-06 03:50
Zibri
Account closed

Registered: May 2020
Posts: 304
Back to a serious discussion:

In all this mess I forgot to mention a major flaw of all
other rpm programs:
if the disk is formatted by a real drive which speed is set to let's say 290RPM, ALL tests will fail.

This behaviour can't be tested on an emulator because VICE always writes at 300RPM and fixed density.

Also, on real hardware is very difficult to test if a fluctuation or program error is real or is the drive speed fluctuating.

That's why I opted for writing a test track in a way that it is independent from the writing speed (i.e. it is dependent but in a way that is irrelevant to the result).
Same goes for all programs written before mine and that's why real test program used pre-mastered disks.

The "beauty" of my program is that it does not need a master disk (a disk mastered by a "perfect" drive) in order to give perfect results.

A faster drive will have a very different track geometry where SYNCS will be nearer to each other and data will be narrower.
By opposite, a slower one will have SYNCs further away from each other (and wider data in the middle).

Also: a slower drive creates "longer" tracks and a faster one creates shorter ones.

Even SYNCs will be shorter or longer depending on the writing speed.

P.S.
There "might" be another way (which I am studying) to achieve the same accuracy my program actually has and without writing a test track (even if I find nothing wrong in doing that).
Unfortunately emulators, including VICE will give false positives to my theory (it will work in emulators but maybe not on real drives).

We will see if my new theory is right (I strongly doubt that) then I will release a new version.
2020-08-06 04:35
Zibri
Account closed

Registered: May 2020
Posts: 304
Update:

I compiled a "wrong" version of RPM which I called "rpm2wrong.prg"
This version does not write a test track.
This version still is accurate as the previous one.

BUT

It is wrong as all "other" programs.
Even if in VICE it will give you perfect results.

A further proof:
It is true that vice writes at a fixed speed and density.
But it is also true that that speed is the speed of the drive who wrote (or extracted) the disk.

So, if you take the original version of ARCHON (for example) and convert it from NIB to G64, then you run the "wrong" program, you won't have 300 RPM but (in this case) 298 RPM.

Why? Because the drive used to extract ARCHON was slower!

Instead, if you run my RPM program, even on the same G64, it will continue to work and give you the actual speed of the reading drive.

I know these concepts are not immediately easy to understand. And the emulator complicates things.

I could easily say that my rpm2wrong.prg is working perfectly since it has no glitches, no jitter and it's still precise to the cent like the real version.

But... IT IS WRONG.

If anyone is interested I can give you a link to the wrong version and you can verify it works "flawlessly" in VICE.
Wher will it fail in the real world then?
It will fail if used on a disk which was not formatted by a perfect drive with no wobble and a steady speed of 300 RPM.

All clear?

Good night.
Zibri
2020-08-06 09:47
tlr

Registered: Sep 2003
Posts: 1762
Quoting Zibri
It is true that vice writes at a fixed speed and density.
But it is also true that that speed is the speed of the drive who wrote (or extracted) the disk.

So, if you take the original version of ARCHON (for example) and convert it from NIB to G64, then you run the "wrong" program, you won't have 300 RPM but (in this case) 298 RPM.

Why? Because the drive used to extract ARCHON was slower!

Instead, if you run my RPM program, even on the same G64, it will continue to work and give you the actual speed of the reading drive.
I'm assuming here that you are still measuring time (as opposed to capacity) with your new implementation. In that case, the actual _time_ cannot physically change if the (emulated) rotational speed is 300 rpm. The actual _amount of data_ per track can change however depending on the speed of the drive used to write it.

It looks to me that what you are seeing is the effect of a limitation (bug) in vice. If the emulated rotational speed is 300 and the actual _time_ before the data loops is longer than one revolution then this is obviously impossible. This could never happen on hardware.

You could try to run it in different emulators (e.g hoxs64) and see if it works differently.
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | ... | 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
Critikill
psych
REBEL 1/HF
Spinball/Excess
TFWP
dstar/Fairlight
Sentinel/Excess/TREX
Guests online: 86
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 Comaland 100%  (9.6)
8 Wonderland XIV  (9.6)
9 No Bounds  (9.6)
10 Unboxed  (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 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Morph  (9.5)
8 Dawnfall V1.1  (9.5)
9 Onscreen 5k  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Nostalgia  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.2)
Top Coders
1 Axis  (9.9)
2 Graham  (9.8)
3 Crossbow  (9.8)
4 Lft  (9.8)
5 HCL  (9.8)

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