need an estimate of time required to scan 11x8 matrix

I want to use an adriuno micro to scan a 8 x 11 matrix. i need to do this in under 2ms, maybe 1ms, possibly including debounce. I am a noob. About how much time will it take to do this scan?

Thanks, Mike

Depends on what you mean by "scan" and "matrix". If you're talking about iterating through a multidimensional array of ints looking for a specific value, then it shouldn't be a problem.The Arduino Micro runs at 16MHz. That's 16,000 instructions per mS. That would give you an average of 181 instruction per item in this "matrix" to do whatever you need to do to "scan" it.

This functions exactly like a standard keyboard matrix, I the need to detect and identify the switch the closed for the 88 possible switches (only one switch will be actuated at a time) in under 2ms, as their closure time could be as little as that. So, the polling cycle needs to be less than 2ms. I would do this with pull ups on the output side.

DigitalWrite digitalRead , AFAIK, takes 4 - 5 usec. 88 x 5 = 440 usec. You have half a millisec to do something else. Way to accelerate, direct readings/writing port register, especially if all 8 lines belong to same port you can read in 2 cycles CPU (125 nanosec.)

Why not try it with the Keypad.h library, see if its fast enough?

I am unfamiliar with how i could get the time used by using the library

Mike

Add some start_time = millis() and end_time = milis() statements in your code, see how long it takes to get thru the code.

Something like this:

time_start = micros();

    fix_fftr( fx, FFT_SIZE );

time_fft  = micros() - time_start;

You checking time - micros() before and tight after some procedure, than printing out via serial monitor your results.
Arduino scetch as an example , linked at this page:
http://coolarduino.wordpress.com/2011/09/03/arduino-musical-note-recognition-pushing-the-limits/

CrossRoads:
Why not try it with the Keypad.h library, see if its fast enough?

I throttle the keypad library so a slight modification would be required before he could do this. I tested a sketch with the throttling removed and just as Magician said it requires 448uS per loop. Of course that includes the entire sketch so his calculated value of 440uS is slightly more accurate.

You should read up what debunce means. You can't debunce in a millisecond.

How do you know only one button will be pushed at a time ?

Because that's the stated requirement :wink:

liudr:
You should read up what debunce means. You can't debunce in a millisecond.

Actually it might be possible. I use a state machine to debounce after scanning so if his hardware needs to have the scan completed in 1mS the debouncing could be completed separately. Some things would need to be stripped out of the code but who knows what might work.

michinyon:
How do you know only one button will be pushed at a time ?

If your requirement is to test for a single button then you simply ignore everything else after detecting the first one.

Another way is to store Highs and Lows into an array for ALL the buttons that are being pushed. Then you can post-process the array any way you like. With a 1mS time limit I assume that his hardware is not a keyboard and may return multiple detections per scan.

mstanley:

liudr:
You should read up what debunce means. You can't debunce in a millisecond.

Actually it might be possible. I use a state machine to debounce after scanning so if his hardware needs to have the scan completed in 1mS the debouncing could be completed separately. Some things would need to be stripped out of the code but who knows what might work.

Same with my phi_interfaces library. You just can't debounce in 1ms but you can finish a scan within 1ms and debounce with state machine.

Thank you everyone for your input.

This is an attempt to hack a electronic soft tip dartboard. Research on the internet indicates that the pulse could be as little as 1ms and as much as 4ms. Hard thrown darts sometime cause false readings in some false sectors. It is possible that i will find simply ignoring any other switch closures past the initial detection with a delay will be effective. I suspect that no the hit sector would always be closed first before any other chatter on other sectors would occur. I will find out with testing and experimentation. The reason I ask the original question is that I have not yet purchased the board, and I don't want to go thru to process of doing this and fail due to hardware limitations. After I determine a dart has registered, I will send the information to a pc by emulating an usb keyboard, where the input will be used by an external program.

So in short, It sounds like this should work. My plan would be to set all outputs low and use the chip pullups on the inputs. Continuously scan the inputs, upon detection, start setting the outputs high one at a time and recheck the input for a change in status. Once found, delay(possibly) set all outputs high except the active pin, and re query inputs to confirm correctness. So, from the initial detection to the confirmation i need to be under 1ms. Data intperpretation and transfer can be handled afterwards easily. After 1 second delay or so, the whole thing resets and stars over.

Any further conformations or opinions about my plan would be appreciated. If the opinion is that it isnt fast enough, I will look into a faster board, such as an arduino due.

Thanks, Mike