Projects Research & Design Hub

Build a Motor Dynamometer

Using a PIC32 MCU

Dynamometers are a key tool for assessing electric motor characteristics. Learn how these three Cornell students designed an electric motor dynamometer to characterize the torque, efficiency and power of a small electric motor. Data is processed using a PIC32 MCU and visualized using MATLAB.

  • How to build an electric motor dynamometer to characterize the torque, efficiency and power of a small electric motor

  • How to do the mechanical design

  • How to design the circuitry

  • How to use Wheatstone bridge circuitry

  • How to develop the software

  • Microchip Technology PIC32 MCU

  • Texas Instruments INA121 instrumentation amplifier

  • Mathwork’s MATLAB

  • Analog Devices AD5231BRUZ10

  • Hall effect current sensor ACS758 from Allegro Microsystems

  • Adafruit USB-to-TTL Serial Cable

  • PuTTY

Energy-efficient vehicles provide a viable solution for clean transportation. To maximize efficiency and performance of these vehicles, accurate predictions and measurements are necessary. One way to figure out the most efficient way to accelerate a motor is by measuring torque and angular velocity. Here, efficiency is defined as the ratio of power inputted and outputted by a system. Power can be measured either electrically, as the product of voltage and current (resistance), or mechanically for a rotating shaft, as the product of torque and angular velocity (radians per second). Motor dynamometers are frequently used to characterize efficiency using input electrical power and output mechanical power of a motor.

Currently, there is a lack of diverse, commercially available, small-scale dynamometers that use simple instrumentation instead of water and eddy-current brake systems. Therefore, we designed a friction-brake-based electric motor dynamometer that can be tested on a small brushed 540 DC motor rated at around 300W, with a maximum torque of 0.1 to 0.2 newton meters (N-m). Each variable of efficiency was measured by a sensor that ran concurrently with the others. All components were housed in a mechanical setup consisting of two shafts—one spinning shaft spun by the motor, and one stationary shaft for torque measurements. The two shafts were coupled by a control brake. The data collected was run and processed on a Microchip Technology PIC32 microcontroller (MCU) and visualized in Mathwork’s MATLAB.

HARDWARE DESIGN

The mechanical setup consists of an aluminum base plate and five supports. There are two coaxial shafts: 1) a fixed hollow shaft on which our strain gauges are mounted; and 2) a solid shaft coupled to the motor that can rotate freely (Figure 1Figure 2a). For revolutions per minute (RPM) data collection, a slotted disc was fitted over the rotating shaft, and the infrared sensor (which measures RPM) was attached to the supports adjacent to the disc (Figure 2c and Figure 2d). The other end of the free shaft is where we can apply torque to the system. The brake system consists of two servos that pull on the steel braided wires of a set of bicycle brakes to close on a circular disc brake fitted onto the free shaft (Figure 2b). The servos for the brake are then attached to the hollow shaft, so that any torque produced from stopping the rotating shaft is transferred over and can be read by the strain gauges.

Figure 1 The mechanical setup for the dynamometer consists of five supports attached to a base plate and two shafts. The shaft on the left is fixed, hollow and has the strain gauges mounted on it. The right shaft is solid and spins freely with the motor. The two axes interface one another in the center, where the servos (which are attached to the fixed shaft), clamp onto the spinning shaft.
Figure 1
The mechanical setup for the dynamometer consists of five supports attached to a base plate and two shafts. The shaft on the left is fixed, hollow and has the strain gauges mounted on it. The right shaft is solid and spins freely with the motor. The two axes interface one another in the center, where the servos (which are attached to the fixed shaft), clamp onto the spinning shaft.
Figure 2 Renderings of mechanical setup using CAD. (a) Views of the complete setup. (b) Interface and connection of the servos onto the fixed, hollow shaft used for torque application and measurement. (c) Prototype design of slotted disc. This rendering also shows the connections on the spinning shaft side. (d) Image of slotted disc design used in final product.
Figure 2
Renderings of mechanical setup using CAD. (a) Views of the complete setup. (b) Interface and connection of the servos onto the fixed, hollow shaft used for torque application and measurement. (c) Prototype design of slotted disc. This rendering also shows the connections on the spinning shaft side. (d) Image of slotted disc design used in final product.

