From 2aa308efddf737a31fd72b5f742a0b8cc9963b96 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 30 Jul 2019 16:18:36 -0400 Subject: [PATCH] Tweaks magic formulas. The computer now at least seeks outward, until this attempt at drive speed calculation fails. --- Components/DiskII/MacintoshDoubleDensityDrive.cpp | 2 +- Machines/Apple/Macintosh/DriveSpeedAccumulator.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Components/DiskII/MacintoshDoubleDensityDrive.cpp b/Components/DiskII/MacintoshDoubleDensityDrive.cpp index b41ac1570..9f5a04b32 100644 --- a/Components/DiskII/MacintoshDoubleDensityDrive.cpp +++ b/Components/DiskII/MacintoshDoubleDensityDrive.cpp @@ -30,6 +30,7 @@ DoubleDensityDrive::DoubleDensityDrive(int input_clock_rate, bool is_800k) : // MARK: - Speed Selection void DoubleDensityDrive::did_step(Storage::Disk::HeadPosition to_position) { +// printf("At track %d\n", to_position.as_int()); // The 800kb drive automatically selects rotation speed as a function of // head position; the 400kb drive doesn't do so. if(is_800k_) { @@ -144,7 +145,6 @@ bool DoubleDensityDrive::read() { case CA1|CA0|SEL: // Tachometer. // (arbitrary) -// printf("."); return get_tachometer(); case CA2: // Read data, lower head. diff --git a/Machines/Apple/Macintosh/DriveSpeedAccumulator.cpp b/Machines/Apple/Macintosh/DriveSpeedAccumulator.cpp index 6ab4223a0..2353501dd 100644 --- a/Machines/Apple/Macintosh/DriveSpeedAccumulator.cpp +++ b/Machines/Apple/Macintosh/DriveSpeedAccumulator.cpp @@ -23,12 +23,12 @@ void DriveSpeedAccumulator::post_sample(uint8_t sample) { if(sample_pointer_ == samples_.size()) { sample_pointer_ = 0; - // Treat 35 as a zero point and count zero crossings; then approximate + // Treat 33 as a zero point and count zero crossings; then approximate // the RPM from the frequency of those. size_t first_crossing = 0, last_crossing = 0; int number_of_crossings = 0; - const uint8_t centre = 35; + const uint8_t centre = 33; bool was_over = samples_[0] > centre; for(size_t c = 1; c < 512; ++c) { bool is_over = samples_[c] > centre; @@ -41,13 +41,14 @@ void DriveSpeedAccumulator::post_sample(uint8_t sample) { } if(number_of_crossings) { - // The 654 multiplier here is a complete guess, based on preliminary + // The 1950 multiplier here is a complete guess, based on preliminary // observations of the values supplied and the known RPM selections of // the 800kb drive. Updated values may be needed. - const float rotation_speed = 654.0f * float(number_of_crossings) / float(last_crossing - first_crossing); + const float rotation_speed = 1950.0f * float(number_of_crossings-1) / float(last_crossing - first_crossing); for(int c = 0; c < number_of_drives_; ++c) { drives_[c]->set_rotation_speed(rotation_speed); } +// printf("RPM: %d crossings => %0.2f\n", number_of_crossings, rotation_speed, min, max); } } }