Saturday, 18 July 2026

Proton Precession Magnetometer - Part 5 Serious Debugging. Location, Location, Location


 Location Location Location


Ocne I assembled the amplifier v2.0 I was keen to see if it worked. There was a promising peak at around 2450 which is not far from the expected Lamour frequency for my location. Sadly that peak persisted with the water sample removed so it was clearly spurious. What followed was a long period of sulking, a side-track with a cheap Ali-express amplifier (less gain and noisier than the one I was using) and I'd pretty much decided the project was beyond me.

Then this year I became interested in the applications of Claude AI to my hobby projects. I'd found it useful for reviewing my software and even my hardware designs (with the kicad-happy skills package in particular). Perhaps Claude could help me systematically debug each section of the magnetometer. With a few AI suggestions and some wider reading I started testing the following areas.


The Coil Polarisation Circuit - Quick enough turn off?


I was pretty sure I was getting a magnetic field generated in the coil. I could see with a clamp meter that I was getting about 8A into the coil which should be plenty. A compass nearby was totally deflected by the coil when current was flowing.




What I hadn't fully appreciated when I began this project was how important it was the current (and the magnetic field) be turned off as quickly as possible. Too slow a turn-off and the protons in the sample just ride the field back to normal conditions. I constructed a shunt from 10x 0.1R 2W resistors, put it in series with the coil and measured the turn off with my oscilloscope.




Turn off was complete within 86us which should be fast enough. So the coil seems to be in good shape.


The Sensor Coil and Amplifier


If the magnetic field was sufficient then perhaps the sensor coil just could not pick it up? The design requires a tuned tank with a switchable bank of capacitors allowing it to be tuned to a resonant frequency near the expected frequency. But this requires knowing the the true inductance of the coil. To measure this I put a known capacitor (0.1uF) across with the sensor coil and fed a relatively slow (100Hz) signal in. The "ringing" was very apparent and appeared to have a frequency of about 7kHz. Using standard formula I could estimate the inductance of about 5.4 mH (a little lower than design spec but I had found the coil winding tricky).




There's also the risk that the amplifier, with such high gain, might self-oscillate. Measurements with the input grounded showed that it was quiet. 


Data Collection and Analysis.


So if the sensor coils and capacitor bank and polarisation coil are all working as expected, perhaps it's just the A/D or the analysis software that's a problem. Claude has reviewed the software and made some useful suggestions, including a parameter file to help with consistency and averaging the FFTs over a number of runs as well as the possibility of background removal from a run with the coil not polarised.  One way to test the whole thing is to create yet another coil, this one wound around a piece of dowel and inject a very low amplitude signal at the expected frequency into it. With that coil in place of the distilled water I got the following for a 2440 Hz input signal.


This tells us a number of things. One is that if there was a signal (or one of sufficient strength) I should be able to measure it. The data collection and analysis seems to be OK. 

Sample and the Orientation

At this point I started casting around for a number of other things. I realised that the book I'm following was written for the Northern Hemisphere (Colorado). So while it suggested the coil should be tilted to the North, for me in the Southern Hemisphere it should be tilted to the South. I had high hopes this was the problem but it didn't produce me a signal.  From some reading I realised that the coil in fact could also be aligned East-West and horizontal as that also, by definition, puts it perpendicular to the field as well. I even tried an orientation sweep with several tilt angles but got nothing of interest.

Then, just by chance I noticed that the "distilled water" I had obtained was a super-market "health food" product and had the claim "Oxygen Enriched" on the label. Oxygen, which is paramagnetic, kills the signal. I got some deionised water from an auto supply store and degassed it by boiling it.  Still no better.  No doubt a problem, just not the actual problem

So, what was I getting?

This was a typical result, whether I had water in place or not:


As well as a bit of noise I was getting this "comb" of peaks, at 50Hz separations. This, it turns out, it typical of mains AC harmonics, in this case they are amplified by the natural resonance of the coil and capacitor bank.  Still, to be detecting the 49th harmonic of the mains shows how sensitive the whole thing is. I moved from a 150W mains power supply to a 12V battery to power the polarisation but it was only slightly better.  The strength of the peaks and their exact location moved around a bit but the key point was that they tended not to decay like a real precession signal would.

