High-speed, up/down counter

Hello Everybody,

I want to create high-speed up/down counters (1,2 or 3 counters) on Arduino boards (ATmega processor).

The counters will count input "Clock" in such a way that the counter increment or decrement based on the the value of "Up/Down" signal.

Can you advise me how to configure counters in ATmega processor to realise high-speed up/down counting?

Is it possible (how) to change ATmega counter's mode to increment or decrement mode based on an external signal?

Following figure illustrates my intention

Thx

Albert Goodwill
albertgoodwill at gmail dot com

Dear Richard,

Thank you for your posting.

  • Max rotational speed of the motors is around 1000 RPM.
  • Encoders produce 1024 pulses per rotation. - Therefore 1024000 pulse per minute and 1024000/60sec= 17066.6667 pulses per second (i.e. 17kHz).
  • Which means I would like to be able to count up or down 17kHz "Clock" pulses depending on the "Up/Down" signal. ([100+] Hard Drive Wallpapers | Wallpapers.com)

Albert

40 megahertz frequency counter with atmega8
http://www.avr-asm-tutorial.net/avr_en/fcount/fcount_m8.html

The atmega 168 is even better.

http://www.ikalogic.com/freq_meter_2.php

It can do it, there is a library for rotary encoders. You can funge that to just do counting. You are looking for a decoder function for rotary encoders. I assume it's incremental A follows B.
http://www.arduino.cc/playground/Main/RotaryEncoders

Or pulse counting.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1227229020
http://note19.com/2008/12/28/circuit-gear-arduino-and-counting-pulses/

Hell a 6502 (C64) is less powerful than an Atmega168 in many ways and it will handle this easily.

Well the Arduino mega does allow for five user interrupt pins I believe, so three of them could service the channel A of each of the three encoders. There would need to be 3 input pins assigned for the three channel B signals from the encoder. From there each of the three ISR functions could maintain an up/down counter just as shown in some of the encoder libraries.

So the question is, are three asynchronous 17khz interrupts too fast to prevent missing steps? The ISR needs to be written 'lean and mean', but my gut says I think it can be handled. Keep in mind that the ISR triggers have the option on when the interrupt is generated, change, low, etc. So perhaps some playing with the trigger type can help prevent missing steps for a tradeoff of a small amount of timing skew.

Lefty