Hello, I've searched for a while and have'nt found any solution or any similar project
I'd like to create a loop that would last 60micro seconds ans tha the arduino print 1 on the screen if the voltage have gone over a command and 0 if it has remained under, and to repeat that loop to infinity and beyond XD
I think that I need the Timerone.h library, but I don't really know how to do so, or if it is even possible.
I've thought to set a number to 0 at the begnning of the loop and change it to 1 if it goes over the critical tension and print it at the end of the loop, but one more time I don't really know if it is possible I just think by analogy with Mapple that I'm used to use ^^"
Thanks for your help !
In order to answer this question for yourself, you could investigate these questions:
How much time does it take to read the ADC?
How much time does it take to print a "1" or a "0" to the screen?
Or you could ask the question "is an ADC reading necessary, or could I use the comparator?"
Perhaps if you describe your overall project people will be better able to give advice.
There might be an alternative/simpler way to do what needs to be done.
Seems a bit fast for analogRead. Have a think about how much time over threshold would count as bad. If it is more than 50 microseconds then some contraption with opamps and one FET to get a digital pin above its thresold would do, as one digitalRead takes apparently 8 to 40 microseconds on my 16MHz 328 based nano.v.3.0
If it is 5-50 microseconds high which you want to detect, then consider making something containing an extra capacitor and diode between an op-amp used as a preamplifier and fet used as a thresholder.
If it is much less than 5 microsecond spikes which you are looking for then perhaps borrow an oscilloscope with digital persistance and sufficient bandwidth. Those can be left running for an hour any any spikes which occurred during my lunch hour show up on the screen.
Seems a bit fast for analogRead
... which is why I asked if one is actually needed.
A sixty microsecond sample interval seems awfully short for something that is just printing to a serial port. Do you really mean you want to know what has happened within sixty millionths of a second? If so, where does that requirement come from? Your description suggests you're expecting to detect transients that may be even shorter than those sixty microseconds. What's the shortest transient you're trying to detect?