Due is generally faster and has 2 more bits ADC resolution. Depending on your circuit, these extra 2 bits may be useless because of noise. Noise can be filtered out by taking many samples and averaging, but that is not an option for lightning detection because of the short timescales involved.
As for the speed, the code you posted has been optimised to give fast conversion times on atmega328. This code will not run on Due, forcing you to go back to the standard Arduino functions like analogRead(). This may remove any speed advantage that the Due has.
robtillaart:
besides the prescaler you need to know that a 12bit ADC goes from 0..4095
where the Arduino UNO has a range from 0..1023
There are some related variables e.g. minimum = 1023; that should be changed.
Good point, thanks.
PaulRB:
Due is generally faster and has 2 more bits ADC resolution. Depending on your circuit, these extra 2 bits may be useless because of noise. Noise can be filtered out by taking many samples and averaging, but that is not an option for lightning detection because of the short timescales involved.
As for the speed, the code you posted has been optimised to give fast conversion times on atmega328. This code will not run on Due, forcing you to go back to the standard Arduino functions like analogRead(). This may remove any speed advantage that the Due has.
Noise is one of the things I've been tinkering with reducing. For instance, I even had a custom PCB made a while ago (for another purpose) and fit this circuit on some of the spare space on that, so the antenna is the only wire going anywhere, and it's mounted atop a Pro Mini and hooked up to a pack of AAs that run through the onboard linear regulator.
I'm not sure if that changes anything with the usefulness of the extra 2 bits, but it may.
For some reason (maybe from some of the EMON forums) I'm under the impression that modifying the prescaler on the 328 reduces the reliability of the readings, whereas running the SAM3X with just analogRead() wouldn't have the downgrade in reliability. But, I don't remember exactly what the context was, so maybe that's completely off base.
Thanks for the replies. At the very least, I'll give it a try with simply analogRead and changing the range.
Using simply analogRead() won't give you a real henancement compared to an atmega 328. Whereas ADC direct port programming will give you a real benefit in term of speed (max 1 Msps), SRAM (96 K) and even accuracy (12-bit conversions, or an equivalent of 16-bit conversions if you can oversample 256 times).