Usage of Arduino DUE for high speed data aquisition

Dear Experts,
I am rather new to ARDUINO and just want to know whether I could do the following with the DUE:
Monitoring 16 input channels providing HIGH or LOW information with each one having a speed of 5 kHz.
In case one of the 16 input channels change from LOW to HIGH an output channel should change its status to create an alarm (e.g. LED turns ON). However, some conditions must be met.
The incoming data must be analyzed in a specific way. E.G. if channel 1 is HIGH and channel 2 is HIGH, the alarm should not appear. Only in case channel 1 is HIGH and channel 2 is LOW for example, then the alarm shall appear.
I know this can be programmed and isn't that difficult. However, my question is: As the analysis will take some time, will it effect the overall speed of aquisition?

Thanks in Advance and best regards

The way I would approach this is to write a short piece of code that reads a pair of inputs and does a test and then repeat that piece a hundred or a thousand times while measuring the time from start to finish. This will enable you to get a good idea of how much throughput is possible and should only take 30 minutes or so to code.

If you are reading 16 things @ 5k/sec that’s 80k/sec. The Arduino does 16,000k instructions per second so it looks like it should be capable.


Even an ordinary 8-bit AVR Arduino could do that, it doesn't need a Due unless the analysis you speak of is very complex..

If the tests are very simple you might be able to replace them with a sequence of logical
& and |'s to do the filtering.

You'd first read all the inputs and encode in a single int, then XOR with the last
time you read the inputs. If the result is non-zero something has changed since last time
and you can do your filtering based on the bits set in the XOR result.

In fact as the pin -> port mapping on the Due is so mixed up the Arduino Mega is
a more natural choice - it has several 8 bit ports (A, F, K, L) mapped to consecutive
Arduino pins and each 8-bit port can be read in 1 instruction.

The first part of the test, reading the pins and XORing with the previous values
would take about 1 or 2us using direct port manipulation like this.