Potentially the AC interference is a problem as the expected frequency for my location is 2435 Hz and the 2450 (49th harmonic) is nearby making it difficult to filter out. But still, it seems there should be a signal in addition to the mains interference (and I would hope considerably stronger).


Could it be the location?

This is a very sensitive instrument. After thinking about it for a while I began to wonder if the location mattered. I'd tried a number of different places in my own property but without much effect, only a slight muting of the AC interference as I got further away from buildings. One thing I began to think about was perhaps the fact I live on a volcanic peninsula, literally on top of an ancient basalt lava flow might be the problem? Such rocks are known in introduce magnetic gradients and there's plenty of them around here.  The move to battery power made the whole thing portable so perhaps I could try another location.


A road trip and... success!


I decided to try another location - this one well off the peninsula. I chose the "Groynes", a large regional park well away from houses and on alluvial plain which should be electrically and magnetically quiet. And indeed I did get this with the coil tilted and facing South:


 
This gave a very clean signal at 2431.3 Hz corresponding to 57.10nT.  A similar result was obtained with the coil horizontal and aligned East-West. With the water removed there was just noise. Just for fun I thought I'l put a toolbox full or metal tools next to it and that also killed the signal. 


Most importantly the signal showed clear signs of delay, allowing an estimate of relaxation time:

This result was also very close to the average for that day measured at a magnetic observatory about 20km away:


Next steps

This result was a mixed blessing. On one hand it showed that under the right conditions it could work. At the same time it suggests that there's something about how I've been running it so far that it killing the signal. The biggest culprit is likely to be the basalt rocks under my house. This means my hopes of running a magnetometer to look for solar storms may be unlikely to come true. 

But all is not lost. In the worst case I might be able to gift it to somebody who lives in a more suitable location. There are, however, some thing to investigate. If there are local gradients it's possible the signal is quenching faster than it would in a magnetically quiet area. My amplifier is "blind" for 40ms after the coil stops because of the induced currents in the sensor. I will investigate if I can reduce that by adding a diode snubber across the coil. I also will try some more careful location studies. Perhaps elevated as high as I can get off the ground, and also be very careful about local metal objects. 






Thursday, 16 January 2025

Proton Precession Magnetometer - Part 4. Amplifier Fail!

The amplifier circuit is reasonably simple and came together quite well and I made a power supply in a plastic food storage container o hold 4 6V Lantern batteries which serve as a bi-polar power supply. It sat neatly in a grounded aluminium case and I was confident it was connected correctly. 


I did a quick calculation based on the likey local magnetic field strength as to what capacitors should be switched on via the dip switch:


I even found that my local supermarket was selling "highly distilled" water as a health drink so I got some and was ready to go. The first time I did a run I was very excited to see a strong signal.



Doing an FFT analysis (via scipy.signal.periodogram) showed a number of promising peaks in rougly the right place.


Perhaps a little on the high side but in the right area for sure. Then I stopped to think a bit. The signal was remarkably clean, even before filtering. There was no sign of the 50Hz noise others have seen. And when I looked more closely it did look a bit more like it was "ringing". Was I actually seeing what I thought I was? I did a number of runs with different conditions (longer delay, longer data collection) and was getting similar results. The I decided to try it without the water sample in place. The results, to say the least, were disappointing:




Similar results were obtained when the polarisation coil was unconnected and the data collection run with no polarisation. If the sensor coil is disconnected completely from the amplifier, only broad-spectrum noise is recorded.

So what's going on? I went back to re-read the appropriate chapter of "Signals from the Sub-Atomic World".  I also downloaded the Gerber files for their PCB and examined their photos of the amplifier. From this I realised that I had not full appreciated the importance of some of the precautions against oscillation. I thought that simply having a ground plane, an insulated case and a (more or less) linear signal path would do. But I see now that there's some important things I overlooked (admittedly it would have been useful to show the decoupling caps on the schematic, but they are only part of the problem). I will not redesign the PCB to have:

  • Full surface mount. Their design has no through-hole components and even the few unavoidably through-hole components (an op-amp and the audio transformer) are mounted in an SMD style.
  • Proper decoupling caps on the positive and negative power suppliesas close as possible to each amplifier IC. 
  • Very short power traces on the PCB (their design has power cables attached to several places on the board right near where they are needed)
  • A full ground plane, uninterrupted by traces, on the underside of the board and substantial ground planes on the top. Also thick ground and signal traces.
  • A smaller, more compact board.
  • No test points - these made the signal path non-linear and were not useful anyway as any testing can be done directly on the ICs.

Version 2.0 is being designed. I have enough parts to do a second board, although I will try and recover the 12-way DIP switch as that's hard to obtain. Hopefully a better design will address the oscillation issues I'm observing. One positive is that at least it appears the ADC sampling at ca. 16,0000 samples/s is sufficient to capture the signal of ca. 3000 Hz. In order to improve the accuracy of the sampling I set up an external DS3231 Real time clock and used the 32KHz signal with a simple interrupt on the arduino and a counter. This gives me an accurate timebase for the sampling. 











Saturday, 4 January 2025

Proton Precession Magnetometer - Part 3. Polarisation Coil Pulse Controller

 I've made reasonably good progress on the pulse controller over the last two months. As often happens, some things I thought would be easy turned out to be hard and some I thought would be hard, not so much.

The power supply and controller is now all set up and finally working. I'd located a nice roomy case that fitted the power supply (150 W Meanwell 12V), installed a fused main switch and done the appropriate connections. I've done my best to cover any mains level exposed connections with tape since I'm likely to be poking around a bit while it's powered.



Also shown is the Raspberry Pi Zero W that I'll use to control the whole thing and analyse the data. The direct control of the pulse is done by a Arduino Pro Nano which hopefully will also collect the data and therefore as well as including the coil activation circuit (basically an opto-isolater controlling the gate of the mosfet bank) the pcb also includes an SPI controlled SRAM and an ADC. Brief tests of each suggest that they are fundamentally working as I'm able to read and write to/from the SRAM and when I feed a ca. 2000 Hz signal into the ADC I can sample it, pass the data by Serial to the Pi and perform an FFT, recovering the frequency within 0.1%. Still this is very much on border of how fast the Arduino can sample so I do regret simply going with a device I had to hand and not a faster variant. More detailed analysis will be needed to establish if the sampling rate is fast and accurate enough. Also on the PCB are connections to the front panel for a RGB LED to show the status of the device (ready, energised, collecting, cooling down etc) and a push button to trigger the coil activation and data collection cycle which is useful for testing.



Unfortunately when I hooked up coil and pressed the button, I soon realised (or smelled) there was a problem. Something was wrong with the MOSFETs used to switch on and off the coil. In fact as far as I could tell they were not turning off and so rapidly heating. I removed them and tested them, finding one of them had gone short. Thinking it might have been just a bad MOSFET I replaced it but the the same problem soon occurred. At this point I decided to rethink the MOSFET system. I had followed the book's suggestion and mounted them on perfboard with wires soldered between them and a bar of aluminium as a heat sink between them and the case:



This seemed a bit mechanically dubious as it required bending the pins of the MOSFETs and some marginal soldering. Instead I decided to design a PCB, using as thick traces as I could and 2oz copper (I did a calculation here to estimate how thick the traces needed to be). The result was much cleaner. 



Still there was an issue which I think might have also been the initial problem. With these IRF6215 MOSFETs the tab with the screw whole is also connected to the drain. Although I had used some thin silicone insulating pads they were difficult to hold in place and clearly not doing the job. I purchased some slightly thicker adhesive TO-220 insluating pads as well as redrilling the holes in the aluminium heatsink and the case more carefully. I progressively tested it with my bench power supply and it seemed fine. Then, fairly confident, I hooked up the coil and pressed the button. Nothing bad happened. I found I could run it fairly regularly (the coil is only on for 6 seconds) and the MOSFETS hardly got warm to the touch. So it seemed to be working. But how to be sure? Well one test is to use a compass to see if there's a disruption to the local magnetic field:




Finally - I was curious about how quickly the coil can be turned on and off. With my oscilloscope I estimated that it's about 7uS to turn it on:



 And 3.7uS to turn it off:




The next step is the signal amplifier - I've got all the parts and the PCB so it should come together fairly quickly. 



Tuesday, 1 October 2024

 

A Proton Precession Magnetometer - Part 2: Sensor Coils


Somehow two years has passed and this project has languished. But I've finally cleared enough time and made progress on other things to all allow me to get back to it. The fact we've had an excellent auroral display and may be heading into an era of high solar activity gives me more incentive. 

I'd had a false start on the sensor coils - my first attempt resulted in coils that were too large to fit inside the polarisation coil. I'm not sure if I'd misread the instructions or just somehow the coils were larger than expected. Anyway I started again with some slightly thinner acrylic tube (38mm, AliExpress) and had the end pieces laser-cut at the city library (Tūranga) for only $1! 

For winding the coils I made a simple jig out of Meccano. I was never much of a Meccano enthusiast and neither was my son, so this kit that I bought maybe 15 years ago has just been sitting around unused. The gears, motors and framing are ideal for this on-off type of project. I created a holder for the coil former using Polymorph - the moldable plastic that can be softened with hot water.





The rubber band drive was flexible enough to allow constant pressure the winding and since the coils needed to be wound in an opposite sense from each other the reversing motors were very helpful. It's still a fiddly job but easier with two hands. The result was not perfect, especially by the fourth layer but measuring the impedance it came out to 3.44 mH when the instructions suggest approximately 3.5 mH, so pretty close. I weighed each coil and made sure they had the same weight (and presumably then roughly the same number of turns). 





The coils were easy enough to join and with the addition of a small amount of acrylic to brace them they fit neatly in the polarisation coil:




I then carried out the suggested test to figure out the optimal way to wire them. I created a small Arduino sketch using tone() to generate a square wave and passed that through the polarisation coil. At 20 kHz it looked something like a rounded off square wave. The I tried various combinations of the sensor coils. The first one was simply looking at the signal picked up by a single coil. Yellow is the input signal to the polarisation coil, purple is the induced signal on the sensor coil. 




The signal has a lot of "ringing" but it's clearly coming from the polarisation coil.  Then I tried wiring the coils in series:




This amplified the signal, as expected by a factor or about 2X. Finally I wired the coils in anti-series as expected to get the noise reduction effect. This was quite dramatic:





Adjusting the vertical scale showed that the noise reduction was at least a factor of 10x. So hopefully that will work to reduce environmental EM from making it's way into the amplifier. 

Now I'm getting back to the polarisation coil power supply. I have all the parts and will start the mechanical work of assembling the MOSFETS on perfboard and drilling holes in the case. 


























Friday, 10 June 2022

A Proton Precession Magnetometer - Part 1: Overview and Polarisation Coil

 A Proton Precession Magnetometer - Part 1: Overview and Polarisation Coil

For some time now I've wanted to add a magnetometer to my weather station. Mostly because it seemed like a cool project, tracking the earth's electromagnetic fields, but a trip to Iceland also made me aware of the relationship between that and the Aurora. We are a little too far North to routinely see any but the strongest Auroral Australis events.  Of course there are plenty of ways online to view "Space Weather" and get predictions of when Aurora viewing is feasible, but I like the idea of a DIY version. Also a nice adjunct to my TC1 seismometer which has been running for several years now and collected some fascinating data.

There are several ways to measure changes in the earth's magnetic field. The simplest can just be a suspended magnet in a container which serves as a type of moving compass. More sophisticated versions of the so-called "Torsion" magnetometer involve lasers and photocell detectors. I came close to starting on one of these when I became aware of another way to do it. 

A Proton Precession Magnetometer relies on the fact that when placed in a strong magnetic field the tiny magnetic field protons in hydrogen atoms have will rotate (or "precess") around that field. By suddenly removing the external field the protons will decay to their regular state and release a very weak signal with a frequency proportional to the earth's magnetic field.  It's rather like bringing a strong magnet up to a compass and then removing it - the needle will oscilatte slightly as it returns to the influence of Earth's magnetic field. 

This process is related in many ways to Nuclear Magnetic Resonance (NMR). As a graduate student in Chemistry many years ago I did a lot with NMR, including some late night experiments which collected data for hours. Of course that was an elaborate machine with superconducting magnets cooled with liquid helium:

A PPM is a bit simpler, although it still contains some interesting challenges for a DIY constructor in terms of materials, sensitivity to noise and analysis of data.

Turns out I'm not the only Chemist who's taken an interest in building a PPM. There's some great details on this project here

But I'm using as the basis this book 




