Fan control troubleshooting Microcontroller Programming

8,393

Circuit Image

Control a fan using an LM34 temperature sensor and a computer fan with model number ASB0912L. A 2N7000 MOSFET transistor is utilized as a switch. The fan is intended to operate at a 35% duty cycle when the temperature exceeds 77°F and at a 0% duty cycle when the temperature is at or below 77°F. The provided code, however, results in the fan running continuously.

The circuit design involves a temperature control system that regulates the operation of a fan based on temperature readings from an LM34 temperature sensor. The LM34 sensor provides an analog output that is proportional to the temperature in Fahrenheit. The microcontroller used in this design is the ATmega168, which processes the sensor's output and controls the fan's operation through a PWM signal.

The fan, identified as ASB0912L, is a standard computer fan that operates efficiently with PWM control. The 2N7000 MOSFET serves as a switch, allowing the microcontroller to turn the fan on and off based on the PWM signal. When the temperature exceeds the threshold of 77°F, the microcontroller sets the PWM output to a value that corresponds to a 35% duty cycle, providing sufficient power to the fan. Conversely, if the temperature is at or below 77°F, the PWM output is set to 0%, effectively turning off the fan.

The program begins by defining essential constants and includes necessary libraries for handling I/O operations, analog-to-digital conversion, and PWM generation. The `pwm_init()` function configures the timer for Fast PWM mode, allowing for smooth control of the fan speed. The `adc_init()` function initializes the analog-to-digital converter, setting it up to read the output from the LM34 sensor.

The `adc_read()` function retrieves the current temperature reading from the ADC, and the `sampleToFahrenheit()` function converts the ADC value into a temperature in Fahrenheit. The main loop of the program continuously checks the temperature, adjusts the PWM signal accordingly, and updates the fan's operation status.

This control system is designed to maintain a comfortable environment by automatically adjusting the fan speed based on real-time temperature readings, thereby optimizing energy consumption and improving comfort. Proper attention should be given to the code logic to ensure accurate temperature readings and PWM signal adjustments to avoid the issue of the fan running continuously.Control a fan using an LM34 temp sensor and a computer fan with model number : ASB0912L. I used a 2N7000 mosfet transistor as a switch. I want my fan to run at 35% duty cyle when the temperature is above 77 fahrenheit and to run at 0% duty cycle when temperature is equal to or less then 77 fahrenheit. I tried using the code below but the fan keeps running all the time. // fan_controller. c // for NerdKits with ATmega168 #define F_CPU 14745600 #define PWM_fanspeed_2 12915 //For 7ms high time = 35% duty cycle #define PWM_fanspeed_START 0 #include #include #include #include #include #include #include ". /libnerdkits/delay. h" #include ". /libnerdkits/lcd. h" #include ". /libnerdkits/uart. h" // PIN DEFINITIONS: // // PC0 - temperature sensor analog input //Denne funksjonen velger sammenlingningsverdien til telleren void pwm_set(uint16_t x) { OCR1B = x; } //Denne funksjonen setter opp instillingene for FAST PWM mode 15 void pwm_init(){ //Setter perioden til G¥ vGre 20 ms OCR1A = 36864; //Setter servoen til midtposisjon pwm_set(PWM_fanspeed_START); /* //Har under skrevet til to ulike registre for G¥ aktivere dei forskjellige instillingene //Skriver til registeret TCCR1B for G¥ sette opp prescaleren til 8.

TCCR1B = (1<
🔗 External reference




Warning: include(partials/cookie-banner.php): Failed to open stream: Permission denied in /var/www/html/nextgr/view-circuit.php on line 713

Warning: include(): Failed opening 'partials/cookie-banner.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/nextgr/view-circuit.php on line 713