5 Replies Latest reply on Oct 6, 2020 3:25 AM by AlanH_86

    Interrupts PSoC Creator




      We have a problem with interrupts in PSoC Creator.
      We have a Rotary Encoder (ec12e), which gives to staggered pulses when we rotate it. To see if it rotates clockwise or anti-clockwise, we want to read one of the signals just after they are not both low anymore, see the picture.

      Skærmbillede 2020-10-02 141649.png

      Therefore we have put in an NOR gate, which gives a high when both signals go low. We want a interrupt on the falling edge of the signal from the NOR-gate.
      Unforturnately, we get three interrupts - which makes us think that the interrupt isn't on the falling edge, but is just random.


      Do you have any suggestions as to how we can get an interrupt on the falling edge?Skærmbillede 2020-10-02 142324_1.png


      Best regards Nikolaj

        • 1. Re: Interrupts PSoC Creator

          Hi Nikolaj,


          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. Re: Interrupts PSoC Creator

            Hi Nikolaj,


            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 !




            2 of 2 people found this helpful
            • 3. Re: Interrupts PSoC Creator


              There is a custom community component for interfacing this type of encoders

              Quad Decoder with Button Switch component for rotary shaft encoders



              • 4. Re: Interrupts PSoC Creator



                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.



                1 of 1 people found this helpful
                • 5. Re: Interrupts PSoC Creator

                  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.