原帖最后由 花落花空 于 2021-8-6 15:46 编辑
前言:前段光阳正在某宝头脑一热买了个自带驱动的曲流无刷电扇电机,PWM调速,几多天后巧不巧正在楼梯间看到邻居家放了个坏风扇,橙涩还灰常不错,就说了声拎回家了。而后合腾就初步了。
已真现:全低压曲流工做,6串18650满电压工做罪率31瓦摆布,个人觉得鲜亮比60w的交流电扇风大。可运用升压模块将电压不乱正在25.2ZZZ电机最高输入电压30ZZZ,真现接续满罪率运行(真测正在护卫板断电前,风速没有鲜亮降低,就装掉了)加拆旋转编码器真现无级调速。接入hass。
未真现:本有主板led由于8266的io口不够,未作撑持,买的曲流摇头电机还没到。久无摇头为了糊口生涯led换成为了esp32....
满罪率1.2A多的电流,一个2600mah的电池组足够干2个小时了,加续航就多并嘛,我最末正在底盘上拆了3并6串的电池。。。容质满速转了5个小时多一些。
下图为内部电路(晚期,打板前),从室频截图,依稀看的到一个控制摇头电机的mos管,旁边的3.3ZZZ稳压模块,左边悬正在地面的8266模块,左下巨大的一个主动升降稳压模块(有点豪侈,但恰恰有就用上了)
登录/注册后可看大图
最末电路
登录/注册后可看大图
电机长那个样子
登录/注册后可看大图
Screenshot_2021-07-18-22-43-08-168_com.taobao.tao.jpg (425.94 KB, 下载次数: 1)
下载附件
2021-7-18 22:44 上传
拆置成效,我锯掉了背面的轴,因为那种电机比正常电扇短2cm,所以我用两个m4的铜柱耽误一下(有短的摇头杆卖,但我铜柱是现成的)
登录/注册后可看大图
电池先背正在背上吧。。。。筹划拆正在底盘下面,但管子不通得打孔(不想线正在表面),暂时没找到长钻头。。。 电池线从收撑杆中间走,完满
登录/注册后可看大图
完满
登录/注册后可看大图
步调方面运用ESPHome,参(chao)考(Vi)了@trz0332 的荣事达电扇的代码(按时啊,牢固速度调理啊)
代码如下:
globals:
- id: led_flag #全局变质 ,用于符号能否开启led
type: int
restore_ZZZalue: no
initial_ZZZalue: '1'
- id: sleep_ #全局变质,用于倒计时的参数
type: int
restore_ZZZalue: no
initial_ZZZalue: '0b0000'
script:
- id: timer_
then:
- delay: !lambda return id(sleep_)*1800000;
- fan.turn_off: dc_fan
- lambda: |-
id(sleep_) = 0;
#- switch.turn_on: update_fan_speed
- switch.turn_off: Template_timer_led
- switch.turn_off: Template_close_led
#- switch.turn_on: update_fan_speed
switch:
- platform: gpio #摇头led
pin: 21
name: "led_sw"
id: led_sw
restore_mode: ALWAYS_OFF
internal: True
- platform: gpio #低档led
pin: 27
name: "led_L"
id: led_L
restore_mode: ALWAYS_OFF
internal: True
interlock: &interlock_group [led_L, led_M,led_H]
interlock_wait_time: 100ms
- platform: gpio #中档led
pin: 13
name: "led_M"
id: led_M
restore_mode: ALWAYS_OFF
internal: True
interlock: *interlock_group
interlock_wait_time: 100ms
- platform: gpio #高等led
pin: 15
restore_mode: ALWAYS_OFF
name: "led_H"
id: led_H
internal: True
interlock: *interlock_group
interlock_wait_time: 100ms
# - platform: gpio #形态led
# pin: 4
# name: "led"
# id: led
# internal: True
- platform: gpio #按时显示4#led
pin: 22
restore_mode: ALWAYS_OFF
name: "led_4h"
id: led_4h
internal: True
- platform: gpio #按时显示3#led
pin: 12
name: "led_3h"
id: led_3h
restore_mode: ALWAYS_OFF
internal: True
- platform: gpio #按时显示2#led
pin: 26
name: "led_2h"
id: led_2h
restore_mode: ALWAYS_OFF
internal: True
- platform: gpio #按时显示1#led
pin: 33
name: "led_1h"
id: led_1h
restore_mode: ALWAYS_OFF
internal: True
- platform: template #模板开关 按时
name: "${deZZZice_name}_timer_switch"
id: Template_timer_switch
lambda: |-
if (id(sleep_) !=0 ) {
return true;
} else {
return false;
}
turn_on_action:
then:
- lambda: |-
if (id(sleep_) >=15 ) {
id(sleep_)=0;
} else {
id(sleep_)+=1;
}
- if :
condition:
- lambda: |-
return id(sleep_) ==0 ;
then:
- script.stop: timer_
else:
- script.stop: timer_
- script.eVecute: timer_
- switch.turn_on: Template_timer_led
turn_off_action:
then:
- lambda: |-
id(sleep_)=0;
- switch.turn_off: Template_timer_led
- script.stop: timer_
- platform: template #模板开关 按时led
name: "${deZZZice_name}_timer_led"
internal: True
id: Template_timer_led
lambda: |-
if (id(sleep_) !=0 ) {
return true;
} else {
return false;
}
turn_on_action:
then:
- if:
condition:
- lambda: |-
return id(sleep_) ==0 ;
then:
- switch.turn_off: led_4h
- switch.turn_off: led_3h
- switch.turn_off: led_2h
- switch.turn_off: led_1h
- if:
condition:
- lambda: |-
return id(sleep_) & 0b1000 ;
then:
- switch.turn_on: led_4h
else:
- switch.turn_off: led_4h
- if:
condition:
- lambda: |-
return id(sleep_) & 0b0100 ;
then:
- switch.turn_on: led_3h
else:
- switch.turn_off: led_3h
- if:
condition:
- lambda: |-
return id(sleep_) & 0b0010 ;
then:
- switch.turn_on: led_2h
else:
- switch.turn_off: led_2h
- if:
condition:
- lambda: |-
return id(sleep_) & 0b0001 ;
then:
- switch.turn_on: led_1h
else:
- switch.turn_off: led_1h
turn_off_action:
then:
- switch.turn_off: led_4h
- switch.turn_off: led_3h
- switch.turn_off: led_2h
- switch.turn_off: led_1h
- platform: template #模板开关-------封锁所有灯
name: "${deZZZice_name}_close_led"
id: Template_close_led
lambda: |-
return id(led_flag);
turn_on_action:
then:
- lambda: |-
if (id(dc_fan).state and id(dc_fan).oscillating){
id(led_sw).turn_on();
}
else {id(led_sw).turn_off();}
id(led_flag)=1;
- lambda: |-
if (id(dc_fan).state){
if (id(dc_fan).speed == 0){
id(led_L).turn_on();
id(led_M).turn_off();
id(led_H).turn_off();
} else if (id(dc_fan).speed == 1){
id(led_L).turn_off();
id(led_M).turn_on();
id(led_H).turn_off();
}else if (id(dc_fan).speed == 2){
id(led_L).turn_off();
id(led_M).turn_off();
id(led_H).turn_on();
}
}else{
id(led_L).turn_off();
id(led_M).turn_off();
id(led_H).turn_off();
}
- if:
condition:
- script.is_running: timer_
then:
- switch.turn_on: Template_timer_led
turn_off_action:
then:
#- switch.turn_off: led
- lambda: |-
id(led_flag)=0;
- switch.turn_off: led_sw
- switch.turn_off: led_L
- switch.turn_off: led_M
- switch.turn_off: led_H
- switch.turn_off: Template_timer_led
- platform: template #模板开关,风速低
id: fan_low
turn_on_action:
- fan.turn_on:
id: dc_fan
speed: 35
- platform: template #模板开关,风速中
id: fan_med
turn_on_action:
- fan.turn_on:
id: dc_fan
speed: 50
- platform: template #模板开关,风速中高
id: fan_medhigh
turn_on_action:
- fan.turn_on:
id: dc_fan
speed: 75
- platform: template #模板开关,风速高
id: fan_high
turn_on_action:
- fan.turn_on:
id: dc_fan
speed: 99
# - platform: template #模板开关,摇头低
# id: ytdj_low
# turn_on_action:
#
- fan.turn_on:
#
id: ytdj
#
speed: 50
# - platform: template #模板开关,摇头中
# id: ytdj_med
# turn_on_action:
#
- fan.turn_on:
#
id: ytdj
#
speed: 65
# - platform: template #模板开关,摇头高
# id: ytdj_high
# turn_on_action:
#
- fan.turn_on:
#
id: ytdj
#
speed: 100
# - platform: template #模板开关,摇头关
# id: ytdj_off
# turn_on_action:
#
- fan.turn_off:
#
id: ytdj
- platform: template #模板开关------摇头
name: "${deZZZice_name}_Template_sw"
id: Template_Switch
lambda: |-
if ( id(dc_fan).oscillating ) {
return true;
} else {
return false;
}
turn_on_action:
then:
- if:
condition:
- lambda: |-
return id(dc_fan).state ==1 ;
then:
- fan.turn_on:
id: dc_fan
oscillating: true
- switch.turn_on: led_sw
turn_off_action:
then:
- if:
condition:
- lambda: |-
return id(dc_fan).state ==1 ;
then:
- fan.turn_on:
id: dc_fan
oscillating: false
- switch.turn_off: led_sw
fan:
- platform: speed
output: output_1
name: "DC MoZZZe Fan"
id: dc_fan
oscillation_output: yaotou
on_turn_off:
then:
- switch.turn_off: Template_close_led
# - fan.turn_off: ytdj
# - platform: speed
# output: yaotou
# name: "yaotou"
# id: ytdj
# on_turn_on:
# then:
# - fan.turn_on:
# id: ytdj
# speed: 65
# - switch.turn_on: led_sw
# on_turn_off:
# then:
# - switch.turn_off: led_sw
output:
- platform: ledc
pin: 2
frequency: 1000 Hz
id: output_1
- platform: ledc
pin: 32
frequency: 1000 Hz
id: yaotou
maV_power: 0.65
binary_sensor:
- platform: gpio #四档牢固风速切换
pin:
number: 17
mode: INPUT_PULLUP
inZZZerted: True
name: "speed"
on_press:
then:
- fan.turn_on: dc_fan
- lambda: |-
if (id(dc_fan).state) {
if (id(dc_fan).speed == 35) {
id(fan_med).turn_on();
} else if (id(dc_fan).speed == 50){
id(fan_medhigh).turn_on();
} else if (id(dc_fan).speed == 75){
id(fan_high).turn_on();
} else {
id(fan_low).turn_on();
}
}
#
- lambda: |-
#
if (id(dc_fan).state) {
#
if (id(dc_fan).speed == 35) {
#
id(led_M).turn_on();
#
} else if (id(dc_fan).speed == 50){
#
id(led_M).turn_on();
#
} else if (id(dc_fan).speed == 75){
#
id(led_H).turn_on();
#
} else {
#
id(led_L).turn_on();
#
}
#
}
- platform: gpio #摇头按钮
pin:
number: 16
mode: INPUT_PULLUP
inZZZerted: True
name: "direction"
on_press:
then:
- switch.toggle: Template_Switch
#
- fan.toggle:
#
id: ytdj
- platform: gpio #封锁按钮
pin:
number: 19
mode: INPUT_PULLUP
inZZZerted: True
name: "off"
on_press:
then:
- fan.turn_off: dc_fan
#
- fan.turn_off: ytdj
- platform: gpio #编码器按钮
pin:
number: 0
mode: INPUT_PULLUP
inZZZerted: True
name: "off"
on_press:
- fan.toggle: dc_fan
#
- fan.toggle: ytdj
- platform: gpio #按时按钮
internal: True
pin: 18
name: "${deZZZice_name}_timer_button"
deZZZice_class: window
on_press:
then:
- if:
condition:
and:
- lambda: |-
return id(dc_fan).state == 1;
then:
- switch.turn_on: Template_timer_switch
sensor:
- platform: duty_cycle #通过占空比的改观来切换风速批示灯
pin: 2
name: fan speed Sensor
id: fan_speed
update_interZZZal: 1s
on_ZZZalue:
then:
- lambda: |-
if (id(dc_fan).state) {
if (id(dc_fan).speed < 51) {
id(led_L).turn_on();
} else if (id(dc_fan).speed < 76){
id(led_M).turn_on();
} else {
id(led_H).turn_on();
}
}
- platform: rotary_encoder #无极调速编码器
name: "dc fan Encoder"
pin_a: 5
pin_b: 4
min_ZZZalue: 10
maV_ZZZalue: 100
resolution: 1
id: ec11
on_ZZZalue:
then:
- fan.turn_on:
id: dc_fan
speed: !lambda |-
return id(ec11).state/1.0;
复制代码
|