1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-10-01 13:58:20 +00:00

Tweaks magic formulas.

The computer now at least seeks outward, until this attempt at drive speed calculation fails.
This commit is contained in:
Thomas Harte 2019-07-30 16:18:36 -04:00
parent 74c18d7861
commit 2aa308efdd
2 changed files with 6 additions and 5 deletions

View File

@ -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.

View File

@ -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);
}
}
}