Driving a H-Bridge with a PWM ic

Hello.

As usual.... running out of pins.

I have a BTS7960 40A H-bridge as discussed in this thread here:
https://forum.arduino.cc/t/dc-motor-driver-bts7960/606686

I would like to entirely control it over i2c and wonder if a chip like this could achieve that:
https://www.analog.com/media/en/technical-documentation/data-sheets/max7315.pdf

Lots of i2c addresses to use on this IC.

Can anyone foresee any timing issues? I am kinda stabbing this together if I am honest.
Will certainly need to breadboard it first

Which Arduino board are you using and which pins have you used so far ?

Running an UNO (Not my ideal choice, but it's existing).

All the pins are used, but there is a 0.91" i2c screen bus

You can find a variety of I2C I/O expander breakout boards for sale.

I am making a custom H-bridge driver board to fit a specific task/enclosure.

The H- bridge will actually be the newer version of the BTS7960, as this is now obsolete.

Therefore, I want to add an IC to my PCB, not a breakout board.

My biggest issue will probably be working out the coding to actually get it to work.

OK, makes sense. The concept is fine, but that chip only provides an open-drain output. You should use something that has push-pull outputs like a PCF8574.

If you were thinking of using the PWM capability of that IC, it won't work

Ah ha! That is what I am asking. Why would the PWM not work? (just so that I know why)

That's annoying... nice little chip that

Does the PCF8574 have PWM out? I thought it was a straight I/O expander.

I was looking for a chip with at least 4x outputs of which at least 2x need to be PWM

Then you have to find a PWM module with I2C interface.

I thought that is what this IC was?

The MAX7315 I2C-/SMBus-compatible serial interfaced
peripheral provides microprocessors with 8 I/O ports.
Each I/O port can be individually configured as either an
open-drain current-sinking output rated at 50mA at 5.5V,
or a logic input with transition detection. A ninth port can
be used for transition detection interrupt or as a general-
purpose output. The outputs are capable of directly dri-
ving LEDs, or providing logic outputs with external
resistive pullup up to 5.5V.
PWM current drive is integrated with 8 bits of control.
Four bits are global control and apply to all LED outputs
to provide coarse adjustment of current from fully off to
fully on in 14 intensity steps. Each output then has indi-
vidual 4-bit control, which further divides the globally
set current into 16 more steps. Alternatively, the current
control can be configured as a single 8-bit control that
sets all outputs at once

Okay, that chip has some built-in PWM funtionality for LED brightness (constant current) setting. It may not be useful to control H-bridges for motors etc.

OK... I am confused. So the MAX7315 chip doesn't have PWM output ability? I clearly am not reading the datasheet right then.

I'll look around again

Max7315 PWM freq = 32kHz.
BTS7960 maximum PWM = 25kHz.

The MAX7315 does have PWM, but the outputs are open-drain. So you either need to add pull up resistors to the outputs or switch to another port expander with push-pull PWM outputs.

OK

Just checking the frequency of the BTN8982 which is the newer H-Bridge driver to see if it's the same spec

I can't find a 'max' PWM frequency in that PDF, just a calculation for PWM. Doesn't say it's the max...

6.3 PWM Control
For the selection of the max. PWM frequency the choosen rise/fall-time and the requirements on the duty cycle
have to be taken into account. We recommend a PWM-period at least 10 times the rise-time.
Example:
Rise-time = fall-time = 4μs.
=> T-PWM = 10 * 4μs = 40μs.
=> f-PWM = 25kHz.
The min. and max. value of the duty cycle (PWM ON to OFF percentage) is determined by the real fall time plus
the real rise time. In this example a duty cycle make sense from approximately 20% to 80%.
If a wider duty cycle range is needed, the PWM frequency could be decreased and/or the rise/fall-time could be
accelerated.

Maybe an ATtiny would be a better way forward?

Pca9685?

Sx1509?

I realise 16 channels may be overkill, but they are cheap and easily available and there are Arduino libraries for them.

Thanks - I will look into that (sx1509)

Just found some ATtiny1606 chips. Maybe this could work?

Not sure what clock I need to run that at.... like I said, stabbing around a bit here!

I was thinking the same thing.

That formula they give for PWM is useless. The max PWM is going to be related to the switch on/off delay times and they are no shorter than the BTS7960's times, so I think ~25kHz will still be the limit.