How to use the timer to keep our LED on 80% to 10% (linear down) of the time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-16 1:50 AM
How to use the timer to keep our LED on 80% to 10% (linear down) of the time by setting a period of 500X, turning it on when the counter is 0 to 400X (0-15 minutes) and turning it off when it is 400X to 500X(5 minutes)?
The time and period is a draft idea.
- Labels:
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-16 2:07 AM
By reading the reference manual on timer output PWM mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-16 3:21 AM
I have some difficulty interpreting your question, so please tell me first if my understanging is correct.
- There should be a PWM signal with at least 60 Hz frequency to prevent visible flicker.
- The signal should start with 80% duty cycle, and gradually reach 10% duty cycle in 15 minutes. In how many steps?
- The perceived intensity of the light should change linearly (not the duty cycle, which is a big difference).
- After 15 minutes the light should be off for 5 minutes, then repeat from the beginning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-16 4:11 AM
Your eyes have a logarithmic response, so you'll need to use an exponential to make the change look linear. Could be a simple lookup table or maybe use the arm math linear interpolation function.​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-16 5:09 AM
Using a 2 kB table (1024 short values) is good for 16384 steps with some bit shifting. Works well even on the STM32F0.
