![]() |
Forum Index : Microcontroller and PC projects : AS3935 lightning detector
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Curious Jim, What do these first lines of your latest code do? I can make an assumption. [Code]'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 [/code] Phil. |
||||
Justplayin![]() Guru ![]() Joined: 31/01/2014 Location: United StatesPosts: 328 |
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 I am not a Mad Scientist... It makes me happy inventing new ways to take over the world!! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6286 |
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 VK7JH MMedit |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
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. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6286 |
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 VK7JH MMedit |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Just looking at the output of the latest code this morning & notice this, [Code]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:[/code] 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. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6286 |
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 VK7JH MMedit |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
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 |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6286 |
A bad link makes life difficult! I have noticed that restarting the code once the capacitor value has been found and set i the code seems to work better. When simply exiting the capacitor set routine and monitoring, the module seems too quite. With my test setup (on the bench), I can create Disturber events by putting a finger on the module. Too much touching and I get a noise too high. My simulator seems to work OK and I can create close and distant events easily enough. I still need to put the module outside away from the computers etc and play with the gain settings. Jim VK7JH MMedit |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Jim, Do you think I am doing totally the wrong thing by using an ESP-8266 on the console so close to the AS3935? I know it's up at 2.4Gig, but I'm not much of an RF guru when it comes to harmonics & other interference. And yes, the code seems to run better if you don't visit the cap routine. Phil. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6286 |
Switchmode power supplies and 240V LED lights are more likely to cause interference. If you aren't getting "noise too high" too often or too many Disturber events, I would wait for a storm and see what happens. I haven't play with the ESP-8266 for a while and didn't look at it's RF noise. Jim VK7JH MMedit |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Has anyone got a lightning detector working properly? I'm going to include on in my weather station but reading the posts here it seems very complex to get it working and not certain if anyone has even got it working right |
||||
RonnS Senior Member ![]() Joined: 16/07/2015 Location: GermanyPosts: 121 |
hello Lew, idont know but i know you can buy a asembled one with Housing from ELV Germany these Parts should working Regards Ron |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thanks Ron, but that won't integrate into the weather station I have |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I'm having problems with my Lightning detector I suspect it's due to me using Pin 2 on the 28 pin MM as the IRQ pin on the detector Can anyone verify this by looking at the output when I try and run it? Is there any way round this to make pin 2 work or will I need to make a new board with one of the Count pins as the IRQ pin? [code] > RUN Playing With Fusion: AS3935 Lightning Sensor, SEN-39001-R01 beginning boot procedure.... wrt: 00 Act: 00 wrt: 20 Act: 00 wrt: 00 Act: 00 wrt: 24 Act: 00 set up for indoor operation wrt: 00 Act: 00 disturber detection enabled wrt: 00 Act: 00 wrt: 00 Act: 00 capacitance set to 8x0 = 0pF AS3935 manual cal complete 04:03:27 01-01-2000 Reg &H00: 00 Reg &H01: 00 Reg &H02: 00 Reg &H03: 00 Reg &H04: 00 Reg &H05: 00 Reg &H06: 00 Reg &H07: 00 Reg &H08: 00 AFE Gain Boost: 00000 Power-down: 0 Noise Floor Level: 000 Watchdog threshold: 0000 Clear statistics: 0 Minimum num lightning:00 Spike rejection: 0000 Freq div -ant tuning: 00 Mask Disturber: 0 Interrupt: 0000 Energy LSB: 00000000 Energy MSB: 00000000 Energy MMSB: 00000 Distance estimation: 000000 Display LCO on IRQ: 0 Display SRCO on IRQ: 0 Display TRCO on IRQ: 0 Internal Tuning Caps: 0000 Energy: 0[/code] This is the error I get [137] SetPin IRQ_PIN, fin Error: Invalid configuration Does the IRQ pin have to be FIN? EDIT: I Changed the IRQ input to DIN and not now runs with "no errors" OTHER than the capacitance being 0pF When I try and change the value to 4pF it does nothing but ignore the input??? [quote]> run Playing With Fusion: AS3935 Lightning Sensor, SEN-39001-R01 beginning boot procedure.... wrt: 00 Act: 00 wrt: 20 Act: 00 wrt: 00 Act: 00 wrt: 24 Act: 00 set up for indoor operation wrt: 00 Act: 00 disturber detection enabled wrt: 00 Act: 00 wrt: 00 Act: 00 capacitance set to 8x0 = 0pF AS3935 manual cal complete 04:16:37 01-01-2000 Reg &H00: 00 Reg &H01: 00 Reg &H02: 00 Reg &H03: 00 Reg &H04: 00 Reg &H05: 00 Reg &H06: 00 Reg &H07: 00 Reg &H08: 00 AFE Gain Boost: 00000 Power-down: 0 Noise Floor Level: 000 Watchdog threshold: 0000 Clear statistics: 0 Minimum num lightning:00 Spike rejection: 0000 Freq div -ant tuning: 00 Mask Disturber: 0 Interrupt: 0000 Energy LSB: 00000000 Energy MSB: 00000000 Energy MMSB: 00000 Distance estimation: 000000 Display LCO on IRQ: 0 Display SRCO on IRQ: 0 Display TRCO on IRQ: 0 Internal Tuning Caps: 0000 Energy: 0 wrt: 80 Act: 00 Frequency: 16 New tuning capacitor (1 - 120pF)? 4 wrt: 00 Act: 00 capacitance set to 8x0 = 0pF Capacitor set to 0pF Frequency: 16 New tuning capacitor (1 - 120pF)? 4 wrt: 00 Act: 00 capacitance set to 8x0 = 0pF Capacitor set to 0pF Frequency: 16 New tuning capacitor (1 - 120pF)? 4 wrt: 00 Act: 00 capacitance set to 8x0 = 0pF Capacitor set to 0pF Frequency: 16 New tuning capacitor (1 - 120pF)?[/quote] |
||||
macca Newbie ![]() Joined: 21/02/2017 Location: AustraliaPosts: 32 |
Hi to all Under the same program how can I change the settings say from 0 to 2 or ratio 16 to 64. Having a play around with AS3935 from MikroElektronika on MM+ Function AS3935_SetLCO_FDIV(fdiv) ' This function sets LCO_FDIV register. This is useful in the tuning of the antenna ' LCO_FDIV register: add 0x03, bits 7:6 ' default value: 00 ' set 0, 1, 2 or 3 for ratios of 16, 32, 64 and 128, respectively. ' See pg 23, Table 20 for more info. AS3935_SetLCO_FDIV = AS3935_reg_write(&H03, &HC0, ((fdiv And &H03) << 5)) End Function Regards John ![]() |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6286 |
To change the divisor to 64,simply call the function re = AS3935_SetLCO_FDIV(2) I would put the call at the end of the AS3935_setup SUB In the setcap SUB, for the frequency display to make sense, you would also need to change print "Frequency: ";str$(pin(IRQ_PIN)*16) to print "Frequency: ";str$(pin(IRQ_PIN)*64) As the MM is capable of reading the higher frequencies, I didn't both changing from the default. Jim VK7JH MMedit |
||||
macca Newbie ![]() Joined: 21/02/2017 Location: AustraliaPosts: 32 |
Thank you TassyJim I have changed as to what you sent me. Changed to 32 and the program seems to settle down not so many Disturbers found. I have a ACURITE Lightning detector so will monitor and do a comparison. storms this weekend Regards John |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
Never seen anyone happy about this... perhaps Grogs should take some of what you're having ![]() ![]() ![]() |
||||
macca Newbie ![]() Joined: 21/02/2017 Location: AustraliaPosts: 32 |
Hi TassyJim What simulator are you using to trigger an event as I don't have one at the moment and would like to play around with this project. Regards John |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |