J
Jamie Morken
- Jan 1, 1970
- 0
Hi,
I am using this quadrature encoder:
"http://www.usdigital.com/products/e4p/"
with 300 cycles per revolution / 1200 pulses per revolution.
I have it hooked up to an AVR microcontroller (atmega168) using two
external interrupt pins for the A and B channel (there is no
index channel). This is working and I have a variable that
keeps track of the encoder pulses and uses a 4state machine
to check the rotation direction, so the variable goes + for
forward rotation and - for reverse rotation.
I am now trying to get an averaged rotation rate for the last 1ms, 10ms,
100ms, 1s and 10s. I have an interrupt that runs every 1ms for this
but the code only updates the rotation rate variables once per period,
ie. once per second for the 1s variable, instead of giving a
continuously updated value from the last second.
Any ideas on how to fix this? I was thinking about using a digital
lowpass filter:
(http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html)
for each rotation rate variable but am not sure if that is the best way
to do it.
cheers,
Jamie
I am using this quadrature encoder:
"http://www.usdigital.com/products/e4p/"
with 300 cycles per revolution / 1200 pulses per revolution.
I have it hooked up to an AVR microcontroller (atmega168) using two
external interrupt pins for the A and B channel (there is no
index channel). This is working and I have a variable that
keeps track of the encoder pulses and uses a 4state machine
to check the rotation direction, so the variable goes + for
forward rotation and - for reverse rotation.
I am now trying to get an averaged rotation rate for the last 1ms, 10ms,
100ms, 1s and 10s. I have an interrupt that runs every 1ms for this
but the code only updates the rotation rate variables once per period,
ie. once per second for the 1s variable, instead of giving a
continuously updated value from the last second.
Any ideas on how to fix this? I was thinking about using a digital
lowpass filter:
(http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html)
for each rotation rate variable but am not sure if that is the best way
to do it.
cheers,
Jamie