AS3935 details

After a very frustrating weekend, I am pretty confident I have the worst of the integration problems behind me. The Embedded Adventures board is a very nice board but did take the choice of SPI or I2C out of my hands. It was designed to be I2C only. Not a problem. The Arduino does I2C.

So I hooked up the break out board to my Arduino UNO and started to write some basic “Wire Library” code. How hard could this be? Well after the first day, I would say pretty hard. Turns out the AS3935 has some pretty stringent demands for reading and writing registers. Mostly, when turning around the bus, you must use a “Repeated Start” and not a more normal Stop and Start sequence. After I figured that out, I was able to realize that the Wire library does support that, but not in so many words. After Day one, I at least was getting some ACKs from the device address part of the bus transfer.

After day two, I was able to read and write most registers except register 0×00. This one kept giving me a NAK when I sent over the device address for the read after I had sent over the register address in the write part of the transaction. Much aggravation because sometimes it would work and other times not.

In the mean time, I have exchanged numerous emails with the Embedded Adventures people in the UK. They must never sleep and take days off over there because I was getting very fast turn arounds on the questions I was asking. The upshot is that they had issues as well with register 0×00. So with that in mind, I did a careful survey of the issue and discovered what must be an “undocumented feature”. Reading register 0×00 will always NAK you till such time as you read a different register. After that you can read and write any and all legal registers. I have sent out yet another email to the AMS people in Austria asking them about this issue and any other errata they might like to share.

At the end of day three with the low level communication finished, I was able to get the unit to self calibrate and to sit in listen mode. Further more, I was able to get it to respond with “disturber (not lightning)” reports when I generated sparks in the area. Without the awfully expensive lightning simulator from AMS, I will now have to sit around and wait for a storm. That might be many months from now.

But now with this off my plate (its been a running project for more than two years) I can get back to the AVC. Just so happens that I got two thermo electric coolers in the mail over the weekend just waiting to try to temperature stabilize the IMU and to characterize it for hard and soft magnetic properties.

This entry was posted in Arduino, AS3935, AVC, Components, Lightning detector, Pololu 9DOF IMU, Processors, Projects. Bookmark the permalink.

