Git Product home page Git Product logo

khoih-prog / teensy_slow_pwm Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 114 KB

This library enables you to use ISR-based PWM channels on Teensy boards, such as Teensy 2.x, Teensy LC, Teensy 3.x, Teensy 4.x, Teensy MicroMod, etc., to create and output PWM any GPIO pin. It now supports 16 ISR-based PWM channels, while consuming only 1 Hardware Timer. PWM channel interval can be very long (ulong microsecs / millisecs). The most important feature is they're ISR-based PWM channels, supporting lower PWM frequencies with suitable accuracy. Their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks. These ISR-based PWMs, still work even if other software functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software-based PWM using millis() or micros(). That's necessary if you need to control devices requiring high precision

License: MIT License

C++ 77.57% C 22.24% Shell 0.19%
isr pwm pwm-driver duty-cycle timer-interrupt hardware-timer isr-based isr-based-pmw multi-channel-pwm synchronized-pwm

teensy_slow_pwm's Issues

Unable to set duty cycle to zero

Describe the bug

I need to set and modify 16 PWM channels in order to create 16 PID controllers for heaters. The frequency is 5 Hz and I need to set the duty cycle in 1 ms steps, 0 to 200 ms.

If I set the duty cycle to 0%, I get a pulse 1 ms long every 200 ms (which is wrong as there should be no pulse at all). For the duty cycle = 1%, I get a pulse 3 ms (again wrong, it should be 2 ms), 2% -- 5 ms, …. 99% -- 199 ms, 100% -- 200 ms

Steps to Reproduce

https://github.com/snagaitsev/PWM_slow/blob/main/slow-pwm-test.ino

Expected behavior

There should not be any pulse at 0% duty cycle.

Actual behavior

At 5 Hz (same behavior happens at other frequencies like 50 Hz):
For the duty cycle of 0%, I get a pulse 1 ms long every 200 ms (which is wrong as there should be no pulse at all). For the duty cycle = 1%, I get a pulse 3 ms (again wrong, it should be 2 ms), 2% -- 5 ms, …. 99% -- 199 ms, 100% -- 200 ms

Debug and AT-command log (if applicable)

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Information

Please ensure to specify the following:

Arduino 1.18.19
Teensyduino 1.56
Teensy slow PWM library 1.2.1
Teensy 4.0, 600 MHz
OS: Mint 20

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.