Forum Rule: Always post complete source code & details to reproduce any issue!
Page 4 of 4 FirstFirst ... 2 3 4
Results 76 to 84 of 84

Thread: Hardware Quadrature Code for Teensy 3.x

  1. #76
    Junior Member
    Join Date
    Apr 2018
    Posts
    2
    I have had a look at the code by TLB, and I am quite puzzled by the fact that the addresses of the registers that are set up do not match the addresses as specified in the memory map from the K20 reference manual.

    All the adresses seem to be off by 0x1000 compared to the datasheet (or kinetis.h for that matter...).

    What am I missing here?
    Last edited by polwel; 04-10-2018 at 09:37 PM. Reason: typos

  2. #77
    Junior Member
    Join Date
    Apr 2018
    Posts
    2
    OK, nevermind, I had been looking at FTM0 in the reference instead of FTM1... D'oh.


  3. #78
    I'm new to the Arduino IDE.
    What is the best way to install the five files by tlb for use in the IDE?

  4. #79
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,180
    The programs attached are:

    QuadDecode.h, QuadDecode_def.h - the important ones. Code to utilize the hardware quadrature decode channels on Teensy3.x

    main.cpp - an example of use. As I mentioned, it is templated, and I did not Arduinofy it, so this shows how to use the templates.

    GenEncoder.h, GenEncoder.cpp - program that generates simulated encoder signals for debug and development.


    That means that you do not forcibly have to include all 5 files.

    As tlb wrote, he did not "Arduinofy" it. That means that you can use the example file main.cpp as inspiration and documentation to create your own .ino sketch based on that. You'd have to copy QuadDecode.h and QuadDecode_def.h in your sketch folder and using #include tags to use their functions in the .ino file.

  5. #80
    Theremingenieur,
    Thanks, got it.

  6. #81
    Junior Member
    Join Date
    Sep 2018
    Posts
    2
    I feel like this is a silly question but I don't see a way to download tlb's attached files... Where can I find them?

  7. #82
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,180
    In the very first post of this thread. Depending on your browser and OS, these files are either opened or downloaded when you click on them. In case they open, just copy/paste the content in new tabs with identical names in the Arduino IDE

  8. #83
    Junior Member
    Join Date
    Sep 2018
    Posts
    2
    Ahhh, for some reason on my laptop the list of files wasn't showing but I see them now.

  9. #84
    Junior Member
    Join Date
    Sep 2017
    Posts
    9
    Quote Originally Posted by BrianC View Post
    Hi TLB,

    For 4x count mode, 4 counts are made per pulse (low, rising, high, falling)
    For 2x count mode, 2 counts are made per pulse (low, high)
    For 1x count mdoe, 1 count is made per pulse (just the high I believe).

    The encoder library is in 4x count mode https://www.pjrc.com/teensy/td_libs_Encoder.html
    Is there any way to set 2x or 1x mode when using the Encoder library?

    Id like to reduce the amount of times the interrupts are triggered and would be okay with resolution being lowered.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •