Well, hello again. I'm using an atmega 328p to read pulses from an encoder and an opto - sensor.
I discovered that the application I'm using it in requires the board to register about 10k pulses a second via the interrupt pins. It successfully recorded much higher pulses in under a second.
Now the main issue. Even the opto sensor needs to registered via the interrupt. So 2 pins for the encoder (i.e A channel and B), 1 pin for the opto sensor. As per my knowledge every small jog of an encoder (I'm using a 500 PPR industrial encoder) should record a few pulses. Is it required to use both A and B channels ?.
If not, using only either A or B channel, would there be a severe loss of accuracy ? or the pulses won't get registered at all.
The main reason why I ask, is because I'd like to keep the board as simple as possible with a 328p .
Rotary encoder?
You could use an intermediate chip - LS7184.
This interfaces to the pins of the rotary encoder, and feeds a clock output and direction output to the microcontroller.
You feed the clock into an external interrupt or into a PCINT pin, and read the direction via direct port manipulation and act on those accordingly.
What I mean is, basically an encoder sends a pulse or more when a glass disc with lines cuts across a opto interruptor.... I don't want position of the encoder, only count each slice of the glass disc. Each cut interrupts the MCU with say " x = x + 1" .
Thats it. Is it possible with only the encoder, or is it easier with the LS7183 ?
If your optical encoder has A-B output then it's designed so you can determine direction of rotation but if your not interested in the direction then you can just use A or B to determine rotation when it rotates.
Another option might be to just connect just A to an interrupt pin, freeing the other interrupt for opto use. Then using interrupt change events with B connected to another pin (preferably on the same port) when the interrupt fires check what high/low state both A & B are in to determine encoder direction and count pulses.
Well, I got what you said, but again I ask..
I'm least bothered about the direction, I just need to know when it turns, when it moves a notch, forward or reverse, it should pulse. This should happen on any pin of the encoder?
As you can see, the encoder pulses coming from channel A and B are square waves. My question is whether the squares on channel A are enough to trigger an interrupt
vikramnayak:
Well, I got what you said, but again I ask..
I'm least bothered about the direction, I just need to know when it turns, when it moves a notch, forward or reverse, it should pulse. This should happen on any pin of the encoder?
And again I say...
If your optical encoder has A-B output then it's designed so you can determine direction of rotation but if your not interested in the direction then you can just use A or B to determine rotation when it rotates.
vikramnayak:
As you can see, the encoder pulses coming from channel A and B are square waves. My question is whether the squares on channel A are enough to trigger an interrupt
Yes they will be assuming they are within the range the ATmega chip is expecting for HIGH/LOW signals.