The entire system is constructed from aluminum, so that it can withstand dynamic loading well and be more wear-resistant. The system can run on two power supplies, but we increased this to four to have greater adjustability and to account for filtering for our circuitry. The high-current supply, capable of drawing over 20A, was used to drive the motor. The low-power supply was used to drive the servos, which operate best at 6V. One triple-output power supply was used to drive the instrumentation amplifier and the digital potentiometer at ±3.3V, while another acted as the excitation supply for the strain gauges. The second triple supply was also used to power the cooling fan for the motor. All the grounds are connected in a star ground configuration as common ground with the MCU ground, to minimize noise for the instrumentation amplifier and the ADC. Care was taken so that the higher voltages were isolated and would not fry the MCU.

A full schematic of the dynamometer and sensor interface is shown in Figure 3, and in this section, we will discuss each component individually. The sensors used in this design were strain gauges and complementary circuitry, a Hall effect sensor for current measurements, a voltage divider for voltage readings and an infrared sensor for RPM measurements. We also had servo motors, wiring for communication, and software developed in C and MATLAB.

Figure 3 Schematic for PIC32 Development Board, including external hardware such as the TFT display and UART.
Figure 3
Schematic for PIC32 Development Board, including external hardware such as the TFT display and UART.
(CLICK TO ENLARGE)

To measure torque and strain on the shaft, we used two strain gauges (packaged into one pad), which measure small values of strain, or deformation on an object. As torque is applied to the shaft, the foil/wire that makes up the strain gauge undergoes tension or compression, causing a change in electrical resistance. To measure change in resistance, we use the “gauge factor,” a property that determines sensitivity of the gauge. The equation for the gauge factor (GF) is:

— ADVERTISMENT—

Advertise Here

where ΔR is the change in resistance, R is the resistance at no load and ε is the strain. Since the change in resistance can be as small as microohms, a Wheatstone bridge circuit is used. The bridge balances two legs of the circuit in which one or more resistances can be variable. A simple example is a bridge circuit in which there are three passive resistors and a single active resistor (Figure 4a).

The passive bridge equation is:

As shown in Figure 4b, we use a bridge circuit with two strain gauges, where one gauge undergoes compression and the other undergoes tension to increase sensitivity of the bridge. The other half of the bridge is used for self-balancing, with a digital potentiometer as a variable quarter resistor and a static quarter resistance. This allows the software to auto-balance and zero the bridge upon initialization.

On the shaft, itself, the strain gauges are mounted ±45 degrees to the torsion axis, since in pure torsion, the maximum normal stress due to transverse shear stress occurs at 45 degrees to the original plane. Therefore, 45 degrees from the shaft’s axis is where the measured stress directly correlates to the applied torque. We calculated the tube size necessary for the range of strain using the equation:

where T is torque, C is the radius and J is the polar moment of inertia. We calculated 0.5” OD (outside diameter) and 0.468” ID (inside diameter), which gave us 2,000 micro-strains at the max torque of 5N-m, and has a safety factor of 1.5 (Figure 4c). To tune the system, we hung a 500mm bottle of water at a known distance from the axis of the tube, and determined a ratio between the expected torque values (0.417N-m) and the ADC. Error in calibration was approximately 0.03N-m (Figure 4d).

Figure 4 (a) Quarter Wheatstone bridge. The ratio of R1/R2 must be equal to R4/R3, since VO is zero and the circuit is balanced. Any change in resistance will unbalance the bridge and result in a non-zero output voltage. b) Our half-bridge Wheatstone containing two strain gauges on the right branches, and a passive resistor and self-balancing digital potentiometer on the right. c) Strain gauge diagram. d) “Water-Bottle Method” for calibrating strain gauge measurements.
Figure 4 (a) Quarter Wheatstone bridge. The ratio of R1/R2 must be equal to R4/R3, since VO is zero and the circuit is balanced. Any change in resistance will unbalance the bridge and result in a non-zero output voltage. b) Our half-bridge Wheatstone containing two strain gauges on the right branches, and a passive resistor and self-balancing digital potentiometer on the right. c) Strain gauge diagram. d) “Water-Bottle Method” for calibrating strain gauge measurements.

