27 light PWM control

Hello guys,

I'm working on a light controller, i use mosfets to control 27 * 12V led light modules.
As i'm working with 27 light modules, i had to use a mega controller.
I want to pwm all those lights ( max 14 at the same time since they will blink in different groups ).
Since there ar not enough PWM pins on the arduino, i need to use a softpwm library.
i found this one : GitHub - bhagman/SoftPWM: A Wiring (and Arduino) Library to produce PWM signals on arbitrary pins.
but it's says max 20 pwm channels are available.
Does somebody has a solution/other library to work with my 27 outputs?
I wan't to adapt my blinking lights to the surrounding light ( Read ldr value->dutcy cycle)
I hope for a good response, thank you guys!

How about two of these tlc5940 modules?

That means you can just use an Uno/Nano/Pro Mini and keep your Mega for another project.

Will you also need 27 ldr and 27 analog inputs? If so you could use 2 of these analog multiplexers.

As normal, you can buy "clone" versions of the above for 1/3 of the price from China on eBay.

Another option could be to make a separate controller for each light module, or pair of modules. You could use ATTiny85, which has PWM outputs and analog inputs.

PaulRB:
How about two of these tlc5940 modules?

That means you can just use an Uno/Nano/Pro Mini and keep your Mega for another project.

Will you also need 27 ldr and 27 analog inputs? If so you could use 2 of these analog multiplexers.

As normal, you can buy "clone" versions of the above for 1/3 of the price from China on eBay.

Another option could be to make a separate controller for each light module, or pair of modules. You could use ATTiny85, which has PWM outputs and analog inputs.

The problem big problem is:
I already ordered a prototype PCB to work with my project.
So i can't do any other things with the hardware than what i have made right now.
What you suggest seems interesting, i will have a look at it.
So i'm still looking for a code solution to fix this problem.

I already ordered a prototype PCB to work with my project.
So i can't do any other things with the hardware than what i have made right now.

Then it's not a prototype, is it? If you look up the meaning of the word "prototype" you will understand what I mean.

The best advice I can give you is:

  1. Research, seek advice, explore options
  2. Spend money

(It does not work so well the other way around.)

I already ordered a prototype PCB to work with my project.

You can change a PCB with track cuts and mod wires.

Thank you guys for your input.
I was asking for advice on software PWM programming, so could somebody please give me some advice on how to do this for 27 channels only with software.
I ordered a pcb because i don't want to wire 27 mosfets and go with this out in the field to test my project.
This doesn't mean i'm not willing to do research and try things i guess?
If somebody could help me further with this issue i would like to hear it.
Thank you all

Can you post a picture or link to this MOSFET board?

The author of that library says maximum of 20 pwm channels, but does not seem to explain why that limit was chosen. The author estimates 20~30% CPU usage, so that does not appear to be the limiting factor. Perhaps it was an arbitrary choice.

So I think it would be worthwhile experimenting with a larger number.

In SoftPWM.h is the following line:

#define SOFTPWM_MAXCHANNELS 20

So try changing this to 27.

Then you could try the SoftPWM_LEDHead_Bounce example sketch and modify the following line:

uint8_t leds[8] = {22, 23, 26, 27, 28, 29, 30, 31};

Change the 8 to 27 and list your 27 pin numbers between the curly braces.

PaulRB:
Can you post a picture or link to this MOSFET board?

The author of that library says maximum of 20 pwm channels, but does not seem to explain why that limit was chosen. The author estimates 20~30% CPU usage, so that does not appear to be the limiting factor. Perhaps it was an arbitrary choice.

Thank you for your input.
I have a good connection with a local PCB manufacturer, he is making the PCB now.
It's my own design specific for my application( warning sign trailer for highways ).
I'll give an update/photo once i have the PCB
I have no other difficult tasks to do with the chip, so i guess the chip will handle this. let's hope so :wink:

You can start testing the changes before your PCB is ready. You will need a breadboard, 27 resistors and 27 ordinary 3mm/5mm leds and lots of jumper wires.