Scale fan setting to match PWM_F #20
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
When converting a fan speed percentage to an LSB byte written to the EMC2101 controller, the conversion should translate 100% to 2*PWM_F because the chip determines the PWM duty cycle that way.
The changes in this PR calculate and cache the byte value to use for 100% fan speed in the function
_calculate_full_speed(). This cached full speed value is recomputed wheneveremc.pwm_frequencyoremc.dac_output_enabledare changed — these are the two registers affecting the value.When setting
emc.manual_fan_speedor one of the LUT values, the cached full speed value is used to compute the byte to be programmed into the chip. This means thatemc.pwm_frequencyshould always be set before programming the LUT or manual speed setting.My new oscilloscope arrived today (yay!), so I was able to test this code by measuring the duty cycle on the FAN pin. I tested 10% fan speed increments both with the default PWM frequency, and with
PWM_F=5which produces a 35 kHz PWM signal.Both PWM frequencies plot as a straight line. At 35 kHz, I measured a duty cycle about 0.75% less that the programmed value. I think this is caused by the 1 µs rise time on the open drain FAN pin.