Home  |  Contents 
Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: AS3935 lightning detector Post ReplyPost New Topic
<< Prev Page of 5 Next >>
Author
Message << Prev Topic | Next Topic >>
TassyJim
Guru
Guru


Joined: 07 August 2011
Location: Australia
Online Status: Offline
Posts: 2257
Posted: 06 July 2017 at 9:37am | IP Logged Quote TassyJim

Phil,
There are a couple of bugs in my code.
Once you know the correct capacitance value, change the value in the DIM statement to suit and then just run the main program.

I hope that makes sense!

I will update the code with the fixes later.

Jim



__________________
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm


Back to Top View TassyJim's Profile Search for other posts by TassyJim Visit TassyJim's Homepage
 
TassyJim
Guru
Guru


Joined: 07 August 2011
Location: Australia
Online Status: Offline
Posts: 2257
Posted: 06 July 2017 at 9:52am | IP Logged Quote TassyJim

2017-07-06_094644_AS3935.zip
OK
This version runs the same as before with a few 'refinements'
A disturber event simply prints a 'D' rather than waste a full line.
all other events print the time and event.

Calibrating the capacitor value should work properly now.
C to enter the set routine, -1 to exit the set routine.

I intend to add adjustments for the other settings eventually.

I made a lightning simulator using the Signal Generator Geoff described a few months ago. It seems to work.

More details about that later.

Jim



__________________
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm
Back to Top View TassyJim's Profile Search for other posts by TassyJim Visit TassyJim's Homepage
 
Phil23
Guru
Guru


Joined: 27 March 2016
Location: Australia
Online Status: Offline
Posts: 1137
Posted: 06 July 2017 at 9:37pm | IP Logged Quote Phil23

Thanks Jim,

It looks like there's a fair bit of info about on different calibration settings.
Mostly Arduino routines. Trying to see if I can understand them a bit.

Setting the Noise floor was one that jumped out.

Found missing edit I had which set 80pF as 8 so past that.

But getting a lot of disturbers & a few phantom strikes without triggering the emulator.

Guess that's where the noise floor comes in.

Final thing I did last night was run it for about 30 seconds & capture the output.

A NP++ search for "Disturber Detected" counts 73 instances.
But if I then do a search for "Energy: 0", I get a count of 62.
Some of the Disturber entries have a significant Energy Value.

Don't quite understand what it means, but it's an interesting observation.

Searching "Lightning Detected" has a count of 13,
And Searching "Energy: 0\r\nLightning detected!" a count of 7.

Don't know what that explains either.

I attached the capture file if you're interested.

Will create another one later & try & add known presses of the different buttons on the Emulator at known time stamps.

Cheers.

Phil.2017-07-06_213659_AS3935_Output.zip

Back to Top View Phil23's Profile Search for other posts by Phil23
 
Phil23
Guru
Guru


Joined: 27 March 2016
Location: Australia
Online Status: Offline
Posts: 1137
Posted: 06 July 2017 at 9:46pm | IP Logged Quote Phil23

TassyJim wrote:
A disturber event simply prints a 'D' rather than waste a full line.
all other events print the time and event.


I might revert it to the full line for now;
I can easily search that in a capture file.

Another thing that might help is a Variable to count the disturbers & report them.

Not sure how you'd define my front office in regards to RF noise.

There's 3 Fluro's; Elecronic ballast in the 4' & iron in the two 2' ones.

There's a Wifi AP a few metres away & another about 5m away in the next room.

There's also an ESP-01 on the breadboard I'm using, about 3" away from the Lightning module. Not sure if that's a bad thing or irrelevant.

Phil.
Back to Top View Phil23's Profile Search for other posts by Phil23
 
Phil23
Guru
Guru


Joined: 27 March 2016
Location: Australia
Online Status: Offline
Posts: 1137
Posted: 06 July 2017 at 9:53pm | IP Logged Quote Phil23

Curious Jim,

What do these first lines of your latest code do?
I can make an assumption.

'MMEDIT!!! Basic Version = Micromite_X_V5.3
'MMEDIT!!! Port = COM4:38400:10,300
'MMEDIT!!! Device = Micromite_X_V5.3
'MMEDIT!!! Config = 100111101121010110020000110001
  ' lightning detector code translated from Arduino code
  ' by Jim Hiley tassyjim on TBS forum


Phil.
Back to Top View Phil23's Profile Search for other posts by Phil23
 
Justplayin
Senior Member
Senior Member
Avatar

Joined: 31 January 2014
Location: United States
Online Status: Offline
Posts: 248
Posted: 06 July 2017 at 11:14pm | IP Logged Quote Justplayin

Phil,

