There is some device controlled by (optical) rotary incremental encoder (which gives quadrature output - two channels with square shaped pulses and shifted between each other). I want to add another encoder, which will work in "parallel" with first one - thus will be possible to control device with any of them. So I need to combine two rotary encoders to one quadrature output. How I am gonna do that?
What you're going to have to do is decode both of them into step and direction bits, combine those, and then regenerate the quadrature outputs.
The first part can be done with a couple of flip flops and a couple of xor gates. See http://www.fpga4fun.com/QuadratureDecoder.html . Then you OR the step bits together and use a mux to select which direction bit to use. Finally, use a simple state machine to generate a quadrature output from the step and direction signals.
Combining two rotary quadrature devices isn't possible - "joining" the outputs together with a mixer or logic is going to produce nonsense for a signal. If you want to use device A rather than device B (or device B rather than device A) then use a multiplexer and have a logic signal that decides which device is to be selected.
Yes it IS possible and works perfect as long as one encoder is being read at a time.I do this all the time with my tool changer and I have 5 incremental encoders wired to the one input on my controller card. As the spindle enters the rack, it rotates the encoder nearest to the tool it is selecting.
It is possible to combine two rotary encoder inputs if they will never move simultaneously. Conceptually, it's not even terribly difficult: pass one rotary encoder signal through a couple of inverters so its signals are available in true and complement form. Feed the other into the select inputs of a 2x4 multiplexer (e.g. a 74HC153), and drive its data inputs with various combinations of true and complement signals from the first:
* If second is 00, mux outputs should be A0 and A1 * If second is 01, mux outputs should be !A1 and A0 * If second is 11, mux outputs should be !A0 and !A1 * If second is 10, mux outputs should be A1 and !A0
Unfortunately, if one attempts this approach using just a 74HC153 and a couple of inverters, performance may be poor because a single-bit change on the second encoder input may cause both multiplexer outputs to glitch briefly before settling on the correct value. This problem may be solved by adding a 6-input flop which is clocked faster than the encoders are going to change. Two of the flop inputs should latch each encoder, and two should latch the multiplexer output.