<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">I have substantial experience with the
      application but not in a musical context. My extensive trials and
      errors has convinced me of the following:</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">1. You'll need to know when inputs
      change state, not just when the signals go low. Consider rising
      and falling edge interrupts on both inputs. You can detect
      rotation direction using this strategy.<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">2. There WILL be bouncing so plan for
      it. Contact type switches will bounce more than optical switches.
      Contact type switches will degrade over time.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">3. Interrupts vs polling: Interrupts
      are great but they have a hidden hazard in that they can flood and
      overwhelm some MCUs (YMMV of course). A capacitor can help
      alleviate the problem but it's better to find a non-cap solution.
      I've found polling is better. I use a digital integration method
      (*) and a fast polling interval. That works so well, I
      automatically go to that design solution for most applications.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">* --- A digital integration method uses
      a counter that counts up and down and outputs a state change
      signal when a count threshold is reached. Increment the counter
      while the input is high and decrement the counter when the input
      is low. Reset the count when the output state changes. Adjust the
      polling interval for speed and accuracy. As a frame of reference,
      I use a 5 msec polling interval for keyboard debouncing. You'll
      probably want a faster interval if your encoder can be turned
      fast. I'll warn you that there can be a surprisingly large number
      of lines of code for such a simple task like digital debouncing.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">JJS<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 8/6/2021 8:46 AM, Jean-Pierre
      Desrochers wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:000601d78ada$49b21470$dd163d50$@oricom.ca">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 14 (filtered
        medium)">
      <style>@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Texte brut Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}span.TextebrutCar
        {mso-style-name:"Texte brut Car";
        mso-style-priority:99;
        mso-style-link:"Texte brut";
        font-family:"Calibri","sans-serif";}.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}div.WordSection1
        {page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoPlainText">Hi everybody.<o:p></o:p></p>
        <p class="MsoPlainText"><o:p> </o:p></p>
        <p class="MsoPlainText"><span lang="EN-CA">I’m doing some tests
            on a rotary encoder and a PIC16F1783.<o:p></o:p></span></p>
        <p class="MsoPlainText"><span lang="EN-CA">A standard Bourns
            encoder like <a
href="https://www.google.ca/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwjyoqDF3JzyAhUmhOAKHf3lAzoQFnoECAoQAw&url=https%3A%2F%2Fwww.bourns.com%2FPDFs%2Fpec11l.pdf&usg=AOvVaw2RyieyzPnujiOTS7LBcbpw"
              moz-do-not-send="true">THIS</a> .<o:p></o:p></span></p>
        <p class="MsoPlainText"><span lang="EN-CA">Connected using 2 x
            10k pullups with 0.01uf caps to ground<o:p></o:p></span></p>
        <p class="MsoPlainText"><span lang="EN-CA">to PORTB of the
            micro. Interrupt calls (falling edges) used on encoder pins
            A & B.<o:p></o:p></span></p>
        <p class="MsoPlainText"><span lang="EN-CA">I struggled so far to
            get clean increments/decrements out of it.<o:p></o:p></span></p>
        <p class="MsoPlainText"><span lang="EN-CA">Many missing counts
            occur..<o:p></o:p></span></p>
        <p class="MsoPlainText"><span lang="EN-CA">I tried many source
            codes on the web with no luck..<o:p></o:p></span></p>
        <p class="MsoPlainText"><span lang="EN-CA">Is there anybody
            who’d have worked on this in the past<br>
            and have a working c code ?<o:p></o:p></span></p>
        <p class="MsoPlainText"><span lang="EN-CA">No ARDIUNO please.<o:p></o:p></span></p>
        <p class="MsoPlainText"><span lang="EN-CA">Thanks !<o:p></o:p></span></p>
      </div>
      <br>
    </blockquote>
  </body>
</html>