In the figure you show, you can simply use the rising edge of Signal A as an interrupt.
Since this Rotary Encoder determines the direction of rotation by setting either signal to HIGH after two signals are LOW?
Can you check what the waveform looks like depending on the direction of rotation of the rotary?
Probably, I think that it is better to interrupt by the rising edge of the two signals at OR, then monitor the status of either signal A or B.
2 of 2 people found this helpful
You can use TCPWM component in Quadrature decoder mode readily available in PSoC Creator.
For this you just have to connect the Signal A and Signal B to the Phi_A and Phi_B pins of the Quadrature decoder component.
Please use this already available code example for your purpose:
If you are using PSoC 4 here is the link for code example:
Hope this information helps !
1 of 1 people found this helpful
It appears from your original post that you are trying to avoid getting an interrupt when both inputs are LOW.
You've place a NOR gate (combinatorial logic) in front of the two quadrature signals to try to accomplish this.
Without seeing your circuit, this is my take on what is happening:
- Combinatorial NOR logic IS NOT clocked. This means that if one (or both inputs) change, the output of the NOR will reflect the new logic within about 10 to 20 nsec..
- I know what you're thinking. You only expect to have one input change at a time on rotational movement. In the case of a rotary quad encoder you are right BUT you are not considering switch debounce. Most quadrature encoders still use mechanical switches to toggle the A and the B outputs. Switches are notorious for mechanical 'bouncing' the outputs This means that for every switch A or B transition, you will see one or more switch transitions FROM THE SAME output! This is most likely where you are getting
we get three interrupts
There are ways to significantly address this.
- Place a debounce circuit after the A and B input with as low a clocking frequency you can tolerate. (For most applications a 100Hz should suffice.) This will significantly minimize the multiple switch transitions by synchronizing the output of the debounce circuit to filter out the unwanted extra transitiions. In this case you should be able to keep the NOR AFTER the debounce circuit.
Based on the PSoC part you have chosen, this option will not be possible DIRECTLY. This option requires a PSoC with UDB resources.
I've looked again at your first post. You are using a "Double-sync" for each input which is very good, however, the switch bouncing frequency will probably be much lower than the clocking frequency of the input (BUS_CLK) x2.
- I believe the Quadrature Decoder has a input debounce built in.
- Ignore the NOR gate and process each switch transition in SW. You can still put a debounce circuit in the signal front-end (adviced) or you can perform a SW debounce.
To verify the 'bouncing' of the inputs and the resultant NOR output transitions, I recommend using a 3-input scope. Monitor the A and B inputs and route the NOR output to a PSoC pin to see the results.
This is a good answer.... definitely use the quadrature decoder in the chip which was put there just for this application.
The multiple interrupts are caused by bounce.
For sure could use the glitch filter to debounce.
Could use software to debounce
Did Nilo use an external nor gate? That could be done in the UDB as well.
But the best answer is just use the quadrature decoder.