davidgiven / fluxengine

PSOC5 floppy disk imaging interface
MIT License
352 stars 68 forks source link

Getting a different rotational speed with the same drive 5.25" HD 80 track drive but two different commands #303

Open wybren1971 opened 3 years ago

wybren1971 commented 3 years ago

when i use inspect i get following: (./fluxengine inspect -s drive:0) Measuring rotational speed... 200ms 0xec40 bytes of data in 239.305ms Required USB bandwidth: 246.809kB/s

Clock detection histogram: 37 3.08 46 ▎ 38 3.17 763 ████▉ 39 3.25 700 ████▌ 40 3.33 821 █████▎ 41 3.42 99 ▋ 42 3.50 42 ▎ 43 3.58 86 ▌ 44 3.67 32 ▏ ... 73 6.08 39 ▎ 74 6.17 383 ██▌ 75 6.25 2851 ██████████████████▋ 76 6.33 6121 ████████████████████████████████████████ 77 6.42 4352 ████████████████████████████▍ 78 6.50 747 ████▉ 79 6.58 253 █▋ 80 6.67 546 ███▌ 81 6.75 392 ██▌ 82 6.83 72 ▍ ... 115 9.58 38 ▏ 116 9.67 38 ▏ 117 9.75 610 ███▉ 118 9.83 3931 █████████████████████████▋ 119 9.92 6035 ███████████████████████████████████████▍ 120 10.00 2286 ██████████████▉ 121 10.08 154 █ ... Noise floor: 61 Signal level: 306 Peak start: 37 (3.08 us) Peak end: 42 (3.50 us) Median: 39 (3.25 us) 3.25 us clock detected.

en when i use rpm (./fluxengine rpm -s drive:0) i get: Rotational period is 167 ms (359.281 rpm)

How is this possible? and what is the rotational speed used by this drive? or can it switch the speed? but why would it?

do you have an explanation why the fluxengine client reports two different kinds of rotational speed with the same disk in it just another command (inspect vs rpm)?

davidgiven commented 3 years ago

That does indeed sound like a bug. You do only have one drive, right? It's not somehow picking different drives for the two commands (which is still a bug, but a more explicable one)?

wybren1971 commented 3 years ago

I have two drives connected and the selected drives led goes on... Tomorrow I will try with one drive connected. Just to see if it makes any difference.

wybren1971 commented 3 years ago

I disconnected the powercable to my 3.5 inch floppy drive and got exactly the same results. rpm reports 360rpm and 166ms and inspect reports 200 ms.

No idea why... do they use a different algorithm?

davidgiven commented 3 years ago

Nope, they both call the same routine on the firmware, so they should produce the same result. Clutching at straws here, but you don't have a hard-sectored disk in the drive, do you? Or any kind of exotic index pulse generator? It all works fine for me:

$ ./fluxengine rpm -s drive:0
Rotational period is 166 ms (361.446 rpm)
dg@hilfy:~/nonshared/fluxengine$ ./fluxengine inspect -s drive:0 -c 0 -h 0
Measuring rotational speed... 166ms
0x12700 bytes of data in 199.085ms
Required USB bandwidth: 370.445kB/s
wybren1971 commented 3 years ago

No i don't have a hard sectored disk (i think). the only 5.25" disks i have are commodore 64 disks (double side double density). Commodore drives work at 300 rpm, so the disk in the drive is written at 300 rpm but that doesn't explain why the same routine in firmware gives two different results with the same commdore 64 disk in the drive.. I also tried with an empty DSDD disk and got the same results. rpm reports 167ms and inspect reports 200ms. I have a fluxengine board with the latest firmware on it and the latest fluxengine client. (yesterday that is;-) Well if i find another 5.25 disk i will try that one and see what i get. I don't understand either. However everything works fine (writing and reading commodore 64 disks). i send you a commodore 64 disk i use with the 40 track drive if you reply to my email for the address to send it to.

wybren1971 commented 3 years ago

I tested today with a greaseweazle attached and got the following results for just the inspect command:

./fluxengine inspect -s drive:1 --usb.greaseweazle=/dev/ttyACM0 i get 149 ms each time and with the following command: ./fluxengine inspect -s drive:1 -c 1 -h 0 -B --usb.greaseweazle=/dev/ttyACM0 i get 199 ms... i dont understand why there is a difference. May be it gives you some more insight in the problem.

the rpm command (./fluxengine rpm -s drive:1 --usb.greaseweazle=/dev/ttyACM0) gives me the following result: Rotational period is 166.449 ms (360.47 rpm)

I used the latest fluxengine source (today). Hope this gives you some clue as to where to look. i suspect the -B option had something to do with it.

The disk in the drive is a commodore1541 disk formatted bu a commodore64.

Greetings Wybren

wybren1971 commented 3 years ago

After analyzing the code i noticed that in fe-rpm.cc the following function gets called: usbSetDrive(config.flux_source().drive().drive(), false, config.flux_source().drive().index_mode()); and in hardwarefluxsource.cc this function gets called this way: usbSetDrive(_config.drive(), _config.high_density(), _config.index_mode()); changing _config.high_density() to "false" in hardwarefluxsource.cc results in the two commands giving the same rotational speed. I don't know which of the two usbsetdrive is the correct one, but i hope you know.

Greetings Wybren

wybren1971 commented 3 years ago

another thing that puzzled me. there are two configurations: _config.high_density() and _config.has_high_density() or config.flux_source().drive().high_density() and config.flux_source().drive().has_high_density() Which of these two (high_density or has_high_density) is the appropriate one. because i have a low density disk in my high-density drive...

well hope this helps you in sorting the problem...

davidgiven commented 3 years ago

I wonder if the drive is changing speeds based on the density pin? From 360 to 300rpm or vice versa? Although that doesn't really make much sense to me as standard DD disks spin at 360rpm...

The flux_source/flux_sink versions of the high_density flag should be the correct one --- will fix; thanks.

wybren1971 commented 3 years ago

I don't understand either. all i know is that in fe-rpm the density setting is always false and in the hardwarefluxsource.cc the density is given by a variable and not hence not always false. Changing that variable to false results in the same outcome, hence my conclusion that the problem originates there. i don't know what the solution is and what the influence of the high density pin setting is on the measurement. Hope this helps you in fixing it.

what is the difference between config.flux_source().drive().high_density() and config.flux_source().drive().has_high_density()?

wybren1971 commented 3 years ago

i searched online and found that there are 5.25 drives who:

This drive is a high-density, dual speed, double-sided 5.25" mini-floppy disk drive. The speed is controlled by Pin 2 of the interface connector. Normally, when this pin is at logical low, the transfer rate is low and when at logical high, the transfer rate is high. This drive can be used as a high-density 1.6Mb drive. When at logical low, this drive can be used as a standard 1.0Mb drive.

so your assumption on the drive changing speeds based on the density pin is a valid one... the issue is also referenced here

and it seems my drive does change the rotation speed based on the setting of the density pin. hence the two different rotation speeds reported.