10 Replies Latest reply on Apr 15, 2017 12:16 PM by 1020ohio_1493671

    Quadrature Decoder not working

    1020ohio_1493671

      Using the PSoC4 Pioneer Kit and a 500 PPR encoder I am trying to get it to count up when I turn the encoder in one direction then count down hen turned it the other direction; but it is not working correctly.

         

      When I turn the encoder in what I believe to be the count-up direction (A leads B) it does count up.

         

      When I turn the encoder in the count-down direction (B leads A) it does NOT count down.

         

      It just toggle back-and-forth between two values.

         

      I capture the counts through Hyper Terminal and log them to a .txt file.

         

      My project and the text file are attached.

         

      I manually edited the .txt file to give indicators when I changed encoder direction.

         

       

         

      Thank you,

         

      Doug

        • 1. Re: Quadrature Decoder not working
          user_1377889

          The provided project does not match your count output. I cannot see where you print "DN ".

             

          Your components are outdated, consider updating to Creator 4.0 SP1 and updating tje components.

             

           

             

          Bob

          • 2. Re: Quadrature Decoder not working
            user_242978793

            What version of Psoc Creator are you using?  You need to update it to the latest revision. Here is an example with a PDF to check your Program  against as I don't have an encoder to check your program.

            • 3. Re: Quadrature Decoder not working
              1020ohio_1493671

              Thank you everyone for your replies.

                 

               

                 

                 

              I had HyperTerminal save the incoming counts to three .txt files.

                 

              1.) First I turned the encoder in the count-up direction and saved the counts to: counts01.txt and then closed that file

                 

              2.) Then I turned the encoder in the count-down direction and saved the counts to: counts02.txt and then closed that file.

                 

              3.) Last I turned the encoder in the count-up direction and saved the counts to: counts03.txt and then closed that file

                 

              4.) I combined the three files into one and changed the UP to DN at the right places and added the ---------------- between the UP and DN counts.

                 

               

                 

              I tried to up-date my components but it looks like I have all the latest versions.

                 

               

                 

              Any other help is appreciated.

                 

               

                 

              Thanks,

                 

              Doug

                 

               

                 

              This is my version of PSoC Creator:

                 

              • 4. Re: Quadrature Decoder not working
                user_1377889

                Actual version is Creator 4.0 SP1 and afaik there is a new version coming soon.

                   

                 

                   

                Bob

                • 5. Re: Quadrature Decoder not working
                  ken.sappio

                  Doug,

                     

                   

                     

                  I took a look at your project and I noticed that the "Encoding mode" under the "Quadrature Decoder" tab is set to 1x.  That is fine for a tack to read RPM but you are interested in counting up and counting down so the Encoding mode should be set to 2x.  That way the decoder can tell direction, up or down.

                     

                   

                     

                  Ken

                  • 6. Re: Quadrature Decoder not working
                    1020ohio_1493671

                    That worked Ken, thanks.  But when I look at the counts on Hyper Terminal or look at them in the text file there are missing counts.

                       

                    Example:

                       

                    33408
                    33409
                    33410
                    33412
                    33415
                    33416
                    33417
                    33419
                    33421
                    33424
                    33425
                    33426
                    33427
                    33429
                    33430
                    33432
                    33434
                    33435
                    33437
                    33438

                       

                    There are 20 numbers here, there should be 31.  The 11 listed below were missed.

                       

                    33411, 33413, 33414, 33418, 33420, 33422, 33423, 33428, 33431, 33433, 33436

                       

                    I upped the UART's and Hyper Terminal's baud rate from 9600 to 19200.  It seemed to of helped, but the numbers above were taken at 19200 so that didn't solve the problem.

                       

                    Also, I stopped logging the numbers to a text file in case that was slowing things down but that didn't help.

                       

                    I would think that others, maybe many others, have used the quadrature decoder component before with success and I am hoping they can give me some helpful input to my problem.

                       

                     

                       

                    Thanks again,

                       

                    Doug

                    • 7. Re: Quadrature Decoder not working
                      user_1377889

                      Can you please provide us with your actual project, so that we all can have a look at all of your settings. To do so, use
                      Creator->File->Create Workspace Bundle (minimal)
                      and attach the resulting file.

                         

                       

                         

                      Bob

                      • 8. Re: Quadrature Decoder not working
                        user_342122993
                                Looks like normal behavior when decoder polling rate is slow. The encoder has very fine pitch (500/turn), so it updates position faster than UART can output. To confirm, change baud rate to 57k or 115k.   
                        • 9. Re: Quadrature Decoder not working
                          ken.sappio

                          Doug,

                             

                           

                             

                          When you say the decoder is missing counts I don't think that is the case.  Looking at your numbers such as 33410 and 33412, you are thinking that the decoder is missing counts, but it can't count from 33410 to 33412 unless it has already counted 33411.  Just like you can't count from 1 to 10 by adding 1 to the previous number and not count all the numbers, you can't get to 5 from 3 by adding 1 unless you have already went from 3 to 4 first.

                             

                          I think you data logging/display part is too slow, the count is there, it has already come-and-gone by the time the UART sends it to Hyper Terminal and it gets displayed.

                             

                          I would try upping you BAUD rate, as odissey1 suggested.

                             

                          Other possible bottlehecks could be:

                             

                             1.) serial communication wiring from the PSoC board to your computer.

                             

                             2.) your computer running slow.

                             

                             3.) delay due to writing to the log file.

                             

                             4.) UART-to-USB Bridge if you are using the PSoC 4 Pioneer board.

                             

                           

                             

                          Ken

                          • 10. Re: Quadrature Decoder not working
                            1020ohio_1493671

                            Thank you Odissey1, thank you Ken.

                               

                             

                               

                            I upped the baud rate to 115200 and got the missing counts which proved Ken's theory correct.  The quadrature decoder was working as it should, I just couldn't see it because of the missing counts.  The missing counts from the too slow baud rate and not from the PSoC component.

                               

                            So thanks again.

                               

                             

                               

                            Doug