Locating Where a Sound is Coming From

For my masters year, half the marks came from one module, the masters project. Being a team effort, we were in a group of three. Putting our heads together, and taking ideas from lecturers, we made a list of potential projects. We knew for one that I wanted to be making hardware, and the other two wanted to use/learn machine learning and maybe FPGA’s. After much deliberation we decided to make a project that listened for a sound, and using time difference of arrival worked out where the sound came from. This post is mostly about the hardware and circuitry designed for the project.

The final board for our masters project. Contains four amplifier sections for the microphones and a micro controller with USB interface.

With a world with a big focus on safety in public places, we thought it would be a good product for the security industry, potentially with links to smart cities. Imagine a shopping center, somewhere with lots of security already. They tend to have lots of security cameras, alarm systems and a dedicated guard. This isn’t uncommon in big public places/attractions, especially in the UK. Sports stadiums, train stations and museums are always looking for new ways to protect themselves and isolate problems. The example that inspired us was the horrendous shooting in Las Vegas at a concert in October 2017, just as we were picking projects. The main problem was that the security services did not know where the shooter was, meaning it took longer to get to him. If they had a system like we envisaged, the microphones would pick up the sound and triangulate it. The location could then be sent to relevant authorities to use.

The front page of the New York times just days after the Las Vegas shooting

To start with we needed microphones. We didn’t need to reinvent the wheel, and microphones can be easily bought off the shelf. For ease we used standard stage microphones, that had 3-pin XLR outputs. Although we had been warned that they would not work they had a good omnidirectional pattern, and had lots of good documentation. One issue with them is the output is balanced, which means it needs to go through a pre-amp. To get an idea of what a balanced signal is, imagine a ground connection and two signals. The two signals are the same, but one is inverted. This means when it travels down the cable it is much less susceptible to interference. This is part of the reason we liked using stage rated equipment, as sound engineers have already worked out issues with transporting sound signals long distances through noisy situations. We concluded from research that the signals could reach over 100m, which was the number we were aiming for.

One of the pre-amplifier sections used on the board, using four operational amplifiers.

Once the signal got to the box it needed to be converted to a signal that could be read by an ADC. To do this we used an INA217, a pre-amp designed for basically this purpose. An instrument amplifier, it measures the difference between the signals and amplifies them, outputting a voltage with reference to ground. The signal from the microphone is tiny, in the tens of milivolts range, so it needed some dramatic amplification to get it near the 5V ADC. The INA217 did a good job but we put a second stage amplifier to give it the extra push, as very large gains can sometimes be bad for a number of reasons. We used an OP07D but if we were to do it again we would get a rail-to-rail to get better results. This amp had a pot as one of the gain resistors so that we could easily trim the gain depending on test. Finally, the signal at this point sat between -2.5V and +2.5V so we needed to shift it up so it was between 0 and 5V. This was done with a simple shift circuit and an amplifier. We used another OP07D to make buying easier.

Me manufacturing the PCB, at this point I was inspecting to see how well it had been soldered.

From here the signal gets read by the 12 bit ADC in an STM32 microcontroller. It then streams the data via the USB to a PC where MATLAB picks it up. This is where my knowledge is a bit lacking as I did not make it. In essence MATLAB uses a machine learning algorithm that had listened to over 1000 gunshots, screams and explosions. It has categorized them, and used a number of features to notice the difference. Then when playing a new sound of one of these things (not heard by it before) it categorizes it and outputs it to the user. It also used a selection of sounds from the background to know when there is not one of these events happening, else there will false negatives.

One of our set ups to get a useful output and test the amplifiers were working properly.

All in all the project did actually work. It detected gunshots and screams being played into the microphone, and the triangulation algorithm worked, just not in real time. We managed to win the best masters project, mainly because we had good quality hardware, a partially working system and a good business case behind it. There is a lot of scope of where this project could go, and many things that could be improved, but we were happy with how it came out. I may be able to use some of the circuitry on other projects, who knows. If you are interested in more of the project, maybe some more detail about the hardware or manufacture, comment or message on Twitter. Thanks for reading.

A good example of how much difference there is between the microphones when a big sound was made. Minute distances made a big time difference.

The Dawn of Ion Engines

Ion thrusters are becoming a bigger and bigger part of modern satellite design. Over 100 geosynchronous Earth Orbit communication satellites are being kept in the desired locations in orbit using this revolutionary technology. This post is about its most amazing achievement to date, the Dawn Spacecraft. Just reported that it is at the end of its second extension of the mission it has a few records under its belt. It is the first spacecraft to orbit two different celestial bodies, and the first to orbit any object in the main asteroid belt between Mars and Jupiter. It is also a record breaker for electric speed. Travelling over 25,700 mph it is 2.7x faster than the previous fastest electric thrusted spacecraft. That is a comparable speed to the Delta 2 launch vehicle that got it to space in the first place.