16 Responses to AS3935 details

  1. John says:

    AS3935

    Hey Skye,
    i am working on the AS3935 as a final year project and im using the 18f448 and I2C. I have no problem reading and writing to the registers but i am getting a problem reading back from the AS3935 on the IRQ pin to display the frequency of the antenna. I have a signal GEN set up sending a low amplitude with a 500kHz frequency into the AS3935 but when reading this on the IRQ pin im getting a load of rubbish.
    I was just wondering also what is the baud rate for the AS3935 i was thinking that could be my problem either.
    Any help would be great after getting bogged down in this the last few days.
    Cheers John

    • Skye Sweeney says:

      John,
      Glad someone else is using this chip! What may I ask is the goal of your project?

      Not sure sending in a signal into the AS is going to work. The antenna is an R-C-L circuit that is excited by what I would image is a multivibrator/oscillator inside the chip. Driving a signal into the chip is opposite from what the chip is trying to do and send a signal out. I would not be at all surprised that it is confused! Have you tried an antenna circuit like the one in the reference design?

      As for the bit rate, I am not sure at this moment. I am using whatever the Arduino support for it’s fastest speed. Will get back on that when I can take a measurement. But that is an interesting idea that I might be driving the clock too fast. Of course if the chip was designed right (not sure it was!) it would implement clock stretching and the speed issue would be moot.

      Have you not experienced a problem trying to read register 0 before any other register and gotten a transfer failure? If not, that would point a finger more in my direction than at the chip. Of course there still is NO excuse for the idiocy of having to wait 2ms after the interrupt before you can read the interrupt status register.

  2. John says:

    Hey Skye,
    Thanks for getting back to me.
    The goal of my project is to just build a circuit using the AS3935 and getting it communicating with the 18f448 and displaying the info on a LCD and maybe a contractor or something to simulate shutting down a power supply and having a back up or something along those lines .
    I done a nice bit of research on the NET the last day or two and i think one of my biggest problems is that i wasn’t using the right inductor for the antenna. When i set the LCO in register 8 (bit 7) i should get the resonance frequency out on the IRQ pin but i just cant seem to get it out for some reason would not having the right inductor make that much of a difference or what type did you use?. I have one ordered on line and should get it in the next few days so hopefully that sorts my problem otherwise i must have a problem in my c code.

    I purchased a made board from Embedded Adventures. It had the proper L and C values on it already.

    • Skye Sweeney says:

      The inductor, and capacitors on the antenna circuit are likely to need fairly close values. It forms an oscillation circuit. It gets adjusted by the capacitor values in Reg8. But if you change the values of the external L or C too much, I suspect the oscillator will not oscillate. Think about the motion you need to get the water in your bathtub to slosh. Now that same motion in the ocean (different LC values) is not going to do very much at all!

  3. Angelo Matta says:

    Hello Skye,

    I’m working on a project with the AS3935 with a plate that I purchased in tautic.com,i use the arduino mega2560 and i use the library available, but is responding me with much noise and response:

    Tuning out of range, check your wiring, and make sure your sensor physics laws have not changed!
    Noise floor is: 2
    Spike rejection is: 2
    Watchdog threshold is: 2
    Noise level too high, try adjusting noise floor
    Noise level too high, try adjusting noise floor
    Noise level too high, try adjusting noise floor
    Noise level too high, try adjusting noise floor

    You have some other progam, which tested in arduino and it worked?
    Angelo Matta

    • Skye Sweeney says:

      The Tautic break out board is SPI based. The one I use is I2C. The code I have would be of little use to you.

      The advice I would give you is to make sure that you have tuned the antenna properly. You need to set the bit in register 8 to send what should be a 500kHz square wave to the interrupt pin. You then need to measure this frequency and adjust the tuning bits in register 8 to find the best value to get as close to 500kHz as possible.

      Once this is done, you should start to see interrupts occurring every second or two, but the reason would a “disturber” not a strike. Disturbers are other source of magnetic noise like relays, switches, motors, that may be within range of the sensor. In my lab, every time the furnace turns on, I get an interrupt. Each time the scope switches modes and the relays inside switch, I get an interrupt.

      Now if you are getting many more interrupts, than either the antenna gain is too high or the noise floor is too low. This you will need to play around with till you get it right.

    • I too, have AS3935/Arduino setup. I see similar when starting up, so I added a second reset/calibrate and adjusted the noise floor to 3. The second calibrate has never failed. Here in Florida, we have lots of lightning, and I get lightning detection to about 30km. So, I know its working, though, I am still tuning and adjusting. (The tiny antenna does show directional properties.)

      The delay()’s here may not be needed, but I use it for my testing.

      if(!AS3935.calibrate())
      {
      Serial.println(“Tuning out of range, retrying…”);
      delay(1000);
      AS3935.reset();
      delay(1000);
      if(!AS3935.calibrate())
      {
      Serial.println(“Rats, Still out of range…”);
      delay(1000);
      }
      else
      {
      Serial.println(“Success tuning”);
      delay(1000);
      }
      }
      Serial.println(“Continuing setup…”);

  4. Angelo Matta says:

    Hello Skye,
    thanks for the reply, tell me where you he bought the plate with i2c output? You can send me the arduino program to I2c?

    thank you,
    Angelo

  5. I’ve also got the tautic board and it does occasionally see a lightning hit (it’s storming right now thats why i’m playing with it) but not reliably and I also get the noise floor is too high warning with every startup regardless of the setting of the noise floor. I gather since there are 3 bits in it’s register that you can set it from 0 to 7? the library has a calibrate function that tries to tune it to 31250Hz, but you mention 500kHz? That tautic board can do I2C so we could alter it to use your library I think. But I really dont get a good picture of how to properly use the chip from it’s data sheet.

    • Skye Sweeney says:

      The frequency of the antenna needs to be 500kHz. You can arrange the output to be sent out the interrupt pin so your micro can measure the rate and then tune to capacitor bank till you get the best value. The confusion is that there is a register on the AS3935 that will divide down the antenna frequency before it goes to the interrupt pin. The 31250Hz is 500kHz after a divide by 16.

      I will try to post my current code tonight for those that are interested.

  6. Angelo Matta says:

    Hello Skye,

    I tested the code I2C in arduino and worked with the boarding TAUTIC, seeing the instructions and it worked ….

    Angelo

  7. Angelo Matta says:

    I did not quite understand the code that you posted, but joined parts of codes, the board of tautic, I followed the manufacturer’s recommendations chip as3935 and did the following:
    MISO ==> GND
    CS ==> GND
    SI ==> 3.3V
    SCLK ==> 10K PULL UP ==> A5 ARDUINO
    MOSI ==> A4 ARDUINO
    IRQ ==> D2 ARDUINO

    for initial testing I used the Arduino Duemilanove and the Arduino UNO also tested.

    if you want I can send email, the final program …

    Angelo

    • Skye Sweeney says:

      Not sure I understand your post. You seem to have wired the Tautic for I2C and loaded the code I posted. Did it work? If not, what problems are you having? If it did work, but you make changes, I would like to have the changes for possible improvement to my code. You could send them to “Skye at fll-freak dot com”.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Refresh