Since the change in resistance is relatively small, we used a Texas Instruments INA121 instrumentation amplifier to amplify the output voltage of the Wheatstone bridge.
A gain of 500 (with a 100Ω variable resistor) was chosen, because with a 3V excitation voltage, a delta of 1mV to 2mV was expected at the half-bridge output right before amplification, when the brushed motor was at maximum torque (about 0.1N-m to 0.2N-m). Thus, the output of the amplifier ranged from 0.5-1V, which is measurable by the ADC. A set of sockets was mounted on the solder board to add additional resistors and modulate the gain for future measurements. We also observed that the system could run under a higher excitation voltage of 5V without saturating the amplifier.

We then combined the Wheatstone bridge and instrumentation amplifier. To achieve finer resolution, we used a 10-bit Analog Devices IC 10kΩ digital potentiometer (AD5231BRUZ10) for the self-balancing quarter of the static half of the bridge. We interfaced with the potentiometer using serial peripheral interface (SPI) protocol, and used the chip select, clock and serial data output on the PIC32. Using 32-bit control words with the most significant bit (MSBit) as 0xE or 0x6 (based off the reference sheet), we can command the potentiometer to increase or decrease by a resistance of 1/1,024. The potentiometer, with a resistance of 8.6kΩ, was put in series with a 15kΩ resistor and balanced against a 20kΩ resistor. This achieved a theoretical balance of accuracy of 0.05%, and a measured accuracy of 4%-5%.

WHEATSTONE BRIDGE

To filter noise, we place low-pass RC circuits with a cut-off frequency of 20Hz (R = 800Ω, C = 10µF) were placed at the input of the Wheatstone bridge and at the output of the amplifier. Additionally, because the readings from the strain gauges can be small by themselves, we attached the circuitry for the strain gauges close to the mechanical setup to eliminate noise that could arise from long wires. Any critical signal wires carrying microvolt signals were shielded and grounded with an aluminum foil jacket.

The output of the filtered instrumentation amplifier is wired to the third ADC channel on the PIC, and is read after the initial calibration period. The raw_p value is used to do a low-pass filter and determine the strain on the shaft. The equation for this digital IIR filter is:

— ADVERTISMENT—

Advertise Here

where strain_filt is the filtered strain value, raw_p is the raw ADC input and 16 is a set time constant. strain_filt is initialized to is the first raw_p value read after the calibration period. Then, torque is calculated by taking the difference between the current strain_filt and the init_strain (initial strain) and dividing by a constant to convert to newton-meters. This constant was determined by the water-bottle method described above.

We measured the current from our motor voltage source using a Hall effect current sensor (the ACS758 from Allegro Microsystems) (Figure 5). The sensor outputs a voltage level that is proportional to the input current. This voltage is fed to an ADC on the PIC32, for use in further calculations. Calculation and calibration are required, however, to convert the ADC readings into amperes. First, the ADC readings are mapped to voltage readings by matching the upper limit of the ADC (1,024) to the supply voltage used (in this case 3.3V). Next, we found the change in amps per change in volume. We measured this by applying currents every 0.25A from 0-2A and measuring the voltage read by the sensor. Once enough trials had been conducted, we calculated the average change in voltage per amp and used that as our conversion factor. The datasheet lists the sensitivity of this part as 40mV/A, and our testing confirmed this value.

Figure 5 Full system diagram, including separate sensor schematic sections linked to the corresponding sections of the motor dynamometer Pin connections are shown from sensors to PIC32 pins.
Figure 5
Full system diagram, including separate sensor schematic sections linked to the corresponding sections of the motor dynamometer Pin connections are shown from sensors to PIC32 pins.

The last step for calibration was accounting for the offset in the ADC measurements. We did this in software by subtracting the ADC value measured when no current was applied. During our testing, we observed an ADC value of 128. The calculations required for calibration are as follows:

Next, the motor input voltage was measured off a voltage divider parallel to the power supply (Figure 5). The output of the voltage divider was at a 1:3 ratio with the power supply, to protect the pins of the microcontroller.

