Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

PWM to drive over 16 channels #1

Closed
LaurentR59 opened this issue Aug 25, 2022 · 7 comments
Closed

PWM to drive over 16 channels #1

LaurentR59 opened this issue Aug 25, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@LaurentR59
Copy link

Is your feature request related to a problem? Please describe.

if the need is over driving 16 channels, it means we must to use another object for 16 additionnal channels if I m not wrong?
juste to be sure how to process on that case.

So what happen if non other hardware TIMER still available?? (usually One is for millis(), one will be for ISR_Timer interupt generating this PWM, another one can be keep for core operations (in my case NMRA DCC signal management).... so few solution available!
Worst case on megatiny CPU with less TIMER ( A0 B0 B1 only)

Describe the solution you'd like

May it would be possible to limit frequency ( ex between 50hz-120hz range and add PWM channels on the 16 ones on the initial range as a way? (may be not at all!)

Describe alternatives you've considered

using biggest hardware on the family to have enough TCB Timer ressources is the intial possibility if available!

other is to get capacity or possibility to move millis() on a TIMER A type? (not sure it would be well managed by dx core or megacorex and megatinycore?)
May require some additionnal settings according optional links between TIMER A type and B type.

using millis on same timer as the one managing PWM? (stupid way? uncompatible?)

Additional context

optimisation of selected hardware according usages needs specially for limited TIMER numbers.

@khoih-prog
Copy link
Owner

Hi @LaurentR59

The current 16-channel limitation is artificial and arbitrary decided to avoid overloading the board. I'll create a new version for this feature.

Anyway, I'll make it configurable in users' code, and will be max 48. But I think for slow PWM (low PWM frequency), the max number of channels can be very large.

Is that value 48 reasonably large enough ?

You can also use many Timers, if available, by adding the Timers and similar code for 1 Timer.

other is to get capacity or possibility to move millis() on a TIMER A type? (not sure it would be well managed by dx core or megacorex and megatinycore?)

With DxCore, you can move millis() to other Timers, such as TCA, TCD

@khoih-prog khoih-prog added the enhancement New feature or request label Aug 25, 2022
@LaurentR59
Copy link
Author

LaurentR59 commented Aug 25, 2022 via email

@khoih-prog
Copy link
Owner

OK, hear you, I'll set max number of channels to 64 and configurable in your code.

Will modify those slow PWM-related libraries similar way. The next release will be out within today.

Please test then, with max 64 channels, if possible.

@khoih-prog
Copy link
Owner

Hi @LaurentR59

The new Dx_Slow_PWM releases v1.0.1 has just been published. Your contribution is noted in Contributions and Thanks

Looking forward to receiving more contributions from you.

Best Regards,


Release v1.0.1

  1. Make MAX_NUMBER_CHANNELS configurable to max 64 PWM channels
  2. Remove debug codes possibly causing hang
  3. Improve debug to use Serialx port automatically according to boards

@LaurentR59
Copy link
Author

LaurentR59 commented Aug 25, 2022 via email

@khoih-prog
Copy link
Owner

You now just declare in your code (any number up to 64). Will be trimmed to 64 if bigger than 64.

// Be careful when using MAX_NUMBER_CHANNELS > 16. Max pemissible MAX_NUMBER_CHANNELS is 64
#define MAX_NUMBER_CHANNELS 16

@LaurentR59
Copy link
Author

LaurentR59 commented Oct 11, 2022 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants