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.








Monday, 29 July 2019

Twilight Photometer Part 1 - Construction

I'm a big fan of Forest M. Mims III.  Not only has he published some excellent reference books such as his charmingly hand-drawn Engineers Notebook, he very much represents the best of what's possible with Citizen Science. Mimms was one of the first to realise that light-emitting diodes (LEDs) can act as photosensors as well as light emitters and he has created some ingenious applications of this. A lot of what Mims promotes are simple, but rigorous observations. Even such things as measuring the 'temperature' of the sky with an IR thermometer or simply taking a photo in the same place at noon each day, provide a surprising amount of useful data. With simple equipment and careful observations and analysis, Mims shows that we can all do interesting science.

A few years ago he wrote a couple of articles in Make Magazine about Twilight Photometry. These really caught my imagination - the idea that what was essentially an LED pointed into the sky being able to detect aerosol layers tens of kilometres up seemed fascinating.  Of course, the Devil is in the Details and there are some important considerations to get this to work.  It's taken some years to get around to it but I've finally found the time to get started on this project.

The keys parts of the photometer are simple - a circuit to amplify the tiny current created by the LED as it points at the twilight (or dawn) sky. To do this requires a low noise amplifier with a very high gain circuit. This requires resistors in the GΩ range. These are by far and away the most expensive resistors I've ever purchased at $10 each!

Following the schematic in the Make article and Mim's related book, I used KiCad to design and layout a small PCB. The files for this are available on GitHub.

























Mims suggests that the LED, capacitor C2 and resistor R1 should be soldered directly to input,  pin 2 of the TLC271 in order to reduce noise. I'm hoping that because I'm on a "proper" PCB with a ground plane that it will be sufficient to just use the PCB connections as normal. I can always re-engineer it if the noise is a problem.

I followed Mim's suggestion to install everything in a metal enclosure and to make the LED mounted in a removable fitting. In my case, I used a metal 6.5mm phono plug which holds a LED and a piece of brass tubing (with some black heat shrink extension) as a collimator quite nicely.  I've set up both red and infra-red LEDs in phono plugs and these can be swapped out.

Data is collected using an Arduino and the excellent Adafruit Datalogger shield which contains both an SD card and a Real-Time Clock. Like all Adafruit products, it's well documented, robust and well-thought-out. As an interface between the output of the amplifier, I used the 16-Bit, 4 channel ADC also from Adafruit. This is an I2C device, easy to use and seems accurate. Since I'm running everything off 5V (supplied by the Arduino) there's not a lot of voltage range but hopefully, the 16bit ADC (running at 0.0635 mV resolution given the 2V full range setting ) will be sensitive enough.

The code for the Arduino is here. It's pretty straight-forward, several readings are taken for each channel and averaged giving a recording time of about once every second. One notable thing is I added the ability to download the datafiles (YYYYMMDD.CSV)  from the SD card over a serial connection to my laptop which saves constantly having to open up the enclosure and get the SD card out.


Here are some photos of the final enclosure:



Since there are three "unused" channels on the ADC I've added three additional LEDs (each in clear housings) attached to those channels as described in "Atmospheric Monitoring with Arduino". I did a test of various LEDs - using an RGB LED to generate various colours and measuring the response.




The response curves are not ideal as clearly a couple of them are saturating fairly easily but it seemed blue, yellow and red gave the best spread so I've used those. Daylight photometry is kind of tricky since there tends to be shade from ground features and clouds at some time during the day. At the very least I may be able to get some full sunshine measurements around noon for some days of the year.


Finally I decided to add a ground stake to the enclosure to keep electrical interference to a minimum. Here's a picture of it all set up on my deck on the first night I tried it. It's powered by my 'portable' SLA/Solar power box I used for water pumps and the like around the garden - the solar controller has a convenient USB output. You can see I mounted the photometer on a piece of plywood with a levelling mechanism made of some embedded threaded rod and some bolts. The ground stake connection goes off to the right and into the garden.




