Craig Macomber, Milda Zizyte
June 10, 2011
Introduction
Often, humans are faced with the problem of finding that which they cannot see. The five senses are limited and in particular do not extend to wavelengths outside the audible or visible spectrum. Auxillary devices employing sensing solutions are thus required to augment the senses.
Such sensing capabilities are conceivably very important. In the area of electric sensing, a person might want to locate power behind a wall or want to figure out the closest source of power in a busy room.
In particular, humans cannot easily locate electric fields. However, given sufficient hardware and clever filtering, it is possible to detect the 60 Hz electric fields emanating from wall outlets and the cables attached to them. [1] uses such a scheme, with a copper-coated electric plug face as one electrode and the ground prong of the plug as another, to scan for such fields and allow a robot to effectively “feed itself” by guiding itself to power.
In fact, the robot Marvin faces the same problem humans do - just as a robot cannot see these electric fields, neither can humans. Our project aims to provide human perception of such phenomena by hardware which translates an electric input into minimal visual feedback. We thus achieve the analog of an electric studfinder - a device which senses otherwise invisible objects (obscured by obstacles or otherwise) and conveys them with a few blinking lights. In fact, our solution provides enough information for a user to be aware of electric cables in the wall to prevent from drilling into them!
Our solution combines analog filtering with digital processing to achieve its goal. It is an easily adaptable and potentially portable device with many possible applications and implications.
Analog Hardware Design
The analog circuit has three main purposes:
- To receive and filter an input electrode current into a clear voltage output signal
- To convey the output using minimal complexity
- To effectively interface with an Arduino Uno for digital processing
(1) is the most complex, requiring filtering a current source. A MCP6024 quad op-amp package is used for this purpose, and is described in a later section.
(2) is accomplished by the use of three LEDs, denoted “left,” “right,” and “amplitude.” In this way, we can convey both direction and strength of the electric field by modulating brightness. This seems like the most natural and unobtrusive way of translating electric fields to a “human-readable format,” as it is less irksome than audio output and easier to implement, as well.
(3) strongly depends on (1) and (2). In particular, the Arduino places constraints on how many wires we can use and the form our outputs take. We opted two use two analog input pins post-filtering, and three pulse-width modulated pins for outputs into the LED.
An overview of our circuit is thus figure 1. EL and ER denote the left electrode signal and right electrode signal, respectively.
Electrodes
Our electrodes, or antenna, are simple in design. Due to the low operating frequency, there are no real restrictions on what shapes pick up a strong signal. Our design needed to meet two requirements: producing a sufficient signal, and providing a directional differential signal. With our antenna's two electrodes are simple copper tape rectangles. The length of the tape, which sets the height of our antenna determines the signal strength, and the separation sets the directional sensitivity. A good balance of both is required to be able to both detect a signal from a significant distance, as well as to tell what direction it is coming from. Our final shape was mostly determined by supply available, and some guessing about how much signal we needed based on our original smaller electrodes. Our final measurements are 300 mm across, 240 mm high. The makes the electrodes 25 mm by 240 mm with a separation of 240 mm (265 mm center to center).
Also, the symmetry is very important: both electrodes are the same area. Otherwise, our differential zero point would be off.
We chose acrylic to mount the copper tape on for three main reasons:
- It is a good insulator. The plastic used is scrap from an old electrostatics project and was originally selected for its insulating properties. If the substrate for our antenna were a conductor, our two electrodes would be connected, and we would lose the directional signal.
- It is transparent. This makes it much easier to see what one is doing when using it near the source its detecting, as is the case when following wires in walls.
- We had some available. There are plenty of other materials that would have also worked well, but we simply chose the one we had in the correct size.
Filtering
The circuit shown here provides a current to voltage conversion, followed by a low pass filter tuned to easily pass anything near 60 Hz or lower. Since there is vastly more 60 Hz signal than any nearby or lower frequency, a sharp cutoff was not needed.
Notice that our cutoff frequency is:
(1)Our original filter had a resistor value of twice that for an 80 Hz cutoff. Experimentation yielded less than satisfactory results, so we decreased our resistor value. This still cuts off most high frequency noise, as we are mostly worried about noise in the kilohertz and above.
We went for a simple active filter along with some additional gain. This design allowed all the needed analog filtering using only two op-amps per channel. Thus, we only needed four op-amps total, one package.
The transimpedance stage, which converts the electrode's current signal to a voltage signal uses a 2M resistor. Some experiments were run on what values worked best.
The second stage, an inverting low pass amplifier with a cutoff frequency of 160 Hz and a gain of 50. This removes high frequency noise, and brings our signal up to an accurately measurable size.
Output
We opted for a simple output of three LEDs. Two of them are directional and almost directly correspond to each component of the antenna. The third is a magnitude antenna, which helps the user distinguish how strong the observed signal is. No analog magic is used for this part of the circuit: there are just the conventional resistors to ground, and everything else is driven by digital logic, discussed in the next section.
Pulse-Width Modulated pins were used for the LEDs so that we could control their brightness using the Arduino.
Throughout the development and testing process, we tried a few different display approaches. Initially we simply had one output, which when low, lit one light, and when high lit the other. Initially this was a digital output, simply high or low. When the antenna was pointed at the field source, both lights would flicker and it would be confusing. We then converted to using pulse width modulated outputs. This helped, but we found both lights coming on to be not very useful, which lead to the final design. Only one light is on at once, and the brightness depends on the amount that the antenna needs to turn. To make out full level of sensitivity apparent, we multiplied up the signal so the LEDs saturate pretty early, and its easy to see small angular differences.
Firmware
The comments explain the code in detail. At a high level it reads in the two signals, and uses an IIR filter to computer the mean. It then subtracts the mean from the signals removing the DC offset. Finally the signals are rectified and smoothed with another IIR. It then takes the difference of the absolute magnitudes to get direction, and output that to the left and right LEDs. We also apply an IIR to our magnitude LED to smooth out flicker.
We experimented with several values for both $a$ and $b$ in our code. As the purpose of the LEDs is to convey first-nature, intuitive information about what the antenna senses, this experimentation was not precise. We noticed a trade-off between “flicker” (how much and how often the signal changed in a distracting fashion) and speed (how quickly the LEDs mimicked the action of changing the configuration of the antenna) and settled on some values that generally worked well. Depending on use case, these values may need to be readjusted.
// These constants won't change. They're used to give names // to the pins used: const int left = A0; // Analog input pin for the left electrode const int right = A1; // Analog input pin for the right electrode const int leftLED = 11; // PWM pin for the left LED const int rightLED = 10; // PWM pin for the right LED const int ampLED = 9; // PWM pin for the amplitude LED const float a = .2; // filter value for the left/right IIR low-pass filter const float b = .008; // filter value for the output IIR low-pass filter (for smoothing) // used for IIR static float leftmid = 0; static float rightmid = 0; float signal = 0; // difference of the filtered left/right signals // used for IIR static float signalLeft = 0; static float signalRight = 0; // writing to serial at intervals int count = 0; void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); // initialize pins: pinMode(left, INPUT); pinMode(right, INPUT); pinMode(leftLED, OUTPUT); pinMode(rightLED, OUTPUT); pinMode(ampLED,OUTPUT); } void loop() { // Read in the values int l = analogRead(left); int r = analogRead(right); // Apply an IIR to each one leftmid = a*l + (1-a)*leftmid; rightmid = a*r + (1-a)*rightmid; // Take the magnitude without the DC components float left = abs(l-leftmid); float right = abs(r-rightmid); // Smooth them out with another IIR signalLeft = left * b + (1-b)*signalLeft; signalRight = right * b + (1-b)*signalRight; // Take the difference (negative signal means more input on the right; positive means more on the right) signal = (signalLeft - signalRight); // duty factor for amplitude output: just the sum of the amplitudes we've seen int df = min(255,(int) (signalLeft+signalRight)); analogWrite(ampLED,df); // Output to the LEDs: the *32 is to favor a large signal in one of the LEDs, but if the signal is in the middle, both LEDs are going to be dimmer analogWrite(leftLED,min(255,max(0,signal*32))); analogWrite(rightLED,min(255,max(0,signal*-32))); // Print what we see to the monitor for data collection if(count == 0) { Serial.println(signal); } count = (count+1)\%100; }
Characterization
We performed several experiments and measurements to evaluate our circuit. They are as follows:
Noise measurement
For this experiment, we simply held the antenna away from any visible powerlines in the middle of an isolated area. We took 234 samples from the arduino serial input with the antenna tilted both ways. Our results are outlined in table one (the output is the filtered analog $signal$ value as seen in the code above):
Average | Standard deviation | |
---|---|---|
First orientation | -0.08 | 0.138 |
Second orientation | -0.18 | 0.120 |
Since two positions were identical except mirrored swapping the electrodes, the bias can be computed as the difference of the two means. These results show little bias in the inputs, only 0.10. If desired, this could be reduced by some calibration. Calibrating out the bias would require two adjustments. The first to remove the zero signal offset measured here, and a second to scale the data to compensate for multiplicative errors.
The noise was of a comparable scale to the bias, also very small.
Signal to Noise Ratio
We also took samples of a strong signal (the antenna close to a power outlet with a cord in the wall, which was our strongest pick up) and measured the mean and standard deviation: the mean turned out to be 163.86, and the standard deviation 2.43. This leads to a signal-to-noise-ratio of
(2)Unfortunately, looking at the details for this data, it seems likely that some of the signal was clipping, so it is not an accurate measurement.
Using some of our other data from the antenna in a strong field, 30 cm from an extension cord, we computed this:
(3)This includes the variations from not holding the antenna still, and is still quite good. Since our data used here was with the antenna oriented to produce low differential signal, the signal value is taken from the same position, but with a different orientation to measure the actual field present. Using the sum for this would have been better. Further data collection to measure the SNR under more conditions would provide more detail, but currently we do not have such data.
This high signal to noise ratio was achieved by averaging over a long period with our IIR filter. It comes at the cost of somewhat slow response times, however for our uses, the response was plenty fast.
Rotations
We performed several experiments with rotating the antenna with a fixed centerpoint, including the following:
These were all rotated by hand, which is not easy to do accurately. Even the strong and clean signals show some distortion, and the non-uniform rotation speed is probably part of the cause. Also, in some of the tests, rotation started a little way into data collection leaving a flat spot at the beginning. With this taken into account the graphs all resemble a sine waves of various amplitudes with varying clarity.
If we assume the field is a uniform linear gradient with no curl (which is somewhat close to reality when far away from the source), an ideal version of our sensor would produce a sine wave. Thus, the sine wave was the expected result. The zero crossing show where the antenna's normal is inline with the field gradient (meaning its pointed at or away from the source), and the peaks show where the antenna is inline with the field gradient (the field source is in the plane of the antenna).
Even the weak signal from the wall socket alone (which was partly shielded by a metal face plate) still produced a sign wave in our 1.5 m test. This shows that we can still detect the direction of a socket from 1.5 meters away. The direction might not be too accurate, but it should be good enough to get closer where a more accurate signal would be available.
Distance Variation
Another experiment was keeping the antenna in the same orientation parallel to some walls in a hall and moving it away from a visible socket, recording the data. We plotted the results as follows:
These plots show 2 types of saturation related failures. The first shows that even if there is a strong differential signal, it can fail to be detected if both channels start clipping. At the beginning, we suspect the signal is so strong that the difference partly hidden by this effect. This however only seemed to be an issue in the most extreme case of the antenna sideways and up against the outlet.
The second plot shows the total sum amplitude, not difference. It shows the clipping, and a sharp falloff with distance. Since it is measuring the derivative of the electric field which falls off with the square of the distance, the signal is expected to drop off with the cube of the distance. While we can not accurately tell the shape of the curve, it looks like it is not clipping it may be roughly the expected proportional to $\frac{1}{d^3}$ where $d$ is the distance from the source.
Conclusion
After looking at our LEDs, as well as some numeric data, we discovered a few things about our design. One is that we can get some clipping issues. This was not apparent from just looking at the LEDs, but perhaps we could get better signals for close/strong sources if we resolved the issue. Once approach would be logarithmic gain. Initially we avoided this because it added complexity, and we feared its reduction in differential signal might be an issue.
The other main thing we noticed from our numeric data was that we could tell the general direction from further away than was obvious from just our LEDs. One thing we could do to better display this so to lower the time constant on our final IIR filters for more smoothing and slower response. This would allow even the noisy long range signals to be directly usable as long as you don't turn too fast.
This relates to another change that would improve the usability across varying distances: using different tuning, and even antennas, at different distances/signal strengths. It would be possible to adjust time constants based on signal strength, and to shift over to higher precision antennas. This would also resolve most saturation issues if done correctly.
Another change we would make if redoing or continuing this project is to insulate the electrodes. Covering them with packing tape for example would help protect them from getting shorted to things accidentally, and should have little to no effect of the signal. Additional static protection for the first op-amp might also be a good idea.
While we have several ideas how the system could be improved, it does work quite well, and exceeded our expectations. It is able to do the two things that interested us: seeing through walls to follow and locate wires, and to detect outlets from long distances, up to and perhaps exceeding 1.5 meters.
The first of these uses is the most simple application. Now that good constants are known, it would be quite straightforward to produce a low power and low cost pure analog version. This could be mounted on the back of the antenna on the top out of the way. Then the directional LEDs could be wired out to near the electrodes for easy viewing, and a handle could be attached for easy gripping and pointing. If desired, such a system could include swappable (or multiple) antennas of differing sizes depending on the task, and perhaps some jumpers or switches on the board to rescale some of the constant adapt it for different use cases (long time constants and high gain for weak signals, vs low gain and fast responses for quick scans). It could even make a viable consumer product for locating wires to aide in wiring, or safety when drilling into walls.
The second use is detection of outlets for a robot. With the assumption that most outlets are at roughly the same height, our antenna could simply be placed on the front of a robot and would provide a signal for if there was a power source nearby (potentially and outlet, but perhaps a cord, or wire inside a wall). It would also provide a directional signal, which based on our data would be enough to steer the robot toward the outlet from 1.5 meters away, gaining accuracy as it got close. While our antenna might not be good enough to do the centering to plugin, as discussed above, it could be combined with a higher precision antenna, especially one that also has a vertical channel. Plugging into an outlet thats right in-front of the robot is one thing, but noticing one from the middle of the hall as our system can, and then going over to it and plugging in is a much more useful accomplishment if one is trying to make a robot that can recharge itself at outlets. There is a important detail with this however: its important that the robot does not produce a significant 60 Hz signal of its own. While this could potentially be calibrated out if its consistent, it would likely decrease sensitivity.
One interesting idea we have not had time to explore is whether it is practical to make a system that detects distances to the signal sources. Using signal strength is not enough because the signal emitting from the sources varies from source to source. Some sort of three electrode antenna could either detect the curve of the field, or its non-linear fall off depending on the placements of the electrodes. Either of these measurements could be used to compute the distance assuming something about the source shape (probably assume a point source). This, if it worked, would allow detecting the distances, which when combined with our existing approaches would allow a measure of location, distance, and using the amplitudes, the actual strength of the signal emitted from the source. With a bit of math, and assuming the signal source is in line with the two electrodes, it should be possible to compute a distance to a point source.
$k$=produced signal strength from source (unknown)
$x$=distance from near electrode to source (unknown)
$a$=measured signal at close electrode
$b$=measured signal at far electrode
$s$=distance between electrodes
Eq.(7) provides the distance to a point source using a two electrode antenna, which can be used in Eq.(6) to get the strength of the point source. We never had a chance to apply this, and it would be interesting to see if it produced usable results. These equations are derived from Eq.(4) and Eq.(5) which simply represent the electric field falling of with the inverse square law.
The real limit of sensing the field is to have a lot of antennas. With enough knowledge of the local electric field, it should be theoretically possible to reconstruct the field outside the of the local area and locate multiple sources. As the number of antennas grows, interference from them may become an issue, which could be countered with having fewer moving antennas, or smaller ones with more gain. What we don't know is how far in this direction it is practical to go. Clearly one and two antenna designs work and produce useful results, but how much can be gained from extending this remains a topic for further study.