User Tools

Site Tools


as3935

AS3935 Lightning Detector Chip

Sourcing

Chip available at Digikey and Mouser, not any other normal distributors. Also need special antenna which I can only see at mouser and the manufacturer, Coilcraft.

Devboards more widely available, from Sparkfun, DFRobot, and others.

Antenna

The chip specifies a specific antenna which was made for it.

https://www.coilcraft.com/en-us/products/rf/rfid-transponders/x-y-axis-transponder-coil-2mhz/ma5532/

Antenna from coilcraft: 1 1.47€ 100 1.26€ 250 1.01€ 500 0.93€ 1000 0.73€

Specs

  • ab max power 0.1 mW
  • Normal listening mode: 70 μA
  • Signal processing mode (for 1 to 1.5 secs after squelch opens): 350 µA
  • Receiver centred on 500kHz, bandwidth 33kHz.
  • Shortest time between detections about 1 second.
  • Range max 40km
  • Under best conditions only has 40% chance of detecting a strike,

“Disturber” means QRM.

I2C

Chip contains 10k pullup on SDA but not SCL. Addresses 1, 2, or 3, depending on config pins.

Calibration

Antenna LC oscillator needs to be 500kHz +/- 3.5%. Can be calibrated by setting trimming capacitors according to timing signal on IRQ pin.

A badly designed, pulled, aged, uncompensated crystal oscillator might be 50ppm off, so much better than needed as a calibration standard for this application. Therefore can use a µC to calibrate it automatically. I don't see this done in the Sparkfun library even though it seems obvious.

The chip can then calibrate its clocks from the above value, so antenna should be trimmed first. Clocks calibration must be repeated after power loss.

How it works

Gain: two ranges for indoor or outdoor, and then configured levels in range.

Input is compared against the watchdog level. A squelch, I would call that. Also compared to a configurable noise floor level. If exceeded, interrupt warning sensor won't work.

When squelch opened, an interrupt is generated and signal is classified. It can be Lightning or QRM. If lightning, energy and distance estimations are made. Distance depends on previous detections too. The chip has a memory.

Interrupt 0 means distance estimation changed.

Usage procedure

  • Trim antenna frequency.
  • Calibrate internal clocks.
  • Set gain: indoor/outdoor and level. Indoor/outdoor refers to setting of AFE_GB - Analogue front end gain boost.
  • Set max noise floor.
  • Set watchdog level (squelch).
  • Set any more detection levels you want.
  • On interrupt, read register to see what happened.

Experiments

Using DFRobot board.

I wrote a program to test and tune it. Initially found:

[016412] [D] measure_frequency(): counts: 33133, time: 999837, frequency: 530214 Hz
[016412] [D] Trimcap: 0pF, Error: 30214 Hz, 6.0%
[017414] [D] measure_frequency(): counts: 33017, time: 999811, frequency: 528371 Hz
[017414] [D] Trimcap: 8pF, Error: 28371 Hz, 5.7%
[018416] [D] measure_frequency(): counts: 32910, time: 1000059, frequency: 526528 Hz
[018416] [D] Trimcap: 16pF, Error: 26528 Hz, 5.3%
[019418] [D] measure_frequency(): counts: 32792, time: 999927, frequency: 524710 Hz
[019418] [D] Trimcap: 24pF, Error: 24710 Hz, 4.9%
[020420] [D] measure_frequency(): counts: 32682, time: 999998, frequency: 522913 Hz
[020420] [D] Trimcap: 32pF, Error: 22913 Hz, 4.6%
[021422] [D] measure_frequency(): counts: 32570, time: 1000004, frequency: 521117 Hz
[021422] [D] Trimcap: 40pF, Error: 21117 Hz, 4.2%
[022424] [D] measure_frequency(): counts: 32459, time: 999937, frequency: 519376 Hz
[022424] [D] Trimcap: 48pF, Error: 19376 Hz, 3.9%
[023426] [D] measure_frequency(): counts: 32352, time: 1000006, frequency: 517628 Hz
[023426] [D] Trimcap: 56pF, Error: 17628 Hz, 3.5%
[024428] [D] measure_frequency(): counts: 32236, time: 999936, frequency: 515809 Hz
[024428] [D] Trimcap: 64pF, Error: 15809 Hz, 3.2%
[025430] [D] measure_frequency(): counts: 32132, time: 1000007, frequency: 514108 Hz
[025430] [D] Trimcap: 72pF, Error: 14108 Hz, 2.8%
[026432] [D] measure_frequency(): counts: 32024, time: 999936, frequency: 512416 Hz
[026432] [D] Trimcap: 80pF, Error: 12416 Hz, 2.5%
[027434] [D] measure_frequency(): counts: 31922, time: 1000007, frequency: 510748 Hz
[027434] [D] Trimcap: 88pF, Error: 10748 Hz, 2.1%
[028436] [D] measure_frequency(): counts: 31817, time: 999936, frequency: 509104 Hz
[028436] [D] Trimcap: 96pF, Error: 9104 Hz, 1.8%
[029438] [D] measure_frequency(): counts: 31720, time: 1000089, frequency: 507474 Hz
[029438] [D] Trimcap: 104pF, Error: 7474 Hz, 1.5%
[030440] [D] measure_frequency(): counts: 31614, time: 999936, frequency: 505856 Hz
[030440] [D] Trimcap: 112pF, Error: 5856 Hz, 1.2%
[031442] [D] measure_frequency(): counts: 31516, time: 1000023, frequency: 504244 Hz
[031442] [D] Trimcap: 120pF, Error: 4244 Hz, 0.8%
[031444] [D] Lowest error: 0.848800%. Using 120pF.''