When testing with the lightening simulator be careful the detector is not too close. Otherwise you will get "disturbers" instead of lightening detections. I normally start with the simulator about 20cm away and slowly move it closer while triggering the weakest strike. When I get a positive lightening detection (normally about 5-7cm) I stop moving and proceed to testing the other strike triggers.


--Curtis

Edited by Justplayin on 06 July 2017 at 11:15pm


__________________
I am not a Mad Scientist... It makes me happy inventing new ways to take over the world!!

CGCOLORMAX2, CGMMSTICK1, DUINOMITE-MINI, MICROMITE-150, MICROMITE-170, SKINNYMITE, Explore64
Back to Top View Justplayin's Profile Search for other posts by Justplayin
 
TassyJim
Guru
Guru


Joined: 07 August 2011
Location: Australia
Online Status: Offline
Posts: 2257
Posted: 06 July 2017 at 11:23pm | IP Logged Quote TassyJim

Phil23 wrote:
Curious Jim,

What do these first lines of your latest code do?
I can make an assumption.

'MMEDIT!!! Basic Version = Micromite_X_V5.3
'MMEDIT!!! Port = COM4:38400:10,300
'MMEDIT!!! Device = Micromite_X_V5.3
'MMEDIT!!! Config = 100111101121010110020000110001
  ' lightning detector code translated from Arduino code
  ' by Jim Hiley tassyjim on TBS forum


Phil.


In MMEdit, if you have the option set in preferences,



The syntax and port settings are saved in the BAS file.
I should have removed them before posting the code.

I find it useful when I am playing with various devices at the same time. Switching code automatically switches the port settings for me.

The config line doesn't do anything yet.

This option appeared in V3.7.0 in April

Jim


__________________
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm
Back to Top View TassyJim's Profile Search for other posts by TassyJim Visit TassyJim's Homepage
 
Phil23
Guru
Guru


Joined: 27 March 2016
Location: Australia
Online Status: Offline
Posts: 1137
Posted: 06 July 2017 at 11:37pm | IP Logged Quote Phil23

Thanks Jim,

And yes, very useful.
Often miss changing the connection IP when I switch devices.
I just set that option, but not sure where to go from there.

Should MMedit write those 4 line into the beginning of the code,
or do I need to paste them from elsewhere..

Phil.
Back to Top View Phil23's Profile Search for other posts by Phil23
 
TassyJim
Guru
Guru


Joined: 07 August 2011
Location: Australia
Online Status: Offline
Posts: 2257
Posted: 07 July 2017 at 12:43am | IP Logged Quote TassyJim

MMedit will attached the config lines each time the code file is saved.
That means that the port settings and syntax file will get updated if you open the file, change the settings then save again.

If you use the same basic code for multiple devices, you will have to keep changing the port.

For normal use, forget about the added lines. Opening the file in another editor will have them as comments and if you leave them alone, they will still be correct when you open the file in MMedit again.

If you open a file that doesn't have the config lines, MMedit will stay with the current settings.

Jim


__________________
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm
Back to Top View TassyJim's Profile Search for other posts by TassyJim Visit TassyJim's Homepage
 
Phil23
Guru
Guru


Joined: 27 March 2016
Location: Australia
Online Status: Offline
Posts: 1137
Posted: 07 July 2017 at 11:15pm | IP Logged Quote Phil23

Just looking at the output of the latest code this morning & notice this,

08-07-2017 09:10:28 08-07-2017 09:10:29 DDDDDDDDDDDDDDDDDD
08-07-2017 09:10:39 DDDDDDDDDDDDDDDDDDDD
08-07-2017 09:10:50 DDD
08-07-2017 09:10:52 DDDDDDDDDDDDDDDDDDDD
08-07-2017 09:11:02 DDDDDDD
08-07-2017 09:11:07 DD
08-07-2017 09:11:08 DDDDD
08-07-2017 09:11:11 DDDDDDDDDDD
08-07-2017 09:11:17 DDDDDDDDDD
08-07-2017 09:11:24 DDDDDDDDDDDDDDDwrt: 8B Act: Frequency: 499840
New tuning capacitor (1 - 120pF)? 88
capacitance set to 8x0 = 0pF
Capacitor set to 0pF

Frequency: 499856
New tuning capacitor (1 - 120pF)? 88
Frequency: 499856
New tuning capacitor (1 - 120pF)? -1
Playing With Fusion: AS3935 Lightning Sensor, SEN-39001-R01
beginning boot procwrt: 01 Act: wrt: 0B Act: 0010
Clear statistics:     0
Internal Tuning Caps:


I had edited the Cap value to 88 in the code (Shipped marked 80pF),
but changing it's value seems to give an unexpected result.

Phil.
Back to Top View Phil23's Profile Search for other posts by Phil23
 
TassyJim
Guru
Guru


Joined: 07 August 2011
Location: Australia
Online Status: Offline
Posts: 2257
Posted: 07 July 2017 at 11:39pm | IP Logged Quote TassyJim

I see a number of problems with your output.
There shouldn't be the timestamps on the lines with 'D'
You seem to miss a few CR's and possibly other bits of the output.
and the problem with zero capacitance.

My output from initial starting and setting the capacitance to 88 then back to 112 is:
> RUN
Playing With Fusion: AS3935 Lightning Sensor, SEN-39001-R01
beginning boot procedure....
wrt: 24 Act: 24
wrt: 20 Act: 20
wrt: 00 Act: 00
wrt: 24 Act: 24
set up for indoor operation
wrt: 00 Act: 00
disturber detection enabled
wrt: 00 Act: 00
wrt: 0E Act: 0E
capacitance set to 8x14 = 112pF
AS3935 manual cal complete

09:28:43  08-07-2017
Reg &H00: 24
Reg &H01: 22
Reg &H02: C2
Reg &H03: 00
Reg &H04: 00
Reg &H05: 00
Reg &H06: 00
Reg &H07: 3F
Reg &H08: 0E
AFE Gain Boost:       10010
Power-down:           0
Noise Floor Level:    010
Watchdog threshold:   0010
Clear statistics:     1
Minimum num lightning:00
Spike rejection:      0010
Freq div -ant tuning: 00
Mask Disturber:       0
Interrupt:            0000
Energy LSB:           00000000
Energy MSB:           00000000
Energy MMSB:          00000
Distance estimation:  111111
Display LCO on IRQ:   0
Display SRCO on IRQ:  0
Display TRCO on IRQ:  0
Internal Tuning Caps: 1110
Energy:   0
wrt: 8E Act: 8E
Frequency: 499664
New tuning capacitor (1 - 120pF)?
Frequency: 499664
New tuning capacitor (1 - 120pF)? 88
wrt: 8B Act: 8B
capacitance set to 8x11 = 88pF
Capacitor set to 88pF

Frequency: 504560
New tuning capacitor (1 - 120pF)? 112
wrt: 8E Act: 8E
capacitance set to 8x14 = 112pF
Capacitor set to 112pF

Frequency: 499664
New tuning capacitor (1 - 120pF)? -1
wrt: 0E Act: 0E
Playing With Fusion: AS3935 Lightning Sensor, SEN-39001-R01
beginning boot procedure....
wrt: 24 Act: 24
wrt: 20 Act: 20
wrt: 00 Act: 00
wrt: 24 Act: 24
set up for indoor operation
wrt: 01 Act: 00
disturber detection enabled
wrt: 00 Act: 00
wrt: 0E Act: 0E
capacitance set to 8x14 = 112pF
AS3935 manual cal complete

09:29:41  08-07-2017
Reg &H00: 24
Reg &H01: 22
Reg &H02: C2
Reg &H03: 00
Reg &H04: 00
Reg &H05: 00
Reg &H06: 00
Reg &H07: 3F
Reg &H08: 0E
AFE Gain Boost:       10010
Power-down:           0
Noise Floor Level:    010
Watchdog threshold:   0010
Clear statistics:     1
Minimum num lightning:00
Spike rejection:      0010
Freq div -ant tuning: 00
Mask Disturber:       0
Interrupt:            0000
Energy LSB:           00000000
Energy MSB:           00000000
Energy MMSB:          00000
Distance estimation:  111111
Display LCO on IRQ:   0
Display SRCO on IRQ:  0
Display TRCO on IRQ:  0
Internal Tuning Caps: 1110
Energy:   0





__________________
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm
Back to Top View TassyJim's Profile Search for other posts by TassyJim Visit TassyJim's Homepage
 
Phil23
Guru
Guru


Joined: 27 March 2016
Location: Australia
Online Status: Offline
Posts: 1137
Posted: 08 July 2017 at 1:55am | IP Logged Quote Phil23

The problem with my output seemed to be Teraterm dropping data for some strange reason (it or the IP stack).

Even in MMedit I couldn't get valid data.

Resolve it by closing all Teraterm session (had 2 that had been up a day or so).

Maybe not so much Teraterm as the TCP/IP stack overflowing.

Didn't suspect your code, as I only edited pin#'s & switched to I2C.
Hadn't touched the output.

Phil
Back to Top View Phil23's Profile Search for other posts by Phil23
 


<< Prev Page of 5 Next >>
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1094 seconds.
Privacy Policy     Process times : 0.02, 0, 0, 0.09