Sojourner Generation 4
Back EMF Experiment
By: David Garcia
Table of Contents
Comparing Designs
When we started this process, the first useful circuit we found was on a site called precision Microdrives. There was an article detailing gathering back EMF data. This article was very helpful in furthering our understanding of the actual process being used to gather our data. The first problem was in the name of the process when a more accurate description would have been a regenerative mode for RPM estimation.
The actual description would be more like using the DC motor as a generator off and on rather than to couple the back EMF in some way.
Figure 1 – Voltage Generation to RPM Theory
From this basic understanding of how the testing works, we start to move our way towards a way to capture the data in the RPM. Before we get to coding we ended up first trying to capture a scope picture of the BEMF data and see if we can find a way to deal with both directions of the motor rotating.
Rapid Prototyping
The first circuit we tried ended up giving us very little and that was likely due to the inability to reliable trigger the BJT.
As we analyzed the circuit it became clear that most of the circuit was simply used to trigger the motor to run and we could replace that with another circuit more easily controllable from an Arduino.
Figure 2 – L298N Unsuccessful Test Circuit
This was the second attempt we ended up using for the testing. The L298N module is easily controllable and set up.
While uncertain why testing across the capacitor in this way didn’t give us anything but noise. We also sometimes ended up with classic damped harmonic waveforms.
Another Circuit we tried to remove the cap and instead add a resistor in line with the diode and measure cross the resistor. Repeated measurements of the terminals of the L298N and ground showed it was only a few millivolts above ground.
This circuit still has the disadvantage of not being able to be run in both directions. Any solution implemented would have to be able to be run in both directions if it was going to be of any practical use.
Figure 3 – L298N Test Circuit
A Final Design
We didn’t want to have to give up two lines from each motor in order to be able to use this method of encoding. In order to be able to do this, we needed to come up with a solution using a multiplexer and a polling method on the motors to take them individually.
Figure 4 – MUX circuit block Diagram
A multiplexer which would work perfectly for the 8 lines we need for the motors and the line out to connect to the rectifier and then the ADC would be CD4051B
Figure 5 – TI CD4052B Multiplexer
We wanted to make sure we could measure in both directions as the motor was being polled. Rather than use passive components such as a full bridge rectifier we did some research into active rectifier circuits. Northern Illinois University outlined, in a PowerPoint, some very useful resources on active rectifiers.
We also found an application note from Texas Instruments on making a full wave side input rectifier.
Figure 7 – TI Low Voltage Rectifier
Iterative Code
A finite state machine was designed to deal with the initial spike of voltage after disconnecting voltage from the motor. The motors are controlled via a PWM wave so the sampling has to take place between when the motor is being supplied voltage and prior to the start of the next wave.
This has to be triggered by an interrupt pin on the falling edge of the PWM wave. The first FSM state deals with the delay. If the delay is not appropriately long then we would take samples of the initial voltage spike and our readings wouldn’t be accurate.
The second stage is when we would implement a circular buffer and take a running average of the generated voltage which is proportional to the spinning of the motor. Once enough samples are taken we leave the sampling state and head to a state where the speed is updated.
Figure 8 – Finite State Machine Diagram
For testing purposes, the normal stage jumps between printing the RPM value and recalculating the RPM from the buffer. Because serial print takes so much time, separating it from the data collection and delay is the only way to get an accurate value out.
Testing
Figure 9 – Fritzing Diagram Test Circuit
This circuit was used to test in a single direction. The next stage of this testing would be to move to the 3Dot board and write a code using assembly, in order to optimize the delay and sampling.
Results
Before left campus, we did have some success with the circuit. We would have hoped to have taken more care with our measurements before leaving but we were somewhat set back when leaving. The green signal is the PWM wave that controls the voltage to the motor. You can see the yellow trace suddenly raise as the motor shuts off. We were able to get a similar result from our equipment.
Here you can actually see the spikes that we have to avoid measuring by the software delay shown in the previous finite state machine picture.
Results With CE Gain Stage
The Back EMF signal was approximately 200 mV before amplification, so in order to be picked up by the ADC properly the CE Amplifier was designed and chosen for use. The Common Emitter stage is used for amplification, and as we didn’t have MOSFET BJTs to implement our design in time. We decided to use the 3904 NPN transistor as our tool for amplification. To do this, we amplify Vin. Looking at the LTSpice model Vin goes into base of our Common Emitter Amplifier, the output is taken from our Collector (C1 to R5).
In our LTSpice model to test our circuit properly, we have made use of a sinusoidal waveform for our input voltage. The CE Amplifier inverts the signal, so if fed into our actual circuit we are to design it would be acceptable. This is because we are already planning on using a full-wave rectifier before taking an ADC reading.
Design Parameters
Vcc was chosen to be 3 in order to center the supply. The wave should center on the supply in order to receive the maximum swing in our amplifier. With the design parameters of Ic=1mA and Vce=1v; we were then able to solve for the resistor values in our amplifier. Once the values were put into LTSpice, we were able to verify the calculations from above to the operating point in the LTSpice model.
With the design parameters established, we were able to produce a working CE gain stage circuit into our Back EMF method. The pictures below show that the operating is biased properly against our simulation. To compare our values in simulation were Vc=2.89 Volts, Vb= 1.69 Volts and Ve=1.04 Volts. Our realistic values were Vc=2.71 Volts, Vb=1.74 Volts and Ve= 1.11 Volts.
Above is the built CE circuit use for testing.
The above pictures are placed through the CE Gain Stage, making it easier to send the voltage to an ADC. Before the ADC stage, our voltage value was around 0.2 Volts. The output values of our waveform now have a value of around 1.75 Volts. This gain we saw was a value of 8.75. We took three scope pictures to help see the different speeds of our motor and how the output would look. From left to right we have: 200 PWM, 150 PWM and 100 PWM.
These scope pictures were also much more well aligned with a major grid line. Previous scope pictures were wildly inconsistent and difficult to interpret. This was a major lesson learned from the past.
Inclusion of this simple gain stage will make our BEMF output much more readable when heading into an ADC. Further amplification might include using a cascode configuration of biasing the base of our transistor with a specific valued Zener diode being reverse biases. Depending the ease of implementation, an op amp would work to provided a highly tailored gain.
Conclusion
Although proving to be troublesome in theory at first, the Back EMF method was quite practical for sensorless encoding. The Back EMF method proved to be viable in which code could be planned around the distance and delay between the two spikes after the PWM signal. We were able to test the Back EMF method of sensorless encoding for the motor running forwards, to run it backwards, we would implement a way to know when the voltage hits zero, as this would be a turning point for the voltage running in a negative direction. Since the spikes would be negative, we would need the active full-wave rectifier to solve this problem.
References
- Precision MicroDrives – Measuring RPM from Back EMF
- L298N Driver Board
- University of Northern Illinois – Wave rectifiers
- Texas Instruments – Single-Supply Low input Voltage Full Wave Rectifier