Added 2x 6.8pF NPO caps, soldered on top of and beside the existing caps. Then measured:

[020013] [D] measure_frequency(): counts: 31876, time: 1000755, frequency: 509631 Hz
[020013] [D] Trimcap: 0pF, Error: 9631 Hz, 1.9%
[021015] [D] measure_frequency(): counts: 31744, time: 999774, frequency: 508018 Hz
[021015] [D] Trimcap: 8pF, Error: 8018 Hz, 1.6%
[022017] [D] measure_frequency(): counts: 31652, time: 1000077, frequency: 506393 Hz
[022017] [D] Trimcap: 16pF, Error: 6393 Hz, 1.3%
[023019] [D] measure_frequency(): counts: 31551, time: 999950, frequency: 504841 Hz
[023019] [D] Trimcap: 24pF, Error: 4841 Hz, 1.0%
[024021] [D] measure_frequency(): counts: 31454, time: 1000018, frequency: 503254 Hz
[024021] [D] Trimcap: 32pF, Error: 3254 Hz, 0.7%
[025023] [D] measure_frequency(): counts: 31355, time: 999948, frequency: 501706 Hz
[025023] [D] Trimcap: 40pF, Error: 1706 Hz, 0.3%
[026025] [D] measure_frequency(): counts: 31262, time: 1000040, frequency: 500171 Hz
[026025] [D] Trimcap: 48pF, Error: 171 Hz, 0.0%
[027027] [D] measure_frequency(): counts: 31167, time: 1000050, frequency: 498647 Hz
[027027] [D] Trimcap: 56pF, Error: -1353 Hz, -0.3%
[028029] [D] measure_frequency(): counts: 31057, time: 999776, frequency: 497023 Hz
[028029] [D] Trimcap: 64pF, Error: -2977 Hz, -0.6%
[029031] [D] measure_frequency(): counts: 30967, time: 999878, frequency: 495532 Hz
[029031] [D] Trimcap: 72pF, Error: -4468 Hz, -0.9%
[030033] [D] measure_frequency(): counts: 30872, time: 999860, frequency: 494021 Hz
[030033] [D] Trimcap: 80pF, Error: -5979 Hz, -1.2%
[031035] [D] measure_frequency(): counts: 30779, time: 999796, frequency: 492564 Hz
[031035] [D] Trimcap: 88pF, Error: -7436 Hz, -1.5%
[032037] [D] measure_frequency(): counts: 30689, time: 999859, frequency: 491093 Hz
[032037] [D] Trimcap: 96pF, Error: -8907 Hz, -1.8%
[033039] [D] measure_frequency(): counts: 30597, time: 999866, frequency: 489617 Hz
[033039] [D] Trimcap: 104pF, Error: -10383 Hz, -2.1%
[034042] [D] measure_frequency(): counts: 30532, time: 1000684, frequency: 488178 Hz
[034042] [D] Trimcap: 112pF, Error: -11822 Hz, -2.4%
[035045] [D] measure_frequency(): counts: 30442, time: 1000605, frequency: 486777 Hz
[035045] [D] Trimcap: 120pF, Error: -13223 Hz, -2.6%
[035047] [D] Lowest error: 0.034200%. Using 48pF.

Cleaned off flux and got:

