Electronic – L293D Question About Grounding

drivermicrocontrollermotor

I am using the L293D to run two motors, and am controlling it via an ATmega328.

I am a bit confused about how grounding works. I was following this tutorial, and searched this question a lot, but am not satisfied. Essentially, notice how pins 4, 5, 12, and 13 are all connected to ground? And the two enable pins must be connected to +5V. Well, what if my micrcontroller is being powered by a completely separate power source from the motors, yet I am drawing +5V from the MCU for the pins which require +5V on the L293. Which ground do I use for pins 4, 5, 12, and 13? If I use the MCU's ground, then what would complete the circuit for the motors? And if I use the motor's power supply ground for those four pins, then what what complete the circuit for the enable pins?

Basically, I am confused about how to ground the L293 chip, since I require input from both the MCU's power source, as well as from the motor driver's power source (at 12V), yet the datasheet does not seem to indicate separate grounds.

Best Answer

For most simple applications, you needn't have two separate grounds. For heavier applications or where there is need for greater cleanliness of the power supply, it is generally considered a good practice to keep the grounds separate.

Being able to join two grounds together is usually possible (Though not always).

schematic

simulate this circuit – Schematic created using CircuitLab

In the case of batteries, any two batteries are isolated from each other for most practical purposes. Once you connect them (or the circuits they are part of) together, the point at which the connection is made specifies how the voltages are related to each other. For conventional applications, you could just call the connection point the combined circuit's main ground reference point, and connect the negative terminals of the batteries to it.

In the case of something connected to a wall power supply, such as with using a transformer, a similar logic can be applied. The transformers isolate the outputs from the input (wall power), and so the DC voltages derived by rectification are effectively isolated from each other. Again, you can connect the two negative points (the 'grounds') together to make a common reference point. Most commercial power supplies that feed off of wall power will output isolated DC voltage due to regulatory requirements. If the power supply also uses the third pin (Earth) on the wall socket, it may be using that to bias the output (fix it to a certain point relative to the Earth at your house / office / what have you), in which case some care must be taken to connect them together. If the power supplies produce single ended DC output (5V and GND, or 12V and GND), then you can pretty safely assume that if the supply is fixing the output voltage relative to Earth, it most likely will be connecting the output ground (0V) to the Earth. Make sure to make the connection on your circuit as well anyway, because the output may also be isolated.

The problem comes if you are using an unusual power supply combination. If you are using a power supply which produces 5V,5VGND; 12V,12VGND, and the two supplies are for reason not isolated and 5VGND is not connected to 12VGND, then you cannot connect them directly. Which means you will have to most likely treat the two grounds as truly separate.

Treating the two grounds as separate is also necessary if, say, you are driving high power motors which may interfere with your Atmega, or if you are also trying to make sensitive analog measurements, or for a variety of other reasons. If you do have to use separate grounds, though, then your Atmega outputs cannot be directly sent to the L293. The signals have to be referenced against the L293 ground (which we'd usually refer to as the power ground) and not the Atmega ground, and these two are not necessarily at the same voltage (the potential difference between the grounds cannot be guaranteed to be zero unless you actually connect them together). This 'translation' can be done using ICs such as optocouplers and other methods of galvanic isolation, which means that the signal is translated from one 'ground' to another without using any usual conducting connection.