after I explained about the software part of my design in my previous post, I would like to describe an important yet very simple interface circuit that I use to control my motors.
The circuit schematic is shown in this image:
the GPIO pins 23 and 24 are connected to the left and right motors in the same way, the GPIO pin is connected to the base of the PNP transistor through a 1000 OHM resistor, the transistor collector is connected to the Raspberry PI digital ground pin, the Raspberry PI 5 volts pin is connected with a 10 OHM resistor to one side of the Relay coil, the other side of the coil is connected to the transistor emitter.
On the motors side, the positive port of the motor is connected to the positive port of the motors battery, the Motor negative port is connected to the Normally-Open (NO) pin of the Relay, finally, the Common (C) pin of the Relay is connected to the negative port of the motors battery.
This circuit is pretty basic and naive, as it doesn't provide speed control of the Motors using the Raspberry PI PWM pin, However, it can be modified to include this feature by using a power transistor with the motors battery. as shown in this image:
However, I haven't applied the PWM and speed control part, and it can be considered as an extra feature that can be added later.