kaSCcCa

Portable ducted fan, 4 speed settings, 12V power supply, supports PD decoy + DC direct plug.

 
Overview
 
The fan used is a GFC0412DS, 40*40 cm in size. The price on Taobao is as follows: Mine was salvaged from another device
and is controlled by an 8-pin STC8G1K08A-36I-SOP8 microcontroller.
The button logic is
: 0 speed: stop (initial speed); 1 speed: slow; 2 speed: medium; 3 speed: high; 4 speed: fastest. The LED indicator light
illuminates
for 1 second after the microcontroller is powered on, then turns off. The LED flashes faster with each speed increase, until it remains lit at the highest speed. The firmware is attached.
For
board fabrication, choose version 78M05.
The solder mask layer on the back of the board has been removed; you can add solder to increase the current.
Source code reference:
#include
// Define ports #define FAN_POWER_PIN P32 #define LED_PIN P33 #define PWM_PIN P54 #define SWITCH_PIN P55
// Define PWM frequency #define PWM_FREQUENCY 25000
// Speed ​​definition #define GEAR_0 0 #define GEAR_1 1#define GEAR_2 2#define GEAR_3 3#define GEAR_4 4
// Define the duty cycle corresponding to the gear unsigned char duty_cycle[] = {0, 51, 102, 153, 255}; // Corresponds to 0%, 20%, 40%, 60%, 100%
unsigned char current_gear = GEAR_0; // Initial gear is 0
void delay_ms(unsigned int ms);void init_ports(void);void init_pwm(void);void set_pwm_duty(unsigned char duty);void switch_gear(void);
void main(void) { init_ports(); init_pwm(); FAN_POWER_PIN = 0; // Initially turn off the fan power // LED blinks for 1 second after power-on LED_PIN = 1; delay_ms(500); LED_PIN = 0; delay_ms(500); LED_PIN = 1; delay_ms(500); LED_PIN = 0;
    while(1) { if (SWITCH_PIN == 0) { // Detect microswitch pressed delay_ms(20); // Debounce if (SWITCH_PIN == 0) { switch_gear(); while (SWITCH_PIN == 0); // Wait for button release } } if (current_gear == GEAR_0) { FAN_POWER_PIN = 0; LED_PIN = 0; } else { FAN_POWER_PIN = 1; set_pwm_duty(duty_cycle[current_gear]); if (current_gear == GEAR_4) { LED_PIN = 1; // LED stays on at the highest gear } else { LED_PIN = !LED_PIN; // LED blinks at other gears delay_ms(1000 / current_gear); // The higher the gear, the faster the flashing } } }}
void delay_ms(unsigned int ms) { unsigned int i, j; for (i = ms; i > 0; i--) { for (j = 112; j > 0; j--); }}
void init_ports(void) { P3M1 = 0x00; P3M0 = 0xFF; P5M1 = 0x00; P5M0 = 0x30;}
void init_pwm(void) { // Configure the PWM module, set the frequency to 25kHz // Assume the system clock is 24MHz PCA_PWM0 = 0x00; // Clear the PCA register PCA_PWM1 = 0x00; // Clear the PCA register CMOD = 0x02; // Set the PCA counter's operating clock source to system clock/2 CL = 0; // Clear the counter CH = 0; // Clear the counter CCAP0L = 0x00; // Set the initial duty cycle to 0% CCAP0H = 0x00; // Set the initial duty cycle to 0% CCAPM0 = 0x42; // Set the operating mode of PCA module 0 to PWM mode CR = 1; // Start the PCA counter }
void set_pwm_duty(unsigned char duty) { CCAP0L = duty; // Set the low byte of the duty cycle CCAP0H = duty; // Set the high byte of the duty cycle }
void switch_gear(void) { current_gear++; if (current_gear > GEAR_4) { current_gear = GEAR_0; }}
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-28 07:43:34
  • Help
  • Clearance ARM v8 emulator
  • How can I wake up by long pressing the power button?
  • How do I view memory in IAR? Why is it inconsistent with the registers?
  • Request the original IRDA agreement
  • 【Ask TI】TI M3

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号