Go Down

Topic: need an estimate of time required to scan 11x8 matrix (Read 3329 times)previous topic - next topic

mchartre

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

Arrch

#1
Jan 17, 2013, 12:52 am
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.

mchartre

#2
Jan 17, 2013, 01:19 am
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.

Magician

#3
Jan 17, 2013, 01:31 am
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.)

#4
Jan 17, 2013, 01:52 am
Why not try it with the Keypad.h library, see if its fast enough?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

mchartre

#5
Jan 17, 2013, 02:29 am
I am unfamiliar with how i could get the time used by using the library

Mike

#6
Jan 17, 2013, 05:21 am
Add some start_time = millis() and end_time = milis() statements in your code, see how long it takes to get thru the code.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Magician

#7
Jan 17, 2013, 06:11 am
Something like this:
Code: [Select]
`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.
http://coolarduino.wordpress.com/2011/09/03/arduino-musical-note-recognition-pushing-the-limits/

mstanley

#8
Jan 18, 2013, 12:31 amLast Edit: Jan 18, 2013, 12:34 am by mstanley Reason: 1

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.

liudr

#9
Jan 18, 2013, 01:27 am
You should read up what debunce means. You can't debunce in a millisecond.

michinyon

#10
Jan 18, 2013, 03:51 am
How do you know only one button will be pushed at a time ?

#11
Jan 18, 2013, 04:00 am
Because that's the stated requirement
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

mstanley

#12
Jan 18, 2013, 04:19 am

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.

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.

liudr

#13
Jan 18, 2013, 05:15 am

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.

mchartre

#14
Jan 19, 2013, 01:15 am
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

Go Up

Please enter a valid email to subscribe