The last time I wrote about Raspberry Pi was Connect to New Provisioned Raspberry Pi Less than $3, about six years ago. Time flies! Today, I will talk about a grounding issue.
Background and Troubleshooting
I recently purchased a powerful motor driver board. It supports two DC motors with encoders and other features. During the initial testing, I experienced weird behavior. As a cloud engineer, I find it interesting to learn about the physical world.
The problem was that the motor would not respond to the Python code unless I power-cycled the motor driver board. Sometimes, I even had to reboot the Raspberry Pi.
The photo above shows the layout of the motor driver board. Each motor connects to one of the two white 6-pin connectors The key pins on each connector are E*A and E*B.
As you may know, electronic devices can only recognize 0 or 1. We send combinations of the two values to the two pins to control a DC motor spinning around. For instance, if you send value 0 to E2A and value 1 to E2B, the motor may move forward. If you send value 0 to both pins, the motor is stopped.
On the board, E2A and E2B internally connect to BIN1 and BIN2, two input pins receiving signals. I connected the two input pins to Raspberry Pi’s PIN22 and PIN23.
As you can see, the full physical circuit paths are:
- PIN22 -> BIN1 -> E2A
- PIN23 -> BIN2 -> E2B
The problem, as I mentioned in the beginning, due to the motor board’s lack of common ground with the Raspberry Pi.
The motor board and Raspberry Pi have standalone power supplies. The board was 12v, and Pi was 5v. When sending a signal from PIN22 or PIN23 to E2A or E2B, aligned current and voltage on the board are important. I resolved the issue by connecting the board’s ground pin to a Raspberry Pi’s ground pin.
The following part is some notes for my reference. It may be useful for you also.
Purpose of Electrical Grounding
- Protect individuals.
- Protect devices.
- Keep voltage constant and in a healthy phase.
- Redirect leaking voltage to ground.
- Ensure fault energy is dissipated.
- Reduce electrical noise.
- Better function from surge protection devices.
Difference between “bonding” and “grounding”
Bonding is the act of connecting conductive parts together to avoid potential current differences. For example, one hand touches a metal surface on a computer, and another hand touches a metal lamp; if there is no bonding in the house, you may be hurt.
Grounding connects parts of an electrical device to the earth.
Ground Loops
It occurs when there is more than one ground connection in an electrical device.
For example, a computer is connected to a standalone outlet, and a Raspberry Pi is connected to another fully isolated outlet with grounding. If you use a USB cable connecting both, you may see some abnormal behaviors. Connecting both devices to the same outlet will resolve this issue.
Reference Point
If you want to measure the height of two objects, a common object is required as a reference. The full English sentence is like this: Compared with the sea level, object A is 5 meters higher, and object B is 10 meters higher.
When the Raspberry Pi talks to the motor driver board, they need a reference point as a “translator”. In my case, the reference point was missing, so the code couldn’t control the motor driver board.