Motors and SD card!

Hi guys!
I'm wondering how can I interact a TB6612FGN motor driver with a SD ...
My problem is:
-> the SD card needs to be on pins D11, D12, D13 and the CS can be on any pin
-> I have a timer interrupt setup on TIMER1 so I would likely avoid his PWM pair (D9 and D10)
-> and i need to add a TB6612FGN with 2 motors on 4 PWM pins (so D3, D5, D6, D11)
-> how you can see the driver and the SD card uses one common pin.

I think that if I could use the motors and the SD card on the same pins or if I could use other pin for the SD card, I could make this work.

Keep in mind that I'm gonna print my own circuit board, I'm not gonna use an Arduino board, just the atMega328p-pu so you may propose other pin configs too.

If you have any ideas, you may answear here.

Thank you!

Why do you need 4 PWM pins to control the speed of two motors?

You can't get a quart into a pint pot.

Either you need to abandon the use of Timer1 or get an Arduino Mega, or perhaps a Leonardo or Micro.

Or you could use an external chip (such as an AND gate 74HC08) to steer one PWM signal to either of two driver pins.

@PaulS, I suspect (guess) that the driver is like the Pololu DRV8833 and needs one PWM signal for forward and another for reverse.

...R

@PaulS, I suspect (guess) that the driver is like the Pololu DRV8833 and needs one PWM signal for forward and another for reverse.

You are probably right, but that is not the only device that can drive two motors. The choice of a different driver would eliminate the pin conflicts.

Yes, it's like that Pololu driver, it needs two PWM for each motor ... And I can't abandon the interrupt.
But i found a Adafruit library for Arduino and i think that this should work. It adds the void SD.end(void); function.
I don't know if this will help me ..

I don't know if this will help me ..

I don't see how it will. Pin 11 is an SPI pin, and anytime you want to write to the SD card, you will have to have the motors either stopped or running full speed (so PWM is not needed).

PaulS:
You are probably right, but that is not the only device that can drive two motors. The choice of a different driver would eliminate the pin conflicts.

No i can't. I need to use this driver.

PaulS:
I don't see how it will. Pin 11 is an SPI pin, and anytime you want to write to the SD card, you will have to have the motors either stopped or running full speed (so PWM is not needed).

I really need to read and write to the SD in the setup. So you say that if i don't use the SD card i can use the pins after closing the file without affecting the data?

So you say that if i don't use the SD card i can use the pins after closing the file without affecting the data?

Yes.

PaulS:
Yes.

Thank you very much!
Tomorrow i'll test it and i'll reply to tell you if it works!

Did you see my suggestion in Reply #2 to use an external chip to steer the PWM signal.

...R