Delta 2 launch
The Dawn spacecraft launching on a Delta 2 rocket from Cape Canaveral Air Force Station SLC 17 on Sept 27th, 2007. Credit: NASA/Tony Gray & Robert Murra

The Dawn mission was designed to study two large bodies in the main asteroid belt. This is to get a deeper insight into the formation of the solar system . It also has the added benefit of testing the ion drive in deep space for much longer than previous spacecraft. Ceres and Vesta are the two most massive bodies in the belt, and are also very useful protoplanets from a scientific standpoint. Ceres is an icy and cold dwarf planet whereas Vesta is a rocky and dry asteroid. Understanding these bodies can bridge the understanding of how the rocky planets and icy bodies of the solar system form. It could also show how some of the rocky planets can hold water/ice. In 2006 the International Astronomical Union (IAU) changed the definition of what a planet is, and introduced the term “dwarf planet”. This is the change that downgraded Pluto from its planet status, although that has been argued to be wrong by Dr. Phil Metzger in a recent paper. Ceres is classified as a dwarf planet. As Dawn arrived at Ceres a few months before New Horizons reached Pluto, Dawn was the first to study a dwarf planet.

Dawn prior to encapsulation at its launch pad on July 1, 2007. Credit: NASA/Amanda Diller

The ion engine is so efficient that without them a trip to just Vesta would need 10 times more propellant, a much larger spacecraft, and therefore a much larger launch vehicle (making it much more expensive). The ion propulsion system that it uses was first proven by Deep Space Mission 1, along with 11 other technologies. Dawn has three 30 cm diameter (12 inch) ion thrust units. They can move in two axis to allow for migration of the center of mass as the mission progresses. The attitude control system can also use the movable ion thrusters to control the attitude. The mission only needs two of the thrusters to complete the mission, the third being a spare. All three have been used at some point during the mission, one at a time. As of September 7th 2018 the spacecraft has spent 5.9 years with the ion thrusters on, which is about 54% of its total time in space. The thrust to its first orbit took 979 days, with the entire mission being over 2000 days. Deep Space 1’s mission in contrast lasted 678 days before the fuel ran out.

An artist’s impression of Dawn with its ion thrusters on. Credit: NASA

The thrusters work by using electrical charge to accelerate ions from xenon fuel to speeds 7-10 times that of chemical engines. The power level and the fuel feed can be adjusted to act like a throttle. The thruster is very thrifty with its fuel, using a minor 3.25 milligrams of xenon per second, roughly 280g per day, at maximum thrust. The spacecraft carried 425 kg (937 pounds) of xenon propellant at launch. Xenon is a great fuel source because it is chemically inert, easily stored in compact form. Plus the atoms are very heavy so they provide large thrust compared to other comparable candidate propellants. At launch on Earth the xenon was 1.5 times the density of water. At full thrust the ion engines produce a thrust of 91 mN, which is roughly the force needed to hold a small sheet of paper. Over time these minute forces add up and over the course of years can produce very large speeds. The electrical power is produced by two 8.3 m (27 ft) x 2.3 m (7.7 ft) solar arrays. Each 18 meter squared (25 yard squared) array is covered in 5,740 individual photo voltaic cells. They can convert 28% of the sun’s energy into useful electricity. If these panels were on Earth they would produce 10 kW of energy. Each of the panels are on gimbals that mean they can turn any time to face the sun. The spacecraft uses a nickel-hydrogen battery to charge up and power during dark points in the mission.

The dawn mission patch.  This logo represents the mission of the Dawn spacecraft. During its nearly decade-long mission, Dawn will study the asteroid Vesta and dwarf planet Ceres Credit: NASA.

Vesta was discovered on March 29th 1807 by astronomer Heinrich Wilhelm Olbers, and is named after the Roman virgin goddess of home and hearth. The Dawn mission uncovered many unique surface features of the protoplanet ,twice the area of California, that have intrigued scientists. Two colossal impact craters were found in the southern hemisphere, the 500 km (310 miles) wide Rheasilvia basin, and the older 400 km (250 miles) wide Veneneia crater. The combined view of these craters was apparent even to the Hubble telescope. Dawn showed that the Rheasilvia crater’s width is 95% of the width of Vesta (it’s not perfectly spherical) and is roughly 19 km (12 miles) deep. The central peak of the crater rises to 19-25 km (12-16 miles) high, and being more that 160 km (100 miles) wide, it competes with Mars’ Olympus Mons as the largest mountain in the solar system. The debris that was propelled away from Vesta during the impacts made up 1% of its mass, and is now beginning its journey through the solar system. These are known as Vestoids, ranging from sand and gravel all the way up to boulders and smaller asteroids. About 6% of all meteorites that land on Earth are a result of this impact.

