4 Replies Latest reply on Mar 26, 2019 3:38 AM by AH_96

    quadrature decoder - interrupt on compare value

    baye_4029466

      Hi,

      I'm using PSOC4 on my project.

      I have a DC motor connected to a PWM (through H bridge) and the motor axle is connected to encoder that is counting the motor steps.

      I want to stop a motor on exact place using the quadrature decoder peripheral.

      I tried to configure the encoder to set an interrupt on specific value (not 0x0 or 0xFFFF) using the TCPWM_CNT1_CC register, but I don't get the desired interrupt.

      Is it possible to get such an interrupt on quadrature decoder mode?

       

      Thanks,

      Barak.

        • 1. Re: quadrature decoder - interrupt on compare value
          AH_96

          Hi

           

          The quadrature decoder component of PSoC 4 does not support triggering interrupt at a value other than 0x0000 or 0xFFFF.

          Please let us know the use case of such a requirement so that we can provide an alternative.

           

          Thanks and regards

          Harigovind

          • 2. Re: quadrature decoder - interrupt on compare value
            AH_96

            Hi

             

            Could you provide the use case of why an interrupt is required at values other than 0x0000 or 0xFFFF so that we can provide an alternative solution?

             

            Thanks and regards

            Hari

            • 3. Re: quadrature decoder - interrupt on compare value
              baye_4029466

              Hi,

               

              I want to run a motor and by setting an interrupt on the quadrature decoder, stop the motor very accurately on a specific place.

              because the decoder reload value is 0x8000, I wanted to set an interrupt when it gets to 0x8100 for example and then stop the motor, then measure the motor drift ~50mSec after it stops (the current decoder value - 0x8100).

               

              The only solution I think of is to set the counter value to the specific value and stop the motor on the decoder interrupt (when it gets to 0 or 0xFFFF).

              the only problem is that after the decoder gets to 0 or 0xFFFF it reload with 0x8000 so the motor drift measurement may be not accurate (the decoder can lost few pulses while it reloads the 0x8000 value).

               

              what do you think?

               

              thanks,

              Barak.

              • 4. Re: quadrature decoder - interrupt on compare value
                AH_96

                Hi

                This method would work, That is setting the initial counter value to something other than 0x8000 to obtain interrupt at desired value.

                If the program is simple, you can also try polling method by continuously monitoring the counter value. However, this will work only for programs without any heavy processing.

                 

                Thanks and regards

                Harigovind