To measure the rate of the motor, we used a photo interrupter—an infrared light sensor that can detect when an object passes between two uprights. One of the uprights on the sensor contains an infrared emitter and the other contains an infrared emitter (Figure 5). When the gate of the sensor is clear, the oscilloscope shows a straight line at approximately 5V. When something obstructs the gate, the signal drops to approximately 0V. By tracking the change in voltage and recording the frequency with which it changes as the shaft rotates, we can measure its angular velocity, or revolutions per minute.

Controlling the servos was challenging, because they essentially have an internal control system that reads a pulse width modulation (PWM) high-pulse between 1ms to 2ms (on the white signal line, red for power and black is common ground), and sends the servo to maintain the proportional angle. So, if we send a 1ms pulse, the servo goes to its minimum position, and at 2ms, it goes to its max. We used digital servos, which responded faster than analog ones, and were more precise in their maneuvers.

Our motor controller for the DC motor malfunctioned, so we switched to varying the voltage on the high-current supply for control. However, this method is very much the same as the servo controls: 1.5ms duty cycle for neutral, and 2ms for full forward power.

SOFTWARE DESIGN

Our software components can be divided into two sections: the PIC32 and the PC. The PIC32 handles data acquisition from all sensors and transmits to the PC via UART communication (pin RB8, RA3). In the programming for the PIC32, we also have our own preset sequence to collect data. The PC receives data output from the PIC32, which is then analyzed in MATLAB.

To summarize our data acquisition, first, upon reset, the system begins to run our preprogrammed test sequence. The test sequence uses the first 120 seconds for calibration of the strain gauges and digital potentiometer; during this period the servos remain opened, and sensor data is not sent over UART.

Next, the baseline, no-load RPM is measured with the servos completely released. This value is used to calculate the next desired RPM value for the sequence. Our sequence measured 5% decrements of the no-load RPM value (95%, 90%, 80% and so forth) up to 55% of the baseline RPM value. For each rate to be measured, the program measures the current angular velocity read by the photo-interrupter data, and steadily adds load to the brake disc by increasing the PWM supplied to the servos.

Data transmission is paused while the servos engage, until they reach the desired RPM rate. This increases the accuracy of our measurements for torque, which is a running average, by eliminating values corresponding to undesired RPM values. Once the desired RPM rate is reached, the program transmits the corresponding value, torque and efficiency data to the computer. This data is recorded as a running average over a 4-second period. After the 55% no-load RPM measurement is complete, the sequence waits for 5 seconds before repeating the loop and measuring a new baseline value.

To get new data, we had to reset the system, which enabled recalibration of the strain gauge. Initially, we wanted to take data by decreasing the rate by 10%. However, we found that if the RPM rate got too low, then the servo would immediately stop the rotating shaft and the system would stall, since RPM could not get any lower.

The UART protocol was used to serially transmit the servo rate RPM and voltage from the PIC32 to the computer with an Adafruit USB-to-TTL Serial Cable, and was then logged in PuTTY. A sample output from PuTTY is shown in Figure 6. We processed and visualized the data with a contour map in MATLAB (Figure 7). The contourf function in MATLAB was used to produce the map.

Figure 6 Example output from PuTTY during preprogrammed sequence. Each line prints out the measured rate in RPM, torque, and calculated efficiency for the various desired rates. Negative values of strain automatically translate to zero efficiency.
Figure 6
Example output from PuTTY during preprogrammed sequence. Each line prints out the measured rate in RPM, torque, and calculated efficiency for the various desired rates. Negative values of strain automatically translate to zero efficiency.
Figure 7 Example contour map produced from MATLAB code. The axes are RPM and torque are on the X-axis and X-axis, respectively. Additionally, efficiency is reflected as a color scale, with yellow being the highest efficiency.
Figure 7
Example contour map produced from MATLAB code. The axes are RPM and torque are on the X-axis and X-axis, respectively. Additionally, efficiency is reflected as a color scale, with yellow being the highest efficiency.

We first parsed the data file, which had ten rows with each row containing the RPM, torque and efficiency collected in real time. To visualize efficiency of a motor, a contour map is frequently used, because motors have a large operating range, and an efficiency value for each operating point can be observed with a contour map. In this case, the RPM values are on the X-axis and torque on the Y-axis.

The efficiency is on the Z-axis and is mapped to the respective (speed, torque) values. The contour map was produced by creating a 100-point, linearly spaced vector with ten data points. We, then created two-dimensional grid coordinates of the RPM and torque, which was fit to efficiency and then interpolated.

