Using 2 dual drivers (TB9051FTG) and 1 Arduino

I plan to use two driver shields, with one Arduino Uno, to drive 4 DC brushed motors.
After using 4 pins for motor encoder speed sensing, I will use nearly all of the Arduiono I/O pins for PWM/DIR/Current sensing, except for 2 spare pins. So…
I think I could link all 4 enable inputs to one Arduino output- this would give me the ability to enable/disable all 4 motor drives together.
Also, I think I could link all 4 DIAG pins together to one Arduino input pin; a ‘wired-or’ scheme.
[I realise I would have to do a few cuts and links on the boards]
**** anyone see any reason this would not work? ****
[Of course, I’d not get separate enable or DIAG info for each motor, but it’s better than nothing]
Thanks for any thoughts…

Hello.

Connecting all four EN pins should be fine if you want to control all four drivers together. Connecting all four DIAG pins should also be fine; however, you will lose the ability to determine which driver detected a fault if one occurs.

Are you planning on driving four motors independently? If so, what is your plan for the PWM and the DIR signals? If you post a diagram of your proposed connections, I would be happy to take a look at it.

– Jeremy

Hi Jeremy.
Thanks a lot for the quick, helpful reply.
I attach my Arduino pin mapping for using two drivers. If you’d like to check it that would be great!
Incidentally, I find the design of the TB9051FTG excellent, with all its thought-out possibilities for re-mapping to allow people like me to do different things with it.
Having two stacked Arduino shields, on one Arduino, is a nice compact scheme for me even if I do use up every Arduino I/O pin!

I also like the C++ code example library, which I have used on one driver, as a testPin mapping-two-drivers.pdf (547.5 KB) . I have looked at changing this to allow it to work on the 2nd driver also. It looks like I change the pin mappings and the ‘Timer 1’ references to ‘Timer 2’. If I posted the proposed changes (maybe a different forum thread on software), do you think someone would check it for me?

Many thanks. Tony

Thank you for the kind words about our TB9051FTG shield! Your pin assignments seem reasonable. Using Timer2 for the second set of PWM signals should work; however, please note that Timer2 is an 8-bit timer, while Timer1 is a 16-bit timer.

You do not need to start a new thread; you can post your code here, and I would be happy to take a look.

– Jeremy

Jeremy
Thanks for checking the pin assignments and for the comment on timers. I’d forgotten about the 8 bit/16bit issue.
I don’t think I need high precision in setting motor voltage (/speed), so ~ 1% from 8 bits sshoud be fine.

However, for setting the PWM frequency in the sophisticated way that the Pololu example code does (16bit timer 1), I think I’ll need to learn more abour Arduino prescalers/timer operation for the 8 bit Timer 2.

Or, I can maybe take an easier approach for the code and do something simpler by just setting a x8 divisor value to give a 4 kHz frequency? Comments welcome… Haven’t yet looked into this much…
[I saw a post that showed:

"/TCCR2B = TCCR2B & B11111000 | B00000010; // set timer 2 divisor to 8 for PWM frequency of 3921.16 Hz"

best wishes
Tony

Alternatively, you might consider using the analogWrite() function to drive the motors on those pins. Please note, the analogWrite() PWM frequency is 490Hz on those pins, which will probably be audible (4 kHz is also audible).

– Jeremy