Enable invert ir2104

Good afternoon. In my project I use esp32 and the drivers of the ir2104 mosfets. I have two questions: can I invert the enable output signal? I use an analog input to control the motor. This all works well, but when the engine is standing, the lower shoulder mosfets are open, which causes difficulties when the engine rotates. Can you help me? I’m building a game steering wheel using a gyro scooter motor

1 Like

Hi @nikolaewich1988!

Looks like your project is already far along! Nice!

If you want to invert the enable signal, you can use the setting:

driver.enable_active_high = false

This will make the enable pin active-low, the opposite of the default setting.


but actually, looking at the datasheet, this driver has a shutdown (SD) input which is active low, meaning the “enable” signal (the opposite meaning of shutdown) is active-high, the normal setting.

So you should not need to change anything from the default. Just call motor.disable() to switch off the bottom FETs, and motor.enable() when you want to move it again.

1 Like

Thank you for answering my children’s questions)))
I am new to programming and do not quite understand how the function call (((
for example, I control the motor with the signal value, i.e. when the input value is less than 9, the motor rotates counterclockwise, when more than 11, then clockwise. in the range between 9-11, the engine must be switched off. It works for me, but when the value is between 9-11, the motor is standing, but the mosfets of the lower shoulders are open.
You wrote correctly, but I do not know how to call functions correctly(((

I think my ir2104 is faulty. They work only according to one scheme, where the pwm output is connected simultaneously to the IN and SD input. In other cases, the work does not happen. I tried to send an inverted signal to the SD input, but the engine does not work (((.

But when the SD level is low, the mosfets of the lower shoulders open. I probably need to look for other drivers.

Take a look at page 5 of the ir2104 datasheet https://www.infineon.com/dgdl/Infineon-IR2104-DS-v01_00-EN.pdf?fileId=5546d462533600a4015355c7c1c31671

SD is logic input for shutdown, and I don’t think you should feed it a PWM at all.

The IC introduces dead time. You are feeding it the same PWM to both SD and IN pins, and the IC introduces dead time on each pulse and your mosfets don’t turn on. I would assume it works that way - just looking at the datasheet.

Try putting SD high and see if it works.

Taking a closer look at pg 5, it looks the ic doesn’t introduce dead time but rather shuts down when the Lo side should be on - because you are feeding it the same pwm. SD high would be the solution I would try

Something like this is what you want. The SD signal should not normally be driven by PWM.

You can choose any digital IO output pin on your MCU as the “enable” pin (EN in my picture). Then you can initialise the driver like this:

BLDCDriver3PWM driver = BLDCDriver3PWM(11, 10, 9, 8);

→ pin 8 is the enable pin in this example.

Thank you, I tried your scheme today. Unfortunately, it doesn’t work that way. When the lower signal is on the SD, the lower mosfets are open. When the upper signal is on the SD, all mosfets are closed until the upper signal arrives at the IN input. It’s hard to explain. I will try to show in the diagram how they work for me. I read that on Ali Express they often sell with the wrong label. Maybe I have so

That’s not what the datasheet is saying

When SD is HIGH, the PWM signal from the IN pin will generate both complementary HI and LO outputs and introduce deadtime.
When SD is LOW, the PWM signal from the IN pin will be ignored.

How exactly did you test it and figure out low mosfets are open? remember that the mosfets are switching at the PWM frequency

I have a hard time imagining this output based on the inputs you gave.
IN 0, SD 1 - both outputs 0 is normal since you don’t feed it the PWM and there is nothing to generate the complementary PWM for the outputs
IN 1, SD 0 - both outputs should be 0
IN 0, SD 0 - both outputs should be 0
IN 1, SD 1 - complementary PWM outputs should be generated

You absolutely must feed a PWM in the IN pin. Try playing around with the PWM frequency - IR2104 has a bootstrap capacitor that charges and discharges on HI mosfet on/off and that should be scaled according to the mosfet used and the duty cycle of the on/off switching and the mosfet gate capacitance.

It could also well be a faulty IC.
Take it with a grain of salt since I’m just guessing

I’ve just looked at the ir2103 driver, maybe I’m wrong. But it seems to me that my drivers work that way. What does the line above the LIN entrance mean?

The line above a signal name indicates that it is “active low”, i.e. the state indicated by the signal name is achieved by pulling the signal to GND.

So a RESET signal with a bar, sometimes also written as RESET-bar or nRESET, means that the chip is reset by pulling this signal to GND.
The same signal without the bar would mean that the signal is “active-high”, i.e. that the reset happens when the signal line is pulled to VCC.

So in this diagram, the LIN-bar signal has the inverted meaning of the HIN (no bar) signal. HIN is active high, so the output HO is high when the input is high. LIN-bar is active low, so the output LO is high when LIN is low.
Additionally, this chip has some kind of interlocking protection, so LO cannot be high if HIN is high, and HO cannot be high when LIN-bar is low.

Thank you for such a detailed answer, I am very glad that this is still happening. I wanted to try to control these drivers using a 6 pwm. But if LIN’s input is inverted, then it turns out I can’t do it?

Not without changing the code of the library, or adding a logic level inverter to the output signal. Sorry about this!

At the moment, we assume an active-high situation on the PWM signals, i.e. we assume PWM high means the FET will be open. Really, we should make this setting configurable, since it can depend on the driver, but also the FETs used (e.g. P-Channel high side FETs). I will look into what it would mean to make this configurable, but it will take a long time for this to make it to a release version, if ever.

I’m still waiting for other drivers. But today using the method of scientific poke. I have found a solution where I can turn off the lower mosfets while the engine is parked. This is most likely not correct, but it works

I hate to say it, but that circuit makes no sense to me.

For the IR2104, it is not intended for the shutdown to be driven by the PWM. This pin is intended to be used as the enable pin for the driver.

Note that SimpleFOC generally assumes the FETs of a half-bridge are always switched in a complementary state when the motor is enabled. The only exception is the dead-time insertion. So when the high-side FET is closed, the low-side FET is open.
If you want to switch both FETs off you have to call motor.disable().

The IR2104 can work using the BLDCDriver3PWM and the SD pin configured as the enable pin.
The IR2103 is not ideal for SimpleFOC because its inverted logic on the low-side pin means it won’t just work out of the box. You will need to make some changes to the code, or introduce an extra logic inverter in the LIN signal path.
The IR2102 has inverted logic on both pins, so the same remarks apply as for the IR2103.
The IR2101 is the one you want if you want to use 6-PWM control.

1 Like

Today I was very happy to test my board with 6 pwm control, but unfortunately, when the motor stops, the rotor remains blocked, since the mosfets of the lower side are open and the motor windings are closed to each other.
I thought that when the motor stops, there will be 0 at the outputs of the controller, but for some reason 0 only on the pins of the upper side. What then is the meaning and difference between 3 and 6 pvm? If in both cases it is necessary to disconnect the controller from the power supply to close all mosfets😁


Are you using the IR2104? Did you connect the shutdown pin?

In 3-PWM, the driver will have either the high-side or the low-side FETs open. There is no way to close them both from the PWM signal. That is what the SD pin is for. If you connected it, and pass the pin as the enable pin when initialising the BLDCDriver3PWM, then you can call motor.disable() to close all the FETs.