— ADVERTISMENT—

Advertise Here

RESULTS AND CONCLUSIONS

After visualizing data on the contour map, we observed peak efficiency within a range of 10,000RPM to 11,000RPM (yellow region) and 0.05N-m to 0.07N-m of torque (Figure 7). The maximum torque was a little less than 0.1N-m, but maximum power required a slightly lower torque and higher RPM. Moreover, as the RPM increases, the torque and efficiency also decrease. A systematic sweep, however, is necessary for more detailed results.

We observed small volatility in data. However, our calibration system (water-bottle method) suggested that these errors were due to drift when calibrating, because slight adjustments made with the water bottle changed the value of the torque constant. Our software calibration also used static values based on calibrations of our circuit when calculating ADC values, voltage and current—which could also cause error or drift during calibration. Below is the video of our project.

The purpose of this project was to design and build a friction-based motor dynamometer with a power of approximately 300W. Given the scale of the project, we found that overall, the mechanical and electrical components were well integrated and responded to the test sequence almost autonomously. Additionally, given the data we collected, this design seems viable for future testing with larger motors.

We prioritized the accuracy of our system over the speed of execution by slowing down our testing sequence. For example, in the final version of our dynamometer code, the test sequence allows for 120 seconds of calibration instead of the previous 45 seconds. This change gives the digital potentiometer nearly three times the time to zero out and balance the Wheatstone bridge. The extra time also allows lower voltages to be sent to the motor during calibration, instead of having to immediately turn up the voltage for testing, lowering the effect of vibration on calibration. However, further improvements need to be made to increase the speed of execution.

To improve testing, the test sequence can be modified to loop back after the voltage supply has been changed, so that multiple trials can be run and logged in the same file. This can also be improved by integrating the motor controller for the brushless system to sweep a larger set of data points. Data processing can also be improved by testing various filters and zeroing algorithms. 

RESOURCES

E. Dlala, “Advanced Design of Electric Motors”, Ansys Blog, 2013.

A. Cartwright, “Tutorial: How to use the ACS758 Hall effect current sensor module with Arduino! (to measure current)”, YouTube, 2016.

Analog Devices, “Nonvolatile Memory, 1024-Position Digital Potentiometer”, 2017.

Allegro Microsystems, LLC, “Thermally Enhanced, Fully Integrated, Hall-Effect-Based Linear Current Sensor IC with 100 micro-ohms Current Conductor”, 2017.

“The Strain Gauge”, Sensorland.

Sharp, “GP1A57HRJ00F”, 2005.  {Jeff—does this make sense to you?}

Adafruit, “USB to TTL Serial Cable – Debug/Console Cable for Raspberry Pi”, 2016.

National Instruments, “Strain Gauge Measurement – A Tutorial”, 1995.

A. Harrington, C. Kroninger, “Characterization of Small DC Brushed and Brushless Motors”, Defense Technical Information Center, 2013. 

B. Land, “Cornell University ECE 4760 Designing with Microcontrollers Fall 2017”, Cornell University, 2017.

Adafruit | www.adafruit.com
Allegro Microsystems | www.allegromicro.com
Analog Devices | www.analog.com
Mathworks | www.mathworks.com
Microchip Technology | www.microchip.com
SparkFun Electronics | www.sparkfun.com
Texas Instruments | www.ti.com

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • AUGUST 2021 #373 – Get a PDF of the issue

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the May 2020 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article
+ posts

Erika Yu is an electrical and computer engineer at Johns Hopkins University Applied Physics Laboratory, developing software for embedded systems. She studied Electrical and Computer Engineering at Cornell University.

Aasta Gandhi is a software engineer at Elastic Compute Cloud in Amazon Web Services, working on optimizing customer experience on burstable instances. She studied Electrical/Computer Engineering and Computer Science at Cornell University.

Kowin Shi works as a hardware engineer, building self-driving vehicle computers at Aurora. He studied ECE and ME at Cornell University. Website: www.kowinshi.me

 

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2023 KCK Media Corp.

Build a Motor Dynamometer

by Circuit Cellar Staff time to read: 14 min