|Surveyor Robotics Journal|
Sun, 10 Jun 2007
Measuring SRV-1 motor speed using a comparator for Back EMF zero cross detection
We have considered a variety of approaches to adding motor speed measurement to the SRV-1, including optical encoders and hall-effect sensors, but liked the idea of measuring back EMF as an alternative, as it required no additional sensors. Instead, it works on the principle that a motor acts as a generator when free spinning, and the output voltage of this generator is proportional to the speed of the motor.
In the most simple application, bEMF is measured by occasionally turning off a motor to let it free spin, sampling the generated voltage, then turn the motor back on again. The only problem with this approach is that the LPC2106 ARM7 processor has no A/D converters, so there is no easy way to capture the motor voltage level on the SRV-1.
However, there is a solution which uses a simple comparator circuit. If you look at the waveform of the signal from the motor when spinning (without power), there's an AC ripple on top of a DC offset. The DC offset value corresponds to the output voltage of the motor acting as a generator. The AC ripple corresponds to variation in the DC as the active armature coil moves through the magnetic field of the fixed motor magnets.
Because our ARM7 doesn't have an A/D converter, measuring the DC offset isn't possible. However, measuring the "zero crossings" of the AC ripple would be quite useful, as the motor is driving a 100:1 gearbox, and the motor has a 3 poll armature, so we get 600 cycles or 1200 zero-crossings per hub revolution. Because the SRV-1 normally operates at 2-4 hub revolutions per second, it seems that we just need a high pass filter to take out the DC component and band-pass a 1200-2400Hz signal into a comparator. However, in our measurement circuit, we don't want to screw up the PWM drive with the filter components. Also, each comparator (one for each motor) will generate a digital signal that feeds the digital i/o inputs of the ARM7, and we have to be careful to isolate the motor voltage levels from the 3.3v logic levels of the ARM7.
In searching for a solution, I came across a very helpful circuit design website - http://www.discovercircuits.com, and actually found a schematic for a wide band zero cross detector. It uses an LM393 dual comparator ($0.25 part), along with a handful of resistors and a couple of capacitors. The circuit indicated an input frequency range of a few kilohertz to 150kHz, and our signal is in the range of 1200-2400Hz, though it seemed like the input frequency range might be a lot lower, so it seemed worth the effort to build the circuit and then tweak the filter components.
First, a free-standing motor was attached to the circuit and spun by hand. Here are some scope traces that show the results a 2 different motor speeds ...
The results were a lot better than expected. The digital output signal from the comparator is nicely formed, and even the false trigger caused the spike caused by a noisy armature brush on this particular motor (seen every other cycle) can be clearly identified and filtered in software. Actually, it's fortunate that I grabbed a noisy motor, because most of the other motors I checked don't show this brush bounce spike.
Just to check that electrical noise from the motors would not couple back into the 3.3V supply, I connected one of the motors on an SRV-1 to the circuit, and ran tests with the motor power on and off, and didn't see any problems. Here's a schematic of the modified circuit -
The next step is to build a circuit board which interfaces to both motors and mounts on the SRV-1, and then to write some firmware that samples the motor speed through this bEMF mechanism. The bEMF speed has to be actively sampled (this isn't a background task), so this sensor won't accumulate distance traveled (like a rotation counter), but it will be useful for stall detection, closed loop motor control, and odometry estimates.
There is a continuing discussion of this project on the Surveyor Robotics Forum at http://www.surveyor.com/cgi-bin/yabb2/YaBB.pl?num=1181167494
Migrating SRV-1 services from Microsoft Robotics Studio v1.0 to v1.5
This past week, we launched an effort to migrate the SRV-1 services to MSRS 1.5 (CTP May 2007) and encountered a number of problems. We have worked through all of these, and here is a wrap-up of what we found:
The migration process should have been straight-forward. The SRV-1 project files found at http://www.surveyor.com/MSRS.html are first installed in "C:\Microsoft Robotics Studio 1.5 (CTP May 2007)\samples\Platforms\Surveyor\SRV-1". MSRS 1.5 provides a utility called "DssProjectMigration.exe" which is applied to the SRV-1 project from "C:\Microsoft Robotics Studio 1.5 (CTP May 2007)\samples\Platforms\Surveyor\SRV-1". At that point, it should be possible to run "BuildSolution.cmd", but this generates a lot of errors. So resolve these errors, the follow steps are required:
So in the mean time, continue to use the SRV-1 services with MSRS version 1.0. We will post a code update when the corrected version of MSRS 1.5 has been released.