This was not an ideal night, a little hazy and with some low cloud to the west of us. However, a brief look at the data looks promising - if anything it might currently be too sensitive and need a longer tube over the LED as it was at its max reading until about 10 minutes after sunset but then steadily decreased over the 45 minutes. I'm keen to collect more data but we've had day after day of clouds. Here's hoping for a nice clear frosty morning or evening soon!

Part II will discuss the analysis of the data.






Friday, 12 October 2018

LoRat Trap Monitor. Part 4 - PCBs and Antennas

The PCBs arrived, first from PCBWay and not too long afterwards from OSHPark. They look pretty good. Although the classic purple from OSHPark is interesting, I was pleased I selected white from PCBWay.




More importantly they seem to work. I found that there is an issue with the footprint for the SMD u.FL antenna connector which I have fixed for "next time" and also added some holes for direct antenna wire connection. However I'm unlikely to use the u.FL connector as simply a piece of wire or one of the coil antennas which comes the LoRa modules is likely to suffice. The part I was most concerned about - the SMD footprint for the LoRa module, seemed to be spot on and was not hard to solder - just run a fillet of solder up against every pin and remove any bridges with wick.





After that excitement there was a fairly long gap in this project as I was busy at work and ski season meant we were away many weekends.  All that time I still had my prototype out in the garden attached to a rat trap. Sadly there are no rats around at the moment, in our garden at least. At the same time I do check it from time to time and set it off manually to confirm the batteries are still good and the receiver is still running. There have been no false positives so far.

I wanted to experiment a bit with an antenna on the receiver. It was just sitting in my office with a small coiled antenna but to get the most range out of it I want to have an external antenna, located in the garage. This required the use of a WiFi extender to get a decent WiFi signal out to the garage and the construction of a suitable antenna.

Before I did that I wanted some way to estimate range. To do this I use built simple device using a Arduino Uno and a I2C LCD screen connected to a LoRa module. Code for this is on github. Faced with the difficulty of cutting a square hole, neatly, for the LCD I decided to have an enclosure laser cut out of acrylic sheet. This the first time I've tried anything like this, but it worked out pretty well. I used this box generator to generate the starting point for the design. A couple of bolts and standoffs keep the thing together, although I later added some plastic adhesive around the base.




When the test button is pressed it generates a random number then sends that to the base station and waits for a reply. If it gets the same number back in response then it prints the confirmation of that and the signal strength:




The science of antennas, for LoRa along with other radios, is pretty complicated. There's a lot of information on the Internet, some of it contradictory. I had bought this antenna off Aliexpress but wasn't really convinced it would be a good outdoor solution. In the end I decided to build a quarter-wave ground plane antenna as described here. That site also has a very useful calculator so I could cut fives pieces of single core copper wire taken from a domestic supply type cable and use a SMA->TNA adapter I got off TradeMe. This conveniently has four holes which can be used to bolt on the ground planes.




The pieces of wire are not super straight but I assume that won't matter too much. Along with a home-made 2m coaxial cable my initial tests showed it was slightly better than the antenna I bought off Aliexpress.





The antenna sits neatly on top a piece of 15mm pvc tube which then serve as a mounting post:



Initial tests suggest I get pretty good coverage all around the neighborhood. But I'll be trying to quantify that over the next few days.






Monday, 6 August 2018

LoRat Trap Monitor. Part 3 - PCB design

I have now created a prototype PCB design to hold the LoRa radio and the Arduino Mini.

The schematic is pretty straight-forward:



As is the resulting board which is about 34 x 65mm:





This should fit inside one of the candidates for a repurposed enclosure - an "Eclipse" mint tin.

Design files are available on Github.

I created some custom footprints for the LoRa module and the U.FL antenna socket and these are also available on Github.  The LoRa module is quite tricky and might be difficult to solder but we shall see.

I'm having prototypes made at both OshPark and PCBWay simply for comparison. The latter will turn out quite cheaply as long as a cheap shipping option is available.




  A Proton Precession Magnetometer - Part 2: Sensor Coils Somehow two years has passed and this project has languished. But I've finally...