[021200] [D] measure_frequency(): counts: 32138, time: 1000670, frequency: 513863 Hz
[021200] [D] Trimcap: 0pF, Error: 13863 Hz, 2.8%
[022202] [D] measure_frequency(): counts: 32001, time: 999751, frequency: 512143 Hz
[022202] [D] Trimcap: 8pF, Error: 12143 Hz, 2.4%
[023204] [D] measure_frequency(): counts: 31904, time: 999994, frequency: 510467 Hz
[023204] [D] Trimcap: 16pF, Error: 10467 Hz, 2.1%
[024206] [D] measure_frequency(): counts: 31800, time: 999955, frequency: 508822 Hz
[024206] [D] Trimcap: 24pF, Error: 8822 Hz, 1.8%
[025208] [D] measure_frequency(): counts: 31699, time: 1000019, frequency: 507174 Hz
[025208] [D] Trimcap: 32pF, Error: 7174 Hz, 1.4%
[026210] [D] measure_frequency(): counts: 31577, time: 999971, frequency: 505246 Hz
[026210] [D] Trimcap: 40pF, Error: 5246 Hz, 1.0%
[027212] [D] measure_frequency(): counts: 31476, time: 999862, frequency: 503685 Hz
[027213] [D] Trimcap: 48pF, Error: 3685 Hz, 0.7%
[028214] [D] measure_frequency(): counts: 31393, time: 999867, frequency: 502354 Hz
[028214] [D] Trimcap: 56pF, Error: 2354 Hz, 0.5%
[029216] [D] measure_frequency(): counts: 31291, time: 999870, frequency: 500721 Hz
[029216] [D] Trimcap: 64pF, Error: 721 Hz, 0.1%
[030218] [D] measure_frequency(): counts: 31189, time: 1000105, frequency: 498971 Hz
[030218] [D] Trimcap: 72pF, Error: -1029 Hz, -0.2%
[031221] [D] measure_frequency(): counts: 31116, time: 1000610, frequency: 497552 Hz
[031221] [D] Trimcap: 80pF, Error: -2448 Hz, -0.5%
[032224] [D] measure_frequency(): counts: 31009, time: 1000606, frequency: 495843 Hz
[032224] [D] Trimcap: 88pF, Error: -4157 Hz, -0.8%
[033227] [D] measure_frequency(): counts: 30916, time: 1000607, frequency: 494355 Hz
[033227] [D] Trimcap: 96pF, Error: -5645 Hz, -1.1%
[034230] [D] measure_frequency(): counts: 30835, time: 1000591, frequency: 493068 Hz
[034230] [D] Trimcap: 104pF, Error: -6932 Hz, -1.4%
[035233] [D] measure_frequency(): counts: 30731, time: 1000699, frequency: 491352 Hz
[035233] [D] Trimcap: 112pF, Error: -8648 Hz, -1.7%
[036236] [D] measure_frequency(): counts: 30633, time: 1000531, frequency: 489867 Hz
[036237] [D] Trimcap: 120pF, Error: -10133 Hz, -2.0%
[036239] [D] Lowest error: 0.144200%. Using 64pF.

I don't know why added the caps seemed to add way more capacitance then expected. It looks like I added more like 80pf rather than the 13.6pF expected.

The better tuning increased the rate of QRM detections from fairly frequent to constant. Running in my lab with otherwise default settings.

Over the next hours I noticed the capacitance drifted back down again, needing more from the trimcaps. Maybe board drying out or cooling down? The next day it was using 96pF or 88pF trimcaps.

Next day, added 51pF. Now it gets: Trimcap: 0pF, Error: -134 Hz, -0.0%

Also added 22uF ceramic to power socket pins, and 1nF from IRQ to ground. Removed electrolytic. Also modified µC board - added bigger 3.3V regulator with ceramic caps and 470uF input cap.

Get occasional QRM reports but nothing like without any caps that started with.

Noise

It's very sensitive to interference / noise. It was constantly reporting disturbers.

I tried adding more caps to the power supply and put a ferrite round the leads. The biggest difference seen so far came from soldering a 47uF electrolytic to the back of the connector on the sensor board. This seems to have stopped the disturber reports. I also have a ferrite on the leads but this makes less / no difference I think.

Probe disturbance

Touching any of the pins on the sensor board causes spurious reports. That is, one multimeter lead touched to any pin, e.g. ground, with the other lead connected to nothing, or the other end of the lead disconnected, causes report of disturber, or lightning, or an error. Very often an I2C error is reported by the µC, and the interrupt register reads 15. Not sure if the 15 is coming from the sensor or I2C lib on a failed read.

This problem was resolved with the cap mentioned above.

Errata?

Interrupt pin does not go high on detection after initial configuration / cap trimming, until a read is made to the interrupt register. After that it works normally.

(Not extensively tested, maybe reading other registers works too.)

I read that some boards have wrong tuning caps. I couldn't find anything about cap values in the datasheet, but one website suggested 680pF + 270pF = 950pF, which looks about right, maybe a bit small. My DFRobot board has 470pF x 2 = 940uF, according to the schematic anyway, which seems to be a bit too little.

as3935.txt · Last modified: 2024/07/25 22:33 by river

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki