We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: Roman Toropov
Last Updated: 2016-02-19
Package Version: 1.0.0.0
Example: 1.0.0.0
Category: Motor Control
Downloaded: 1954 times
Followed by: 3 users
License: MIT license
Control of fan speed depending on the temperature
Do you want to subscribe in order to receive notifications regarding "DC Fan speed control on ATtiny13 and DS18B20" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "DC Fan speed control on ATtiny13 and DS18B20" changes.
Do you want to report abuse regarding "DC Fan speed control on ATtiny13 and DS18B20".
DOWNLOAD LINK | RELATED COMPILER | CONTAINS |
---|---|---|
1367411264_dc_fan_speed_con_mikroc_avr.zip [124.05KB] | mikroC PRO for AVR |
|
// Roman Toropov
// Termostat source
char duty;
unsigned int temp2write;
void main() {
DDB0_bit = 1;
PWM1_Init(_PWM1_FAST_MODE, _PWM1_PRESCALER_1, _PWM1_NON_INVERTED, 0);
do {
Ow_Reset(&PORTB, 2); // Onewire reset signal
Ow_Write(&PORTB, 2, 0xCC); // Issue command SKIP_ROM
Ow_Write(&PORTB, 2, 0x44); // Issue command CONVERT_T
Delay_us(120);
Ow_Reset(&PORTB, 2);
Ow_Write(&PORTB, 2, 0xCC); // Issue command SKIP_ROM
Ow_Write(&PORTB, 2, 0xBE); // Issue command READ_SCRATCHPAD
temp2write = Ow_Read(&PORTB, 2);
temp2write = (Ow_Read(&PORTB, 2) << 8) + temp2write;
temp2write = temp2write >> 4 ;
// degrees Celsius in decimal form, natural number
if (temp2write > 37) { duty = (temp2write - 37) * 5 + 20; }
if (temp2write > 45) { duty = 255; }
if (temp2write < 38) { duty = 0; }
PWM1_Set_Duty(duty);
Delay_ms(3000);
} while (1);
}