The brave new world of 4 Vesta, courtesy of NASA’s Dawn spacecraft. Credit: NASA/JPL-Caltech/UCAL/MPS/DLR/IDA

Dawn mapped Vesta’s geology, composition, cratering record and more during its orbit. It also managed to determine the inner structure by measuring its gravitational field. The measurements were consistent with the presence of an iron core of around 225 km (140 miles), in agreement with the size predicted by
howardite-eucrite-diogenite (HED)-based differentiation models. The Dawn mission confirmed that Vesta is the parent body of the HED meteorites, by matching them with lab based measurements. These experiments measured the elemental composition of Vesta’s surface and its specific mineralogy. These results confirm that Vesta experienced pervasive, maybe even global melting, implying that differentiation may be a common history for large planetesimals that condensed before short-lived heat-producing radioactive elements decayed away. The pitted terrains and gullies were found in several young craters. This could be interpreted as evidence of volatile releases and transient water flow. Vesta’s composition is volatile-depleted, so these hydrated materials are likely exogenic (formed on the surface).

A colour coded topographic map from the Dawn mission of the giant asteroid Vesta. Credit: NASA/JPL

The first object ever discovered in the main asteroid belt was Ceres. Named after the Roman goddess of corn and harvest, it was discovered by Italian astronomer Father Giuseppe Piazzi in 1801. Initially classified as a planet, it was later classified as an asteroid as more objects were found in the same region. In recognition of its planet like properties (being very spherical) it was designated a dwarf planet in 2006 along with Pluto and Eris. Observed by the Hubble telescope between 2003 and 2004, it was shown to be nearly spherical, and approximately 940 km (585 miles) wide. Ceres makes up 35% of the mass of the main asteroid belt. Before Dawn there were plenty of signs of water on Ceres. First, its low density indicates that it is 25% ice by mass, which makes it the most water rich body in the inner solar system after Earth (in absolute amount of water). Also, using Hershel in 2012 and 2013, evidence of water vapor, probably produced by ice near the surface transforming from solid to gas (known as sublimating).

Dwarf planet Ceres is shown in these false-color renderings, which highlight differences in surface materials. Credit: NASA/JPL-CalTech/UCLA/MPS/DLR/IDA

Acquiring all the data it needed by the middle of 2016, Dawn measured its global shape, mean density, surface morphology, mineralogy, elemental composition, regional gravity and topography at exceeded resolutions. The imaging from the mission showed a heavily cratered surface with bright features. Often referred to as “bright spots” they are deposits of carbonates and other salts. Multiple measurements showed an abundance of ice at higher latitudes. However the retention of craters up to 275 km (170 miles) in diameter argue for a strong crust, with lots of hydrated salts, rocks and clathrates (molecules trapped in a cage of water molecules). Gravity and topography data also indicated that that Ceres’ internal density increases with depth. This is evidence for internal differentiation resulting from the separation of the dense rock from the low density water-rich phases in Ceres history. The rock settled to form an inner mantle overlain with a water-rich crust. This internal differentiation is typical of small planets like Ceres and Vesta that Sets them apart from asteroids.

Thank you for reading, take a look at my other posts if you are interested in space, electronics, or military history. If you are interested, follow me on Twitter to get updates on projects I am currently working on.

Follow @TheIndieG
Tweet to @TheIndieG

Considerations When Making a Current Shunt Sensor

For battery powered projects, current consumption is a really important consideration when designing the circuitry. While designing my final year project I spent a huge amount of time researching how to put together a simple current sensor. Considering most applications for me are DC, fairly low current and low voltage, the most obvious design is to make a current shunt. The basic idea of a current shunt is that you put a very low value resistor between the circuit you want to measure and ground, and measure the voltage across it. When one side is of the shunt resitor is ground it is low side, there are also high side versions but are mlre complex. As the resistor has a small resistance, there will be a low voltage drop (usually mV) across it meaning it shouldn’t affect the load circuitry. The voltage will also be proportional to the current running through it, meaning if you measure it, and do the right maths you can get a consistent and reliable current reading. This post is about how to get that tiny voltage into 1’s and 0’s, while thinking about the considerations that have to be made about the design to make it accurate and reliable in the environments you want.

Final Year Project
My final year project needed current sensors on the motors as well as monitoring the drain on the battery.

The first thing that needs to be decided is the shunt resistor itself. A shunt resistor is basically a low value resistor, with very tight and known tolerance usually with a fairly high power rating. It can be used in AC and DC circuitry, with the concept behind it being that as a current flows  though it, a voltage is induced across it. The voltage can then be measured and using a simple calculation (based on ohms law) converted into a value for current. The value of the resistor depends on what it is measuring and what is measuring it. Start with what is measuring it. If you are like me, it is likely that it will be read by an ADC, probably on a 5V or 3V3 microcontroller. The voltage across the resistor is going to be amplified between 10 and 100 times (we will get to why in a moment) so pick a maximum voltage within that range. I tend to go with 100mV maximum voltage drop, which for a 5V ADC would require an amplification of 50. Then, take the maximum value of current you want to be able to measure. You can then use ohms law to figure the resistance you need. For example if I wanted to measure 1A, the resistor would be 100mV/1A = 100 mohm. Now we know the resistor value, use the power equation to work out the power eating we want. For this example we would need P = I V = 1 x 0.1 = 100mW. This is the minimum power rating you need, I personally would get a 250mW or even a 500mW just to keep the temperature of the circuit down.

The simple equation to work out what sizesunt resistor to use. Credit: Texas Instruments 

Now we have a voltage that will be somewhere between 0 and 100mV with reference to ground. We want this value to be scaled up to 0 to 5V. To do this we are going to use an operational amplifier. There are plenty out there, and most people have their favourites and I’m not here to convince you otherwise. I tend to use an op amp that I am using somewhere else in the circuit to make life easier. There are a few things you do need from an op amp in this circuit though, it needs to be rail to rail, and have a low input offset voltage. Offset voltage in an op amp is the voltage difference on the inputs, and even though they are tiny differences they can have a big effect because we are amplifying small voltages, and any noise or offset will be amplified too. The op amp needs to be in a simple non inverting configuration. The equations needed to design this are in most first year textbooks and there are plenty of calculators online. I have set a gain of 50 in my calculation, which is in the fairly common range. The output of the amplifier can then go straight straight into an ADC to be measured.

The basic layout of a current shunt sensor showing where the shunt resistors and gain resistors go in the circuit. Credit: Texas Instruments 
The first version of my current sense test circuit, using an OP170 made by TI.

Now let’s look at a few places where errors can come into a design like this. There are two types of errors that occur in a circuit like this, gain error and offset error. A gain error is one where the output error gets further away from the ideal output as the current gets higher. An offset error is one that has the same amount of error whatever the input, just like an offset. The only common source of offset error in a circuit like this is from the offset error in the op amp discussed previously, solved with an improved choice of amplifier. The gain errors are usually due to a difference in resistance from the ideal. Many things can cause this, one is the tolerance of the resistor used, we want to use a precision resistor of 1% or less tolerance. Another cause could be temperature changes in the resistor itself, it may be next to a large MOSFET or other hot component, or could have too low of a power rating making it heat up, wither way a change in temperature means change in resistance. Layout can also be an issue, if tracks are too thin or too long they can add extra unwanted resistance.

Great graphs showing the difference between gain an offset error. Credit: Texas Instruments.

If you want to add a bit of fancyness into the project, or really need to measure down to low currents, you need to tackle the zero-current error. The problem is that when using an op amp, even a rail to rail one, it never quite reaches the power rails. Even the best ones can only get within 100mV or so of the power rails, this is known as saturation. Solving this involves moving the power rails slightly so the saturation point is less than ground. If you have a negative voltage rail you can use that but home projects tend to be single supply, so we need another power source. This can be made using a voltage inverter (a type of charge pump). Usually only needing an external capacitor to work, they are cheap and easy to integrate into a project. I used a LTC1983, which creates a negative 5V rail, but there are plenty of others such as the LM7705. Research what fits your circuit and cost point, and just attach the negative output to the negative supply rail of the op amp.

 A great graph showing how the zero current error occurs, and what it would look like if you tested it. Credit: Texas Instruments.

Most issues with error can be fixed during the hardware design phase. You can pick better op amps, such as ones designed to combat offset voltage. Some amplifiers have internal calibration procedures, and some such as chopper stabilizers are specifically designed to correct these problems. You can also use a potentiometer instead of a power resistor, but they are more susceptible to temperature and can be knocked. Another way is to fix issues in software by creating a calibration procedure. Using a calibrated precision current source and a multimeter, measure the reading of the ADC and compare the value to the reading from the instruments. You should get an offset and gain value that can then be used to calibrate the sensor.

A simple set up that I used to calibrate an early sensor, with a big power resistor as the load and a variable power supply to change the current. Marked down to put into calibration.

I would suggest trying out a few of these sensors in future projects, they don’t cost too much, and can be a valuable addition to a design. Especially for power sensitive devices, or smart sensors, this could be a better solution than an off the shelf or breakout board solution. If you want to hear more about my current sensor designs, and how well the testing and calibration went then comment or tweet at me. I already have some documentation that I may release at some point.

Follow @TheIndieG
Tweet to @TheIndieG