View previous topic :: View next topic |
Author |
Message |
njepsen
Joined: 13 Aug 2007 Posts: 469
|
Posted: Wed Sep 05, 2018 11:10 pm Post subject: AS3935 Franklin Lightning Sensor IC |
|
|
Hi Guys,
I have just got hold of one of these devices for a project and am about to embark on some testing. I see that there is some suggestion of a bug? with the
device operation, and also some possible issues with resetting the IRQ after a detection?
Has anyone found any advantage in putting the atmega to sleep whilst waiting so the 3935 is not listening to processor noise?
Do you guys have any updates on your earlier experiments?
neil _________________ Neil |
|
Back to top |
|
|
mfulde
Joined: 24 Apr 2007 Posts: 21 Location: Lonsee, Germany
|
Posted: Sun Nov 08, 2020 8:40 pm Post subject: |
|
|
Hei Neil, hei all,
any progress or update on this topic?
This thread is open since a long time and the first source code was posted a long time ago.
But .... nevertheless, I have now some AS3935 chips at my desk and I am trying to get them running in my weather station project.
I studied the source code to understand how AS3935 is working. In the meantime I read also the complete datasheet and I think I understood the main facts.
Usually I'm familiar with BASCOM and ATmega but I have some problems in understanding the source code in this thread
The main topic is the interrupt handling....
Is it correct, that the AS3935 Interrupt signal is connected to Port B.1 (Int_pin Alias Pinb.1)? I think it must, because Timer Counter 1 is used for 500kHz calibration.
But shortly before the main loop, the DO-WHILE Loop, I can see the following code:
Code: | Pcmsk1 = &B00000010 : Portb.1 = 1
Enable Pcint1 : On Pcint1 Als_is
|
With the bit mask for PCMSK1 PCINT9 is activating , which corresponds to my assumption, that Interrupt is connected to PortB.1
Then, with Portb.1 = 1 the internal PullUp is activated, correct?
But the next line I really don’t understand because here PCINT1 is activated. PCINT1 is PortA.1. But PortA.1 is used for WR for the LCD display.
So, I’m completely confused!
Can somebody help me to undo the knot in my head?
Some hint or idea is very appreciated and I would be very happy to hear from you.
Kind regards and stay healthy,
Markus _________________ MaFu |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Mon Nov 09, 2020 1:06 am Post subject: |
|
|
Hi.
Show me your system configuration or schematic.
My AS3935 lightning detector has been working fine since I made it!
It runs on batteries for about half a year. |
|
Back to top |
|
|
mfulde
Joined: 24 Apr 2007 Posts: 21 Location: Lonsee, Germany
|
Posted: Mon Nov 09, 2020 8:23 am Post subject: |
|
|
Hello,
thanks for the fast feedback.
Yes, sure, I can share my schematic with you, but it is not finished yet. Also my BASCOM programm is not finished yet. I have I2C communication running with the AS3935 and functions for read and write register are programmed. I'm usually not copying code for my project, I'm writing my own code from the beginning.
In my project I use an ATmega328 for the lighning sensor and the GY-AS3935 breakout board I got from China.
My problem is currently NOT a non working program. My problem is a gap or lack of understanding the example programm in this Forum Thread and I'm wondering why and how it works. Especially the part with the interrupt. Maybe I'm completely wrong and I have overseen something but this is exactly my question.
In the example Timer Counter 1 is used for counting, and PCINT9 is configured, what is the programm doing with PCINT1 on PortA.1 used for LCD-WR-line? Why is interrupt service routine configured at the beginning of the project to B.1 and later to A.1?
In my point of view, the example code is wrong and won't work properly but this is only from theory and my understanding, looking into the code and trying to understand it. I don't have this code running on a board (because I will write my own code), I don't have the corrsponding board and I don't have the schematic from this example. _________________ MaFu |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Mon Nov 09, 2020 9:52 am Post subject: |
|
|
"Enable Pcint1" sets the [PCIE1] bit in the [PCICR] register that enables [PCMSK1].
Bit [1] of "Pcmsk1 = & B00000010" is [PCINT9]. |
|
Back to top |
|
|
mfulde
Joined: 24 Apr 2007 Posts: 21 Location: Lonsee, Germany
|
Posted: Mon Nov 09, 2020 11:13 am Post subject: |
|
|
Yes, this is exactly the point I wrote in my message yesterday. But what happens with the next line:
Code: | Pcmsk1 = &B00000010 : Portb.1 = 1
Enable Pcint1 : On Pcint1 Als_is
|
Pcmsk1 = &B00000010 : Portb.1 = 1 ...
is understood.
Enable Pcint1 : On Pcint1 Als_is...
is confusing me! _________________ MaFu |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
Posted: Mon Nov 09, 2020 1:48 pm Post subject: |
|
|
"Enable Pcint1" and the pin name "PA1 (ADC1 / PCINT1)" have the same name but different functions.
This is the BASCOM grammar that many users get lost in.
You cannot actually write "Enable Pcint9".
Read the external interrupt section of the AVR manual! |
|
Back to top |
|
|
mfulde
Joined: 24 Apr 2007 Posts: 21 Location: Lonsee, Germany
|
Posted: Mon Nov 09, 2020 5:55 pm Post subject: |
|
|
Aha, chakka, that's it, got it
Now I understand .... this was the missing puzzle piece ....
ATmega only supports
Pin Change Interrupt Request 0
Pin Change Interrupt Request 1
Pin Change Interrupt Request 2
thats it.
Every PCINT 0-2 has it's own Pin Change Mask Register, responsible for 8 PCINT's
Because PCINT9 is mapped in PCINT1 the mask must be set to 0x00000010 and PCINT1 must be enablöes and linked to ISR.
Thanks!
I never used PCINT's before and I was completely wrong, assuming that every External PCINTx has it's own interrupt vector.
Now it's clear! _________________ MaFu |
|
Back to top |
|
|
Ross_ValuSoft
Joined: 20 Nov 2005 Posts: 275 Location: Melbourne, Australia
|
Posted: Wed Dec 30, 2020 1:13 pm Post subject: |
|
|
Hello O-Family.
Firstly... Happy New Year!
I am interested in your lightning sensor project but cannot read Japanese; my problem, not yours.
So I attempted to Google translate your https://www.ne.jp/asahi/shared/o-family/ElecRoom/AVRMCOM/AS3935/AS3935_test.html#AS3935Clk
... but Google says I cannot do that because you have an English Manual. Where can I find that please?
Cheers,
Ross _________________ Ross McKenzie
Melbourne Australia |
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 320 Location: Japan
|
|
Back to top |
|
|
Ross_ValuSoft
Joined: 20 Nov 2005 Posts: 275 Location: Melbourne, Australia
|
Posted: Thu Dec 31, 2020 2:42 am Post subject: |
|
|
Many thanks.
Now I have some quiet reading for the holidays.
Best wishes for 2021.
Ross _________________ Ross McKenzie
Melbourne Australia |
|
Back to top |
|
|
|