my new toy: Flapper (Flap Actuator – Flexar).
it can only be controlled via H Bridge. how can i use Esphome to control this Flapper?
i used the code here and got error instantly upon compiling H-bridge Fan — ESPHome. please help
on the hardware side, this is how i already wired it.
in HA, i only see this though. when flipped to ON, the H-Bridge outputs 12v DC. when flipped Off, i get 0 volt.
how do i get the Speed and Direction adjustment as seen in the example code at H-bridge Fan — ESPHome
wiring has been adjusted as well because the first diagram i posted is very wrong.
OK. i see now. after clicking on entity, i get speed and direction control. 40% speed is about 5v dc output. but how to get esphome to do PWM?
flat line of 5v dc is no good for this flapper as seen in this video from the inventor https://youtu.be/oe-3H8u-2eM?si=sMzVaa2z_ye_FfWx&t=130
What are you measuring the output with? An oscilloscope is the only thing that will give you an accurate picture of what is happening on the output. A multimeter will just average the voltage of the PWM signal on the output.
here is the specs of the Flapper: https://cdn.shopify.com/s/files/1/0766/9855/0605/files/Flexar_Flap_Actuator_Datasheet_Rev1.0.pdf?v=1689834771
it’s too bad i dont have an oscilloscope, only a multimeter…
after reading your link on how L298N, i see voltage output on the H driver is done by regulating the freq. so if the freq is very high, then Vout is almost constant of 12v DC, right? if freq is low, then it will average out around 3v… BUT the max instantaneous peak is still 12v, correct? would this max 12v damage the Flapper?
i see in the specs, the voltage should be under 6v for the Flapper, but cant tell if that’s average or max peak
There are several things i can see:
the default PWM is 1000hz, which is way too high (for flaps), you need in the 0.5-10Hz range (max is 25Hz).
but you also want to control the PWM to limit power, which will be high frequency
so you will need 2 PWM’s, one set for the 0-10hz (adjustable) and one at the default 1000hz
for the 0-10hz PWM controlling the flap frequency you set a fixed 50% duty cycle and from the docs in esp8266_pwm you will need to implement this to change the frequency,
and then adjusting the PWM duty cycle of the other PWM at 1000hz will be changing how much force it has. this PWM would be fed into the EN pin on the board you have. and this is where you take into account the formula to limit heat.
But you also need to drive the flap in both directions, so for every forward direction pulse you also need to do a reverse direction pulse to move the flap back down
I’m not sure the best way to do that, probably something like on_change with the low frequency pwm and have it invert the GPIO to the other input.
as of now, the Flapper does not work as you know. The Flapper stays up… “floating” in the air and making this high pitch noise. not super loud but noticeable.
I can give you ideas and help you figure out what’s happening, i just don’t have time to sit and figure out the code to actually make it work. it takes practice reading the docs and figuring out how to put it all together to do what you want. ESP home is big and complex and there is normally more than one way to do things.
to drive your device, you will need
PWM fed to the ENA pin on the board, this will control the amount of power going to the flapper, not how fast it flaps
you will need to toggle IN1 and IN2 at whatever frequency you need, this is not PWM, its a fixed 50% duty cycle, for example
IN1 off IN2 on
wait 500ms
IN2 off IN1 on
wait 500ms
IN1 off IN2 on
wait 500ms
IN2 off IN1 on
wait 500ms
the delay between is what changes the flap speed. 100ms is the lowest you can go and will produce the 10Hz limit. the bigger the number the slower the flaps, 500ms will give 1 flap per second
what you are seeing now is the flap pushed away and humming with the 1000hz PWM you are feeding it.
try this, i don’t have a way to test it.
you will need 1 additional wire from GPIO14 / D5 to the ENB pin (if you are using IN3 and IN4) - you will need to remove the jumper
i will try your code when i have some time this weekend.
now, i wonder if i should be using the ESP32 board instead. The ESP32 LED PWM controller has 16 independent channels that can be configured to generate PWM signals with different properties. All pins that can act as outputs can be used as PWM pins (GPIOs 34 to 39 can’t generate PWM). To set a PWM signal, you need to define these parameters in the code: Signal’s frequency; Duty cycle; PWM channel; GPIO where you want to output the signal.
then i can skip using the H bridge altogether, correct???
no, you still need the h-bridge, because the ESP can only handle a few milliamps. the H-Bridge is required to deliver the power required to make the flap move.
the H bridge is a really cool device, there is a few logic gates that prevent the FET’s on the same side of the H from being turned on at the same time. so IN1 controls say the left side, when its low then the bottom FET will be on and the top one off, when you set IN1 high it will turn the bottom FET off and the top one on. IN2 does the same but for the right hand side. the EN pin is used to essentially turn all the FET’s off.
this allows power to be applied in the opposite direction, so your flap will push away from the magnet then pull towards it
you really only need 1 actual PWM, that limits the maximum power. the other PWM set at a square wave at the flap speed is really slow (for a computer) and its pulse width doesn’t change so its not really PWM. in the code above i did away with it and just turn the switches on and off.
i prefer the ESP8266, I’ve had way less issues with them. they seem to be less finicky with the power supply.
I’ve been watching Carl Bugeja for a while and find his projects really interesting and a great use of flexible PCB’s and PCB coils. I’ve often thought about how i can use them round the house, but so far cant think of anything.
I was considering making a bladeless fan, like a tube with PCB coils and magnets that operates in a wave to pump the air along the tube.
i will be using the Flapper for some art projects. myself, im more of an artist than an engineer. it is a problem because i cant code to safe my life. can only do copy n paste from good youtube tutorials. some people on YT dont focus on the coding because they assume others are just as smart, very wrong assumption. this is why i really appreciate your help and Daryl here