I am trying to sample 6 different analog AC inputs in order to continuously monitor the maximum value of each AC input. At the moment a function gets called to take a sample from the AC signal once per 'main-loop'. The sample rate however becomes too slow when I monitor all 6 inputs.
I was thinking of using attachInterrupt(function, period) and thus call every function more regularly that the time taken to run through my main loop. would this work? is there a better way of achieving this?
Welcome to the Forum. For this problem, it would be best if you could post your code. Please read the two posts at the top of this Forum by Nick Gammon on guidelines for posting here, especially the use of code tags which make the code looklike thiswhen posting source code files. Also, before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.
There are scheduler libraries which can be used like this - set it to call a function on a defined time period. However most of the options I've seen don't use interrupts - they rely on the main loop calling the scheduler service function, which means it's good for time periods like seconds to weeks; not good for milliseconds.