Sorry guys, maybe someone has already posted the solution, but after some search,
I still didn't have any clear idea on how this could be done.
So here again I seek for help, and hope you don't mind.
Now back to business, I am designing a driver for my toy car which is used in my thesis. what I need is very simple. The driver board should control 4 motors with both speed and direction. The problems is, I am using Arduino Pro Mini, which has 6 PWM pins. So how can I drive 4 motors using 4 PWM pins?
I am using 2 L293NE chip( do I need external diodes on this one ?) and 7.4v power supply.
Generally, you need two pins per motor; one PWM for speed, and one digital for direction. If you have 6 pins total, you can't easily do what you want.
Build an H-bridge with two P-channel and two N-channel power MOSFETs, and two additional signal N-channel low-end drivers for the P-channel gates. This lets you switch direction.
Then, gate the power into that H-bridge with the PWM. This lets you control speed.
If you only have six pins total, and can only use 4 pins for motor control, then I suggest either using an I2C or SPI based motor controller chip, or building something which averages out the PWM to an analog signal, and uses comparators to select forward/backward, and uses the analog signals as a controller for the duty cycle of something that generates a new PWM signal (such as a 555 for each channel.) This allows you to output "0.5" to stand still, "1.0" to go full forward, and "0.0" to go full backward. It is, however, a lot more external electronics.
You do need diodes with the L293NE, see the datasheet (the L293D has them built in).
As jwatte says, to control a motor you need a pwm pin for speed and a simple digital pin for direction. So you need to use 4 of your 6 pwm pins. If you don't have 8 pins available in total, you could share some of the direction control pins between motors, if you don't need to control the direction of each motor independently of all the others.