It's got a lot to really great details, full schematics and lots of photos. I'm going to use slightly different technology in places (since it was written in 2007) but the basic idea is the same.

The first part which I've attempted is the polarisation coil. Immediately I began to relaise this may be quite an expensive project. I needed to buy a metre of acrylic tube even though I only needed 1/10 of that and the only place I could find suitable wire (solid core) was on Amazon. The rest of the coil and mountings were laser cut out of acrylic.  All other fittings are brass as you can't use magnetic metals in the vicinity. Becasue it needs to be aligned with the local magnetic field the coil is places on a hinged mount - the hinges are model aircraft control surfaces as they have brass pins. I'm yet to actually test it but it looks OK:




The next part will be the powersupply to engergise the coid. Given the large amount of current required and the ability to switch it off very rapidly there are some interesting challenges.




Wednesday, 28 October 2020

LoRat Rat Trap Monitor - Weather proofing, battery life and software updates

 After leaving a couple of the rat trap monitors in place for a few months it soon became apparent that weatherproofing was going to be an issue. In fact, I've learned a lot about how to have electronics outside, how to maximise battery life and how to iterate on a product design.

The major issue was weather-proofing. My original idea was to use repurposed "Eclipse" mint tins. These are about the correct size to hold the PCB and have a handy hinged lid that by eye at least seems to seal quite well. Unfortunately, it soon became apparent that "quite well" is not good enough. Although the LoRat devices are in tunnel-like rat trap boxes, the ends of these are open and the LoRat and it's antenna needs to be near the open end of the tunnel. After a few months of sitting out in the garden, each of the prototypes had become unserviceable and signs of water corrosion were visible on the LoRa module.

Although there is no shortage of "true" ingress-protected enclosures, such as these gasket sealed ABS boxes from Jaycar, these are fairly expensive and would cost as much again as the rest of the parts. Instead, I decided to go with these simple Sistema food storage boxes. These have room for the PCB and for a 9V battery and I've been using a simple rubber gasket to seal the opening required for the antenna and one of these waterproof toggle switches for power.  The box is attached with a short length of aluminium angle that is screwed onto the trap. Originally I tried epoxying the food storage box to the aluminium but this was difficult to get good adhesion, even after roughening the surface of the plastic. After lifting up the trap by the box and a few times the trap was set off, I found the plastic box would detach. I'm now using some M3 bolts and washers and these seem to be able to be tightened enough to keep it secure and protect against water. Finally I've been using a small packet of self-indicating silica gel in the box as a "last resort" defence against moisture.





The move to using a 9V battery, however, bought its own challenges. Even with the Arduino Mini in low-power mode and the indicator LED removed, a 9V battery only lasted six weeks.  That's starting to get a bit expensive and wasteful. The big problem is the low capacity of a 9V (400-500 mAh) and the fact that the Arduino Mini has a relatively inefficient voltage regulator on the board. This hardly matters for most applications but in this situation where the microprocessor is in low-power mode it becomes quite significant. My solution has been to make an additional small PCB with a separate low-dropout regulator with a very low quinesent current.  The MCP1703A has a 2.0 µA quiescent current. 




As usual the design files are available on GitHub. With this regulator connected directly to the VCC input of the Arduino clone, the current draw is such to give about 6 months running on a single 9V. That's about the same as a smoke detector so should be OK. Later versions of the main PCB will have this voltage regulator on it directly.

While I was at it I made a few changes to improve the robustness and usability on the software side as well. The code for the receiver, an ESP9226 Wemos D1 Mini, now just forwards the data over Wifi to my weather station server running on a Raspberry Pi. This is a more robust solution as the Pi can send out the notification emails and store the data in the same SQL database used for the weather station data so I have a record of it. I also slightly modified the firmware for the sensor itself so that it now blinks an LED for 15 seconds before sending the "caught" signal - this allows it to be switched off when moving it to rebait or for other maintenance without sending a false positive signal. 

After nearly four months of use I'm finding that all five traps I have in the local neighborhood are operating will and seem to have had little damage from the elements. While it's true that there haven't been a lot of rats trapped, other forms of monitoring (chew cards, a trail camera) have not shown many rats either. However back in August I caught four rats in just over a week on one trap:

17 August 2020 04:03:13CASH03
16 August 2020 16:09:28CASH02
13 August 2020 20:24:31CASH03
13 August 2020 20:23:51CASH03
12 August 2020 23:50:14CASH03
09 August 2020 20:02:17CASH03


Given that I normally check the traps once a week that's a significant win and perhaps was a family of invaders who have not managed to get established. Note that one trap was triggered twice within 30 seconds, suggesting there was not an immediate kill but that's rare and there was no sign of serious struggle when I examined the trap. 



Thursday, 5 September 2019

Twilight Photometer Part II - Analysis

This is a followup to the earlier post that described the construction of a Twilight Photometer. In this one, I'll describe the setup and analysis.

The basic idea is that as the sun sets, or rises, it sweeps a beam into the atmosphere that illuminates a segment of the sky above the photometer. By analysing the gradient of light changes directly above the photometer and calculating the sun shadow height it is possible to reveal the presence of any high altitude aerosols. The following diagram, from the original article, shows the theory of it:



In the original article, Forest Mims provides a spreadsheet that he uses to analyse the data. Based on this and a similar one from the NOAA I created a Python module to do the solar calculations.  The calculations are quite intricate but it's fascinating to see how given the date and latitude and longitude it's possible to calculate the sun shadow height (and a lot of other interesting things such as sun azimuthal angle and sunset time). I have a series of Python scripts which work together to:

  1. Download the data as a CSV file from the Photometer
  2. Add the observations to an SQLite database
  3. Generate the plots of shadow height vs intensity and intensity gradient.
The Python scripts are available on GitHub

In general, it all works pretty well and, as I hoped, it's more flexible than the spreadsheet allowing experimentation with different types of data smoothing and generation of plots for data from multiple days of sunset or sunrise recording.

Once I started generating plots I was pleased to see they followed the same general shape as those reported by Mimms. The first problem, however, was that the photometer seemed too sensitive, being at maximum intensity even sometime after sunset. So the plots look something like this: 

With the first 10 or so km missing because it's on maximum intensity. 

I'd used 40 GOhm resistors in the amplifier and even with the link removed to only use one it was still perhaps too sensitive. So I soldered an additional 40GOhm resistor over each one in order to halve the resistance:




This seemed to help but I also needed to extend the tube above the LED with a longer piece of brass tubing and an extra piece of black heatshrink tube I could cut. Then I could adjust it so that just before sunset it would be just below the maximum intensity. To help with the adjustment I added a Serial LCD to show the current intensity. This turned out to be a lot more complicated than I'd hoped since I was already using a fair amount of memory and using the SoftwareSerial tipped it into the region where it could no longer open a file on the SD card. I ended up trimming down as much memory usage as I could and moving to the Send-Only version of SoftwareSerial and SDFat library rather than the standard SD one. These savings freed up enough memory to allow the logging to work.

Eventually, I got the sensitivity about right for both sunset and sunrise recording. Here's a typical set of graphs from a fairly clear morning:





As expected the intensity graph gets noisier as the sun shadow is higher because the sky is still quite dark at that point and the signal generated by the LED is weak. 


What I have realised is that there may, in fact, be a limited application for this type of photometer given my location Mims notes that you really need at least one timezone of clear sky along the sun's azimuth at sunrise and sunset. For me, in Christchurch NZ, that's about halfway across the Tasman sea for sunset. Getting that level of clarity might be common in Texas, it's not so much here in the South Pacific. Here's the satellite image for the morning the above graphs were recorded:



You can see that it was clear above Christchurch but to the East, along the sun's azimuth of (60deg)  there were some significant clouds which probably explains the high altitude disruption. Very often I've recorded graphs like this:




There will be days that have sufficiently clear skies but it's likely to only be when there is very significant high pressure to the east or west of my position. That means that the useful data will be recorded mostly for a single type of climatic condition, and a relatively rare one at that.

In any case, I'm still keeping an eye on the forecast, hoping for clear skies and recording when it looks promising. I'm hoping to build up something of a baseline over the winter and perhaps when it's bushfire season in Australia I'll start to see evidence of high altitude aerosols.








Proton Precession Magnetometer - Part 5 Serious Debugging. Location, Location, Location

 Location Location Location Ocne I assembled the amplifier v2.0  I was keen to see if it worked. There was a promising peak at around 2450 w...