Close

Testing Servo Current with Moku:Lab

A project log for 2021 HDP Dream Team: EJA

Learn more about Team EJA's intelligent buoy, and how their solution will help the global fight against ghost gear.

ekEK 12/16/2020 at 00:000 Comments

Using a motor with a limited power source means that current consumption needs to be monitored, especially for small robots. To make better estimations about how to optimize power use, it would be great to see how much current is being used by the servo. In this test we’ll use the Moku:Lab with a shunt resistor to measure the current used by the servo.

For the Eja Intelligent Buoy, there is an external wiper with magnets that slides across the polycarbonate enclosure, where internally there is a similar wiper with magnets, moving with a servo. The servo is a standard hobby servo. In the future with Leo’s Buoy B version, there’s also the capability to use a DC motor. The power source is a single 18650 Lipo.

In this test, the servo will be moving from 0 to 180 degrees and back. It completes one movement from 0-180 with a delay of 15 ms between each degree, so in total taking 2.7 seconds. It will then repeat this movement the other direction after 5 seconds. With the Arduino Servo library, 0 degrees corresponds to 1000 uS, and 180 degrees corresponds to 2000 uS for its pulse width. 

The Moku:Lab is set up on Oscilloscope mode with two probes connected on input. The other ends of the probes are connected to a makeshift board with a 0.05 ohm 5W resistor. This is a shunt resistor, where the two probes measure the voltage differential, and from there we can calculate the current using Ohm’s Law. Check out this guide for some useful tips about this. Here’s a Digikey search to find similar resistors.

Image source: Vivekanand - CircuitDigest

Using the Math function, we can see the result right away on the Moku:Lab. (Channel B - Channel A) / 0.05 Ohms will give us the current. Additionally, there are detail ‘widgets’ that can be added, along with rulers, to see more of the measurements. 

To gather data for the graphs, a 2 minute datalog was recorded at 10 samples per second. (And 10 is the lowest possible setting, it can go much higher - Wow!) 

Had the chance to record this testing session as a video too, check it out if you want to see the monitoring in action


There are two graphs from this data. The first measuring the voltage from the probes attached to the shunt resistor. The second showing the current value in milliamps. 

There is a mistake with the timing. The program uploaded to the Arduino was set to a 16 MHz clock. However, the ATmega328 Arduino bootloader fuses are setup to be 8 MHz internal clock. My observation is that this changes how fast / slow millis() is passed, which is used for the waiting periods. The timing for the servo movement, approximately 2 seconds, is correct both in reality and on the graph. This error was figured out when doing post-analysis, and noticing that Serial Monitor was not giving the expected result at 9600 baud, and changing the clock speed worked.

During the idle periods, it seems the reason why the servo consumes so much current — (over 500 mA at times!) — is because it is forcing the gears towards their end limit. At this point, the servo is visibly shaking and is making an audible hum. It’s trying to achieve the destination, however it cannot reach it. The cause of this could be perhaps the pulsewidth in the servo library is not the pulsewidth limits for this servo. This makes sense, as each servo is different.

What did we learn from these measurements?

What to try next?

It was fun to collaborate with both Leo and Tobi when we were doing an initial set up of this experiment. Big thanks to Leo for answering a lot of questions I had about oscilloscopes and giving pointers on setting up the experiment. Looking forward to sharing learnings from the Moku:Lab with this project and beyond too!

Discussions