PWM function to control 12v LEDs

hamtt

Active member
Unless the variable dimming is required, could you not just run from the unswitched 12V through a resistor (chosen by experiment but starting with 800 ohms to halve the current) in place of the line from the picaxe? When the switch is depressed and both feeds are active, you're still limited by the 800 ohms built into the switch. When not depressed, the current is limited by the 800 plus the resistance of the additional in-line resistor.
Unfortunately I do require the variable dimming. The amount of dimming is very subjective from driver to driver and in the past some have complained they're not bright enough and others saying its too bright when we've used fixed resistors.
 

hamtt

Active member
quick question, what protection do I need between a 12v signal from the switch and the picaxe input pin to detect activation of switch (resistors etc)?
 

lbenson

Senior Member
The 22K resistor in the download circuit is designed to protect against possible RS232 levels, so good to +15V or so. The 10K to 0V would assure that it doesn't float when disconnected. Make sure the 2 Rs aren't wired as a voltage divider.

Re "not bright enough", the 12V pwm would allow greater brightness than the 5V pwm--max of around 12mA rather than 3-4mA, depending on Voltage Forward.
 
Last edited:

AllyCat

Senior Member
Hi,
..what protection do I need between a 12v signal from the switch and the picaxe input pin to detect activation of switch ...?
Yes, about 22k in series is about right, it will limit the current to less than 1 mA when the internal "electrostatic protection" diode(s) on the pin "catches" the voltage to the supply rail (or to between the supply rails). However, there are a few "gotchas":

Firstly, the "Input only" pin (usually Leg 4 on M2s) does NOT have a catching diode, so you must be add an external diode if using that pin with a higher voltage input.

Secondly, current flowing into the protection diodes can "phantom power" the PICaxe (which itself only drains about 0.5 mA). Normally, a "series" regulator can only feed voltage into the PICaxe rail (i.e. up to the required 5 volts), it cannot shunt away any additional current coming into the supply rail from elsewhere. So if several inputs might be activated (high) at the same time, then you may need to add some additional drain to the supply rail. A shunt "zener diode" is often recommended but IMHO is nearly always a poor (and probably unsatisfactory) choice. A simpler solution (as implied by lbenson) would be to add a 10k resistor from each input to ground, forming a potential divider (10 / 32), much in the way the programming input is NOT supposed to be connected ! :)

Cheers, Alan.
 

Hemi345

Senior Member
You can use optocouplers on the switch detection to reduce any chance of voltage spikes hitting the PICAXE pins. Some optocoupler ICs have multiple channels which would reduce parts counts especially when paired with an isolated resistor network/array for current limiting on the LEDs in the optocoupler and utilizing the pullup resistors in the PICAXE.
 

hamtt

Active member
I've ordered a load of components including optocouplers to play about with to see wat works best.
 
Top