Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 11 of 11

Thread: analogWriteFrequency Min/Max range

  1. #1

    analogWriteFrequency Min/Max range

    What is the minimal and maximal frequency that can be specified in analogWriteFrequency ?

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    17,433
    maybe 37500000 ?

    See the section: PWM Resolution (Teensy LC, 3.0 - 3.6, 4.0, 4.1)

    It seems to be dividing from a 150 MHz clock. The next MIN step above Zero will depend on the chosen resolution.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    28,469
    Depends on which Teensy model you're using and what CPU speed (as set in the Tools > CPU Speed menu before uploading). On some boards, also may depend on the pin, as some pins use different timers with slightly different hardware capability.

    I believe code was added many years ago to support very low frequencies on Teensy 3.x by reconfiguring the timer clock source. Pretty sure that work has not (yet) been done for analogWriteFrequency() on Teensy 4.x, so the low limit is probably around 20 Hz.

  4. #4
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    8,758
    Thought I saw something a while ago about this. This may explain it: https://forum.pjrc.com/threads/70660...l=1#post309572

  5. #5
    I am trying to add support for it in Visuino. One of the features of Visuino is that it can either suggest or hard limit ranges for values.
    What do you think is a good range to use for the different boards? I can specify it per board if needed.

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    17,433
    The table indicated in p#2 is best guess here, PaulStoffregen would know if otherwise.

    The fastest expected for each device would seem to be that shown as ideal for the 2 bit resolution. Even that may not work for all higher bit resolutions? But seems it wouldn't work faster than that in any case.

    And on reading that table even for the individual Teensy - a change in clock speed from 'default' will as listed affect the resulting speed.

  7. #7
    The table seems to list the default frequency. I was looking for Min Max limits. Maybe I am missing something :-(

  8. #8
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    17,433
    Quote Originally Posted by mitov View Post
    The table seems to list the default frequency. I was looking for Min Max limits. Maybe I am missing something :-(
    Check the indicated "PWM Resolution" section that lists the "Ideal" - that is where the math works best for adjustment for various bits of resolution. From that it was assumed the MAX would be that shown as suggested for the lowest 2 bit resolution.

    The actual usable MIN as noted p#2 - will vary with the selected resolution for the device at hand given the math involved with the integer divider used to create the desired frequency.

  9. #9
    Well... I have added initial support and have limited it to the from 1.0 to 37500000.0 Hz range. Should be good for now.
    If anyone wants to try, here are Standard and Pro Beta versions:

    https://www.visuino.com/installs/Vis..._84_Beta47.zip
    https://www.visuino.com/installs/Vis..._84_Beta47.zip

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    28,469
    Is Visuino still Windows only?

  11. #11
    Quote Originally Posted by PaulStoffregen View Post
    Is Visuino still Windows only?
    Unfortunately yes :-( . Barely can keep up adding all the features in all the controllers, modules and shields... :-( . Bust I am still trying to get it on other platforms.

Posting Permissions

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