Tools, Design, and Process
When a robot cat doesn’t move like a real cat, it’s a problem. To make his robot move with cat-like grace, Jose identified the problem (unstable servo voltage), and designed a solution, made with a Hall effect current sensor, a linear regulator, and a hand-built PCB. In this article he give us details on the final device that enabled the robot to consistently walk like a live cat.
My friends and I were building a Robot Cat, and encountered a problem with the robot walking— the servos were not behaving as expected. The robot would work well, and then would not, with no clear explanation of what was happening.
After a lot of confusion and hair pulling, by examining the signals and supply voltage, we determined that the servo peak current was drawing down the supply voltage, causing the servos to have an unstable voltage and to malfunction. To fix this battery power supply problem, I needed a method to measure both the DC and AC (peak) current used by the servos, so I could design the right power supply solution.
Based on previous experience with servos and other mechanical devices, I knew that figuring out how much current is needed to have a stable project is a real problem. So, after some analysis and a new current sensor design, I determined how to properly measure the current used, identify the power spike problem, and address this problem with an updated power supply design.
In this article, I will describe a good solution for measuring our project currents, but also explain the design process I followed to arrive at this good solution, as an example of how to handle the engineering and design process.
Solutions and Shortcomings
The best method of measuring current used by a project is to place a current sensor in line with the voltage source to the load (servos in our Robot Cat case). Normally, a small resistor is used in line with the power supply to the project load, to translate the project current to a voltage, and then use an instrument such as a voltmeter to measure the current-induced voltage across this resistor. But to measure AC changes you need an oscilloscope. Unfortunately, a scope cannot be used with this supply resistor, because the scope ground connection will short one side of the resistor to ground causing a short of the power supply.
Other approaches include adding the small resistor between the project ground and the battery ground, so that the scope ground is connected to the battery ground—which is fine. But this solution has its own problem—the project ground is not connected to the power source ground. This lack of the best ground introduces a new set of possible electrical problems, including noise, since the supply ground is not the project ground.
Other solutions can be used, but all have their own shortcomings. Going back to the best solution—a sensor in line with the power source—is to use a ground isolated sensor in the power line, which causes no disturbance to the project ground. That is where a Hall effect device applies well. So let’s see how this Hall effect technology can help.
Hall Effect to the Rescue
The Hall effect was discovered in 1879 by Edwin Hall. Hall effect sensors use a special property of material, where a current flowing through a connection generates a magnetic field. The Hall function senses this field, and converts into a voltage. The current source can be isolated from the sense function, with the magnetic field translating the current magnitude to the sensor without an electrical connection.
The Sensor: With modern semiconductor technology, excellent designs have been developed to use the Hall effect for measuring magnetic fields and current flow. Of the many available Hall effect current sensors, I selected the ACS712ELCTR-05B-T from Allegro Microsystems. Allegro is a well-known manufacturer that produces all types of Hall effect devices, and this particular part is a good choice for measuring up to our 5A of current accurately. Note that this device also has other part number choices with a higher maximum current. These other available devices are important for us, since by just changing the Hall effect part and keeping the same design, we can measure higher currents. Having selected the current sensor, I will now describe the process I used to arrive at a PCB (printed circuit board) solution.
PCB: First, I analyzed the specifications for the ACS712ELCTR-05B-T Hall effect current sensor [1] to determine what this part needs in the PCB design. I learned that it needs a 5V supply with a maximum current of 13mA. The current-sensing leads have an isolation to the device function (that is, power supply, ground, and so on) of more than 2.4kV, which works well for all my possible input voltages. The frequency bandwidth is 80kHz, allowing the measurement of microsecond current changes when the oscilloscope is connected to the Hall effect output voltage. The resistance between the sensing terminals is small, 0.0012Ω resistor, which reduces sensor interference with the power source voltage. For example, these terminals will drop 6mV at the maximum current of 5A, which is such a small variation on the supply voltage that it will not cause a power supply problem. The design for this part requires the 5V supply, connectors, and input connection wiring that can handle more than 5A, plus only two decoupling capacitors, thus simplifying the PCB design.
Second, I needed to figure out what else would be needed on the PCB. I decided to use a battery, so the ground is completely isolated from the ground in our project. Using a battery means that when the scope ground connects to our current sensor PCB, the sensor PCB ground reference then becomes common to the scope ground, thereby avoiding any ground connection problems from the project under test (and associated noise). Note that if another of the scope leads is connected to the project, then the scope ground will be common to the project ground. It will not cause a power supply short, so it is OK.
I decided to use a 9V alkaline battery to provide the 5V for the sensor. It gives hours of operation, and is small and simple to connect. For the 5V source, I needed to find a linear regulator that can handle the 9V input and provide a stable voltage to the sensor. At this point all the key parts needed for the design were identified, so I need to identify this linear regulator before working on the schematics.
Linear Regulator: Using the DigiKey website, I was able to quickly assess various linear regulators and select the part that fit my needs best. I strongly recommend using websites like DigiKey to help arrive at a best part solution and check availability (Active part). I selected the MCP1703-5 SOT-23A 5V linear regulator [2].
Analysis of this part for the design showed that it has a maximum input voltage of 16V, 250mA maximum output current, very low quiescent current (in the microamps) and a very good input and transient regulation specification. This regulator would work well with the 9V battery, but now we needed to calculate the loading effects and power dissipation.
The worst-case calculated current was 42mA (LED, Hall effect, and mini-voltmeter); we needed to know this value for calculating the power dissipated on the regulator. This maximum power with all the parts drawing maximum current (not usual) is calculated to be 0.17W—(9V-5V) X 0.042A. Since the SOT-23A has a Junction-to-Ambient Thermal Resistance of 336°C/W then the power dissipation will cause a maximum temperature rise of the SOT-23A of 57°C (0.17W X 336°C/W). This should be hot to the touch. The maximum junction temperature of the part is +125°C, so we can operate this part at an ambient temperature of up to 68°C (125°C – 57°C). This temperature of 68°C is a lot more than we normally expect for our project, indicating that power dissipation is not a problem. This completed our analysis of the linear regulator and confirmed that this small part would work well for our design as a 5V regulator.
Schematic Design: I designed the schematic diagram with Design Spark PCB, which is easy to use and has a lot of functions for schematic and PCB work. I particularly liked the library function, since it has a wizard that allows easy generation of symbols for new parts for the schematic and associated PCB footprint. I always check the parts and, in most cases, I changed something from the available libraries to meet my special needs. This special need usually involves the footprint, since I will solder by hand, and pad size plus location are important for easy SMT (Surface Mount Technology) soldering. The schematic with all the key parts and their logical connections is shown in Figure 1.
The schematic contains the symbols for the Hall effect device and the 5V linear regulator, plus capacitors, resistors, and an LED that lights up when power is applied. I also used different connectors to allow for the sensor current input, 9V battery, 2-wire connection, and the connection to the oscilloscope for measuring the resulting AC current-to-voltage output. I also included a PL3 connector for using an external mini-voltmeter LED display that can show the voltage value of the average DC current at all times.
A Bill of Materials (Table 1) shows the part numbers for all the devices used. I specified a manufacturer for the capacitors and the one resistor but these are common parts, and any other manufacturer could be used. I always use X7R technology for the capacitors, since it provides good temperature compensation at a small increase in price from the other technologies. If I were mass producing this design, I would consider selecting other technologies to meet the product requirements, to reduce the product cost.
I also used a connector symbol and associated footprint for creating the pins in the PCB for connections to the battery, the scope, and the mini-voltmeter. I will be soldering wires to these pins for the battery and the mini-voltmeter, and I will add a 2-pin header connector for attaching the scope probe. This schematic is simple and uses a variety of technologies.
Trust the Design, but Verify
To verify the design (“trust the design decisions, but verify; we live in a finicky world”), I built a prototype of these parts (Figure 2) and tested it to identify if anything else was needed.
I connected the 9V battery and started measuring the voltage at different points. As expected, the 5V regulator was fine (5.0V), and not as hot as calculated, since the calculations were done for worst case and not a typical case. The Hall effect sensor output voltage was 2.52V with zero current at the sensor connector, which is within the sensor’s specifications. Using this 2.5V for zero current allows the circuit to show both positive current—by having an output voltage higher than 2.5V—and a negative current—by having a voltage lower than 2.5V. I applied different currents up to 5 A using a regulated power supply, and the voltage increased the expected 0.185V per amp (±a few mV). Based on how well these tests worked, I started working on the PCB and ordering the parts.
The PCB design requires resolution of both electrical and mechanical details including having footprints for parts that allow easy hand soldering. For this design, an important problem was the current sensor connector. Because the PCB traces have to handle 5A, the associated traces need to be wider so as to conduct this current without overheating.
Using SMT parts, the PCB is small (1¼ by 11/16 inches), which allows mounting the PCB on top of the 9V battery. This made the whole instrument a small physical addition to my test devices. This 2-layer PCB has all the parts connected on the top layer, while the bottom layer is used as a ground plane to reduce possible electrical noise from the changing current or the ambient lighting, power supplies, and other factors.
Figure 3 shows a larger version of the PCB top layer design, detailing component placement and traces. Note that the IN+ and IN- pin holes for the connector are bigger than the other connector holes, and the traces to the IC1 (Hall sensor) inputs are made of large copper areas—called “copper pour” on the PCB design—covering pins 1-2 and 3-4 of the chip. These large traces are greater than the 100mil size that is the recommended trace width for handling 5A. I completed the PCB electrical rules check with no errors, and ordered PCBs. The next steps are to assemble the PCB and test the functions.
Build and Test
I received the PCBs a week later and manually assembled the parts using my soldering pencil and an assembly microscope. I strongly recommend using a microscope, since often, small soldering problem cannot be seen without a microscope. Such soldering problems include, among other things, cold solder joints, cracks in the solder due to uneven cooling, and SMT parts with pins that are not fully flat. In this case, the surface mount parts went on easily, and the assembly was completed quickly.
I then set up the PCB test, in which my external power supply applied a current to the sensor, by connecting the positive lead of the power supply to IN+ terminal and the negative lead to the IN- terminal. I then followed the connections by measuring the voltage output on the Vout to GND pins of PL1. Figure 4 shows the populated PCB plus the connections for testing the functions. Note the 18 AWG wires for the current input, since up to 5A will be part of the test.
An Acceptable Error
The test showed the accuracy of the sensor working well against the applied current. The Vout voltage had a 0A input value of 2.52V with a factor of 0.185V/A. This mid-5V value was used as indicated before, so that both positive and negative currents can be measured. For example, an AC signal (such as spikes and pulses that are typical in some projects) can be seen as both a voltage above and below 2.52V. Table 2 shows the values obtained during testing. Figure 5 is a graph of the input current versus the measured voltage output, showing good linearity. The graph in Figure 6 shows the error of the sensor-measured current versus the applied input current as a percentage of the difference between these two values divided by the input current. An error less than 1% occurred for currents above 1A, and a larger error occurred for smaller input currents. This error value worked well for solving our problems, since currents spikes greater than 1A caused some of our power supply errors.
A Smoother Cat Walk
I described the process and tools I used to solve a problem measuring current with our Robot Cat design, by using a current sensor. The robot’s power supply design was then changed, and the current sensor was used again to validate the correct operation of the servos. We now have a Robot Cat that walks very much like a live cat, without the servo errors we had previously observed.
By carefully identifying the problem and selecting the right devices for sensing current, the schematic design became simple. The PCB design was physically small, allowing ease of use for testing.
The data in Figure 6 show that there was less than 1% error for currents above 1A a slightly higher error for currents less than 0.5A. These results will work well for testing servos and motors which, due to the inductive component of their functions, can create large spikes that can cause power design problems.
Our Hall effect current sensor will now allow test personnel to determine the value of a current spike using an oscilloscope, and update the project power design to reduce these spikes. Figure 7 shows the clean completed project, using a 9V battery holder and a mini-voltmeter reading 2.51V, as expected for no input current. This device now provides a key addition to my test benches.
RESOURCES
Alegro Micro | www.alegromicro.com
Microchip | www.microchip.com
Design Spark PCB | www.rs-online.com/designspark/home
REFERENCES
[1] Allegro Hall Effect Current Sensor ACS712ELCTR-05B-T datasheet:
https://www.allegromicro.com/~/media/Files/Datasheets/ACS712-Datasheet.ashx
[2] Microchip MCP1703 250 mA, 16V, Low Quiescent Current LDO Regulator – datasheet:
https://ww1.microchip.com/downloads/en/DeviceDoc/22049f.pdf

Jose Rivero is a retired engineer with more than 40 years of experience in the computer design industry. He has three degrees from different universities. Over the years he has worked on the design of mini computers (when they were the size of refrigerators), embedding a computer in a cell phone (IBM Simon), underwater vehicles (Ocean Engineering at Florida Atlantic University) and most recently, designing instruments for the gas and oil industry. His interests have always been in Electronics and Computer Science. His goal is to build special robots based on improving embedded and mechanical technologies, and he is working on a Robot Cat that will walk and behave more like a cat than current internet versions.









