PWM function to control 12v LEDs

hamtt

Active member
Hi all,

Just stumled across Picaxed and bought a starter kit that I have been playing about with. My background in electronics is only really what I learnt in GCSE physics however i work in IT hardware (managing staff who servicing laptop motherboards) so am familiar with common concepts but weak on the application side. I am fine on the programming side having programmed in 68K assembly many moons ago, Turbo C++ and many versions of Basics, again many moons ago but it all comes flooding back, so please bear with me if some of my questions sound stupid or obvious.

Ok now on to my requirements.

Basically I am trying to use the picaxe to control the logic of the buttons on the dashboard of a kit car. The buttons are illuminated and I want them to be dimmed in unpressed state and full brightnes in pressed state. To acheive this I want to use the PWM function of the Picaxe to supply the voltage for the dimmed state. However the LED's are 12V and the picaxe is 5v.

How would I go about making the PWM work on a 12v line? My idea is to have a single 12v feed that connects about 8 switches with LED's in parallel off this PWM-OUT from Picaxe. I've stumbled across similar applications using transistors or mosfets etc but not sure exactly which components are the correct ones or what the configuration is, and what protection if any needs to be applied to the Picaxe pin side. Any help would be appreciated.
 
Last edited:

hamtt

Active member
And would an LM2940T-5.0/NOPB regulator (along with the relevant capacitors) be good enough to power the Picaxe from the dirty 12v supply from the car battery or would I require a buck converter.
 

premelec

Senior Member
Please be more specific about the current to individual LED and total current expected when all LEDs on...

Just the PICAXE will not require much current so linear regulator can be used to drop the 12 to 5 volts with little concern for power loss in the regulator... should be clean enough with capacitors...
 

Hemi345

Senior Member
I would use either solid state relays or optocouplers (to drive the MOSFET gate) to PWM the 12V LEDs. Probably wouldn't be a bad idea to use optocouplers for the switches as well to decouple the PICAXE from any nasty transients.

I've used the VO14642AT SSRs and VOM617A Optos successfully with the PICAXE.
 

lbenson

Senior Member
I ask from ignorance here: is the ULN2803 inappropriate for PWMing these 12V LEDs (depending on current, of course)? At, say 1kHz with varying duty cycle?
 
Last edited:

mortifyu

New Member
The question of MAX current drawn by the LED's is a necessary factor in order to determine an appropriately capable MOSFET to use.

Whatever MOSFET you use, be sure the GATE-SOURCE voltage is +/- 20V. This will allow you to swing the GATE fully to GND or 12V without damage.

Something like this would do the trick...

PWM LED.png

The values of R4-R8 would depend on the LED's. The calculation for the LED current limit resistors is:

SUPPLY VOLTS - LED Forward VOLTS / LED CURRENT.

If for example your LED's were 2.8V/30mA...

12V - 2.8V / .03A = RESISTOR VALUE in OHMS.




Hope this helps.

Regards,
Mort.
 

cpedw

Senior Member
I have had satisfactory performance driving LEDs at variable brightness using just a MOSFET (2N7000 at up to 200mA) with 330 ohm from Picaxe output to MOSFET gate and 10k ohm gate to source. For your application, I think you need a MOSFET and 2 Rs for each switch.
If you're using 12V LEDs then you don't need the Rs 4-8 in Mort's circuit either.
 

lbenson

Senior Member
I ask from ignorance here: is the ULN2803 inappropriate for PWMing these 12V LEDs (depending on current, of course)? At, say 1kHz with varying duty cycle?
Well, to answer my own question, +IF+ the current is low enough, yes, you can PWM 12V LEDs with PICAXE and ULN2803 without excessive heat. I used these LEDs. They have 420R resistors, so 12/420=28mA--too much for a picaxe pin, but fine for the ULN2803. Lamps for dashboard might well be much higher--you'd have to check. Here's the 20M2 program I used to test--with slight modification for the different PWM pins, it would also work on a 14M2:
Code:
' 20pwm12v
' 20M2 pwm on C.5, C.3, C.2, B.1
' 14M2 pwm on C.2, C.0, B.2, B.4
#PICAXE 20M2
#terminal 4800

#no_data
'#no_table

symbol wDutyCycle=s_w1 ' system variable
symbol wRandNo=s_w2 '

symbol loopCnt=b4
symbol pinNo=b5

pause 1000
sertxd("20pwm12v",cr,lf)

for loopCnt=0 to 3: lookup loopCnt,(B.1,C.5,C.3,C.2),pinNo: pwmout pwmdiv4, pinNo, 249, 0: next loopCnt ' off
pause 1000
for loopCnt=0 to 3: lookup loopCnt,(B.1,C.5,C.3,C.2),pinNo: pwmout pwmdiv4, pinNo, 249, 999: next loopCnt ' max
pause 1000
for loopCnt=0 to 3: lookup loopCnt,(B.1,C.5,C.3,C.2),pinNo: pwmout pwmdiv4, pinNo, 249, 0: next loopCnt ' off
pause 1000
wRandNo=48611 ' largish prime number

main:
  do
    for loopCnt=0 to 3
      lookup loopCnt,(B.1,C.5,C.3,C.2),pinNo ' 20M2
'      lookup loopCnt,(C.2, C.0, B.2, B.4),pinNo ' 14M2
      random wRandNo
      wDutyCycle = wRandNo // 1000
      pwmout pwmdiv4, pinNo, 249, wDutyCycle
    next loopCnt
    pause 3000
    sertxd("* ")
  loop
So the big question relating to all the suggested solutions is, "how much current is drawn by your lamps?".
 

mortifyu

New Member
Keep in mind, technically there is no such thing as a 12V Light Emitting Diode.

There may be packages available that have perhaps 6x 2.0v LED's in series making it a 12v LED. However in this example, the moment an applied voltage goes above 12V, the junctions will be over driven and will be damaged. Even with "12V LED's" I would still ensure use of current limit resistors for a bit of 'electrical suspension' if you'd like to call it that.

I have also seen packages with a single LED junction and inbuilt series resistor such as 10mm wedge packages I have seen that are made for automotive use.


Reference to Ibenson's comments in POST #5 and #8, you did answer your question correctly. This is where MOSFET's are a great product to use with PIACAXE circuits over BJT's. A field effect transistor (FET) is a voltage dependent device requiring mere uA's to switch the GATE. A BJT is a current dependent device requiring BASE current. Employing the use of an opto-coupler such as the VOM617A, ensures the PICAXE remains safe even if the FET was damaged.

NOTE: Be sure to "ALWAYS!" put a suitable fuse in the supply line. If a everyday car battery was to be the source of the 12V, it can deliver enough current to make a spanner glow red, hence without a fuse any circuit could be a fire hazard.


Regards,
Mort.
 

hamtt

Active member
Hi all,

Apologies for the delayed reply but I thought I'd get as much info together as I could before posting.

So here it is.

This is the combined swith type I am using.

23393

It has 3 pins at the back (gold) for the switching operation (C, NO and NC) and 2 on side (silver) for the LED. I am using all momentary switches even though the picaxe will be programmed to mimick latching operations at times.

The LED itself can work fine at full brightness on 5v. I have tested on a benchtop power supply. But can support all the way up to 24v. I am told it has an 800 ohm resistor built in to the switch for the LED operation. I am not sure what the current draw is, I will have to measure it.

The arrangement of the switches on the panel will be like this:
23394

Altogether 8 switches will be used. Two for the indicator/flasher functions and 6 for various other simpler functions. The two indicator buttons need to operate the dimming slightly differently.

This is the simple shematic I have drawn up for the wiring.

23396

The signal wires that the switches operate are +ve hence having to pwm the +ve and not the ground. These are from the main wiring loom of the car so nothing I can do about that.

My idea was to supply a PWM'd 12v to the + side of the LED for the dimming effect, and when the switch is activated the NO terminal shorts across to the LED+ to make it light up at full brightness.

The two turn signals signals need to work slightly differently. When a turn signal is activated the LED (on the switch) needs to flash a constant ON/OFF pattern. If wired in directly to the PWM line this will flash ON/DIMM instead of ON/OFF (The +12V coming from teh car side will be coming from a relay so the +12V will be pulsing, creating the flashing affect). I could isolate the two turn switches on to a second PWM line and control the logic from the Picaxe however I would prefer to stick to one PWM. I was thinking of possibly using a P-Type mosfet just before each turn switch to distrupt the PWM line upon the switch making contact but not sure how complex that will get requiring a -ve voltage to switch the mosfet. I was hoping for a more elegant solution.

So basically two problems:

1 - make the PWM on Picaxe work for a 12v line
2 - Breakthe PWM line for the two turn switches on activation of switch

Thanks again chaps.
 

lbenson

Senior Member
With an 800 ohm built-in series resistor the current would be 6.25mA at 5V (as hippy said while I was typing), and 15mA at 12 V. If bright enough, you could directly drive from picaxe pin, or you could use a ULN2803A for 12V. Like so:
23397
If you wanted to have these PCBs made up (for instance, at JLCPCB.com), gerber files for the 14SIP are in this thread, and the ULN2803A in this one.

0V on your lights would be connected to the pins on the far left (for on/off). For PWMing you would need two 14M2s to use the PWM pins,
C.2, C.0, B.2, B.4.

(Note that C.3 is input only on the 14M2, so couldn't switch the lowest pin as shown above.)
 
Last edited:

hippy

Technical Support
Staff member
With an 800 ohm built-in series resistor the current would be 6.25mA at 5V (as hippy said while I was typing),
Sorry - I deleted that while you were typing, because I'd envisaged a 5V only scheme but that didn't fit with the reality of what there is.

But you're right;and my main point was that the current through the LED switches would be below 6mA, taking into account LED Vfwd, so easily controlled using a ULN Darlington.
 

hamtt

Active member
NOTE: Be sure to "ALWAYS!" put a suitable fuse in the supply line. If a everyday car battery was to be the source of the 12V, it can deliver enough current to make a spanner glow red, hence without a fuse any circuit could be a fire hazard.
The 12v feed isn't going to be coming directly from the battery. It is being tapped off from the 12v going to the dash from the ECU so it will be substantially lower current.
 

hamtt

Active member
If you wanted to have these PCBs made up (for instance, at JLCPCB.com), gerber files for the 14SIP are in this thread, and the ULN2803A in this one.

0V on your lights would be connected to the pins on the far left (for on/off). For PWMing you would need two 14M2s to use the PWM pins,
C.2, C.0, B.2, B.4.

(Note that C.3 is input only on the 14M2, so couldn't switch the lowest pin as shown above.)
Thanks very much for making the gerber files available, it's very much appreciated. I'm nowhere near the PCB design stage yet (there's a lot more functionality than what's being discussed here yet) but just trying to figure out the components and logic. No doubt they will come in helpful when I get to that statge.

Why would I need two 14M2's? Wouldnn't i just be able to use a single PWM-OUT to patch up to the ULN2803A?
(I'm using an 18M2 for development but happy to go up to a different chip if required).

I've ordered some ULN2803A chips to have a play about with.
 

lbenson

Senior Member
Why would I need two 14M2's? Wouldnn't i just be able to use a single PWM-OUT to patch up to the ULN2803A?
The 14M2 has 4 separate PWM pins, so if you want to control 8 lights at separate pwm levels, you would need two. If you want them all to be at the same level simultaneously, but vary that level for all, you don't need the ULN2803--you could use a single logic-level mosfet like the IRL520 (which would run cool without a driver at 1kHz up to your maximum current of 15*8 or 120mA), or the 2n7000 suggested by cpedw (up to 200mA) or something newer like the FQU13N06LTU (good also for much higher currents).

Hmmm ... I just notice that you said you need to pwm the high side, not the low side. Why is that? If so, neither ULN2803 nor N-CH mosfets will help you, and high-side 12V driving of pwm is beyond my experience.
 
Last edited:

hippy

Technical Support
Staff member
Hmmm ... I just notice that you said you need to pwm the high side, not the low side. Why is that? If so, neither ULN2803 nor N-CH mosfets will help you, and high-side 12V driving of pwm is beyond my experience.
Maybe not , going back to the OP's original post and the circuit.

The OP wants to change "off/full" to "dim/full". The circuit uses diode mixing to provide a voltage to the LED the other side of which goes to 0V. It should indeed be possible to diode mix a 5V signal from the PICAXE to the LED's, no high or low-side driver required.
Code:
      12V --.--          .-------.
            |            |       |
            |            |   /O--|--
            }------------|--O    |
            |            |    O--|--
            |            |       |
            `--|>|---.   |  LED  |
                     }---|--|>|--|---.
PICAXE OUT >---|>|---'   |       |   |
                         `-------'   |
                                     |
PICAXE 0V ---------------------------^-- 0V
There is no actual need for a PICAXE. The "PICAXE OUT" in the above could be taken to an always 12V signal via an appropriate resistor. A single one of those could feed all switches.
 

mortifyu

New Member
High side PWM can be achieved with P- Channel FET. I did notice that point made earlier. In the last couple days time in my workshop has been very limited, however I will POST a schematic of this within the next 24hrs.


Regards,
Mort.
 

hamtt

Active member
The 14M2 has 4 separate PWM pins, so if you want to control 8 lights at separate pwm levels, you would need two. If you want them all to be at the same level simultaneously, but vary that level for all, you don't need the ULN2803--you could use a single logic-level mosfet like the IRL520 (which would run cool without a driver at 1kHz up to your maximum current of 15*8 or 120mA), or the 2n7000 suggested by cpedw (up to 200mA) or something newer like the FQU13N06LTU (good also for much higher currents).
All the LED's will be at the same PWM brightness. Any visual different in brightness between different coloured buttons I can adjust with a fixed inline resistor, so one control will control all the brightness.

The only exception may be if I put the two indicator/flasher switches on a seperate PWM line in which case I will require to utilise two PWM pins from Picaxe.

Hmmm ... I just notice that you said you need to pwm the high side, not the low side. Why is that? If so, neither ULN2803 nor N-CH mosfets will help you, and high-side 12V driving of pwm is beyond my experience.
On this design I'm being forced to use SPST switches, and the switching action is on the +12V lines from the car. As such when the switch makes contact I can only tap off a +12V from the NO pin to the LED. The GND needs to be supplied constantly to the LED. Thus the DIM/ON function can only be acheived by using a PWM +12V and Constant +12v.

In a previous version of this dash I used DPDT switches which allowed me to short both the +12V for the switch action and the GND for PWM. Howveer the quality of those switches wasn't very good and cost about 5x more each. I tried to source the new switch in DPDT but it's simply not available.
 

hamtt

Active member
There is no actual need for a PICAXE. The "PICAXE OUT" in the above could be taken to an always 12V signal via an appropriate resistor. A single one of those could feed all switches.
The Picaxe is controlling a lot of other functions also. This dimming effect is just one of the things I'm trying to incorporate in to the same Picaxe/PCB to simplify the assembly. The switches on the dash are being used to control multiple fiunctions depending on the length they are pressed for and if multiple ones are pressed together. eg. For the turn switches, if the are pressed for under 1s, the turn signal activates for 7s. If the switch is pressed down for over 2s, the turn signal stays constantly on until being switched off by pressing the switch again. The main reason for using teh Picaxe was for this type of logic (which I pretty much sorted out already).

In the first version of this dash I didn't use a PIC and used basic wiring, resistors, diodes and an off the shelf PWM from fleebay to make it work. Howver I found when it came to assembling, the wring was so complicated and time consuming it would take alsmost a day to do that. So the intention was to simplify a lot of teh wiring by moving the logic to be controlled by the Picaxe.
 

hamtt

Active member
High side PWM can be achieved with P- Channel FET. I did notice that point made earlier. In the last couple days time in my workshop has been very limited, however I will POST a schematic of this within the next 24hrs.


Regards,
Mort.
Much appreciated Mort.

This was my original thinking of how to acheive it but I didn't know which P-Channel FET to use. I did find a couple that could possibly do the job but wasn't sure if they would switch fast enough for PWM use. I could have just bought and tried but the P-Channel's require a negative voltage to activate the gate which would be fine when the pulse of teh PWM was high, but when it was low then the 3.3v/5v from the Picaxe would not be sufficient to activate the gate, so wasn't sure about how to get a permanent negative voltage in to the circuit to activate the gate.
 

hamtt

Active member
Mixing the 5v and the 12v was the obvious way to do it but I wasn't sure if that was a good idea and if the pinout from the Picaxe would have enough current on its own to drive 8 LEDs.

I need a pretty rugged solution as its being used in an industrial emvironment.
 

lbenson

Senior Member
Here is a p-channel mosfet circuit. Your lamps would be connected to "OUTPUT". R1 could be 10K or more.
23407
I could have just bought and tried but the P-Channel's require a negative voltage to activate the gate
That's GATE negative relative to SOURCE--the circuit above achieves that when CONTROL is HIGH, making the 2n7000 n-ch "signal" mosfet conduct, which brings the gate of the IRF9530 (or almost any p-ch mosfet) to 0V, or negative relative to the 12V at its source, so it conducts. CONTROL can be PWMed--1kHz is usually satisfactory for LEDs, and runs cool. A pot could be read by the picaxe to adjust the brightness level with PWM.
 
Last edited:

hippy

Technical Support
Staff member
Mixing the 5v and the 12v was the obvious way to do it but I wasn't sure if that was a good idea and if the pinout from the Picaxe would have enough current on its own to drive 8 LEDs.
Shouldn't be a problem doing that and the PICAXE should be fine if there are 800R resistors in the LED's.

What's confusing me though is why 12V is being used at all.

Are the buttons latching, 'push to make, push to break', or only 'push to make, release to break' ?

It seems that, on one hand, they are being used to tell the PICAXE what to do but, on the other, are driven by 12V coming from something else, which in some cases seems to be intermittent. Such buttons couldn't be determined to be pushed when no 12V is present.

The buttons appear to be 'push to make, release to break' or you couldn't tell how long they were being held for. But if that's the case it would seem 12V is only being used to signal closure to the PICAXE, not control anything else, and it would be easier to just put 5V through them, use the 12V only to light the LED fully -
Code:
      12V --.--          .-------.
            |            |       |
            `--|>|---.   |  LED  |
                     }---|--|>|--|-----.
PICAXE PWM >---|>|---'   |       |     |
                         |       |     |
                         |   /O--|-    |
       5V >--------------|--O    |     |
                         |    O--|--.  |
                         `-------'  |  |
PICAXE IN <-------------------------'  |
                                       |
PICAXE 0V -----------------------------^-- 0V
I think this notion of PWM'ing 12V has completely confused things.

That could be due to viewing the LED's as "12V LED's". It might be easier to think of them as "5V LED's which can tolerate having 12V applied".
 

hamtt

Active member
That's GATE negative relative to SOURCE--the circuit above achieves that when CONTROL is HIGH, making the 2n7000 n-ch "signal" mosfet conduct, which brings the gate of the IRF9530 (or almost any p-ch mosfet) to 0V, or negative relative to the 12V at its source, so it conducts. CONTROL can be PWMed--1kHz is usually satisfactory for LEDs, and runs cool. A pot could be read by the picaxe to adjust the brightness level with PWM.
Thanks very much for the diagram, I'll have a proper look at it tonight and your help really is appreciated.

I actually understood the negative voltage was negative relative to the 12v but I think I got my knickers in a twist trying to solve too many issues at the same type with a P-channel FET in my head and may have overlooked the obvious.
 

hamtt

Active member
What's confusing me though is why 12V is being used at all.

Are the buttons latching, 'push to make, push to break', or only 'push to make, release to break' ?
The switches are a mixture of momentary and latched (the type you describe above).

The switches are wired in the car on the high side for operations such as ignition and horn, I can't change this unfortunately as thats how the wiring loom of the car is. I hope the following picture explains (I've omitted out the diodes, just trying to show how I'm trying to switch frim dim to full brightness of the button when the button is pressed):

23408
 
Last edited:

hamtt

Active member
The obvious would seem to be that you don't require any 12V or high-side switching, no FET or any other driver.
I will mock it up wired directly to the 5v of the picaxe and see what happens. I just didn't like the idea of mixing 5v and 12v.
 

hamtt

Active member
The first version of the dash that I did withoutout a PIC is here:

You can see the brightness of the buttons is controlled by an rotary switch attached to a PWM and the buttons lighting up full brightness when pressed or left in a pressed state.
 

hippy

Technical Support
Staff member
I will mock it up wired directly to the 5v of the picaxe and see what happens. I just didn't like the idea of mixing 5v and 12v.
To provide some background illumination, so the switches can be seen in the dark, so long as mixing diodes are used on each switch, it should be fine. But the proof is indeed in trying it.
 

lbenson

Senior Member
I've looked at the diagrams, and I don't really understand what the switch activates and how that controls the bright/dim states.
23409
What is the C connection--is it 12V? What is its purpose in the circuit? Related: what is the distinction between the two red lines on the right by +12V?

So when the button is undepressed, the red line on the upper left would be disconnected, and so the supply would be from the (diode protected) purple line? So that purple line would be always active, delivering the PWM-modulated current from the picaxe? If so, if it might simultaneously be feeding all 8 LEDs, with maximum total current of around 120mA, a single picaxe pin couldn't provide it, so it would have to be gated somehow.
 

hamtt

Active member
I've looked at the diagrams, and I don't really understand what the switch activates and how that controls the bright/dim states.
View attachment 23409
What is the C connection--is it 12V? What is its purpose in the circuit? Related: what is the distinction between the two red lines on the right by +12V?.
C is the "Common" terminal on the switch.
On switches like these you have a C (the input of the line) and a "NO" (Normally Open) and an "NC" (Normally Closed) terminal.

Depending on how you want the switch to operate, the output connects to NC or NO. If I wanted the switch to make a continuos contact and upon PRESSING the switch, the contact breaks, then the NC terminal is used as the output. If (how normally switches operate) I want the circuit to be open and upon pressing the switch the circuit completes, then the NO terminal is used as the output.

In this instance yes, the C has a 12V going in to it (could equally be the ground but the car wiring loom switches on the high side).
The first red line is the +12v going IN to the switch, the second red line is the +12V coming OUT of the switch that would oonly be active when the switch is pressed.

So when the button is undepressed, the red line on the upper left would be disconnected, and so the supply would be from the (diode protected) purple line? So that purple line would be always active, delivering the PWM-modulated current from the picaxe?
Correct

simultaneously be feeding all 8 LEDs, with maximum total current of around 120mA, a single picaxe pin couldn't provide it,
My concern precisely.
 

hippy

Technical Support
Staff member
I've looked at the diagrams, and I don't really understand what the switch activates and how that controls the bright/dim states.
That's what had me confused. If I have now understood things correctly it doesn't. The PICAXE, for this part of things is only providing background illumination for all the buttons when not pressed. So, take for example a horn button, where there will always be background illumination from the PICAXE and full illumination and horn blaring away when the button is pressed -
Code:
Battery 12V --.--         .---------.
              |           |    _    |
              |           |  _|_|_  |
              `-----------|--O   O--|------.----.
                          |         |      |    |
PICAXE PWM >-----|>|--.   |   LED   |      |   _|_ /|
                      }---|---|>|---|---.  |  |   | |
              .--|>|--'   |         |   |  |  |_ _| |
              |           `---------'   |  |    |  \|
              `----------------------------'    |
                                        |       |
PICAXE 0V ------------------------------^-------^-- 0V
So that purple line would be always active, delivering the PWM-modulated current from the picaxe? If so, if it might simultaneously be feeding all 8 LEDs, with maximum total current of around 120mA, a single picaxe pin couldn't provide it, so it would have to be gated somehow.
I make it N x 6mA at 5V and probably less. So that's likely 4 LED's per PICAXE pin. One could use multiple PWM for more buttons, use HPWM to fake four simultaneous identical PWMOUT, or the Digital Signal Multiplexor to duplicate a PWM on another pin, depending on PICAXE used. Or just use logic gates as buffers.
 

hamtt

Active member
Which is it?
Both.

I'm using momentary switches for the indicators but I'm making them mimick a latching switch through the logic in Picaxe if pressed for longer than 2 seconds. If pressed once they just light the indicators for 7 seconds. The car does not have self-cancelling indicators so this goes some way to compensate that. Furthermore if the brake pedal is pressed and the idicators are on a 7s countdown, the counter will pause until the break pedal is released and then resume. This is so single press 7s flash will be useful for lane changes whilst driving, and a single press at traffic lights standstill will be useful for flashing for 7+x seconds, where x is the length of time the brake pedal is pressed. Long press (over 2s) that would make the switch mimick a latching switch would be useful when the car is pulled up to the kerb indefnitely or without the driver in it. Pressing BOTH the indicator switches together triggers the hazard switch in which case they will also mimick a latching switch.

The ignition and fog light buttons will be proper latching switches with the switch action wired directly to the car, not through Picaxe, as no logic is required to make them have different functions.

Other switches such has the horn will be momentary switches wired directly to the car and not through Picaxe again, as again no logic control is required.
 

mortifyu

New Member
Hi All,

POST #22 from Ibenson perfectly explains and denotes HIGH SIDE switching. I was going to post a similar diagram, but there's no point doubling up.

HIGH SIDE switching with P-Channel FET's is basically the same as LOW SIDE switching with N-Channel FET's and only differs from a polarity point of view.

In each case you just need to have a potential difference (a VOLTAGE) between the GATE and SOURCE to turn the FET on. By how much is dependent on the FET used.
Using a FET that has GATE-SOURCE range of +/-20V and a circuit that is operating at 12V then you can simply take the GATE fully to 12V or GND without the necessity of a protection zener diode between GATE-SOURCE.

R1 in Ibenson's diagram merely turns the M2 FET off when M1 is not pulling the GATE to GND, which is doing the job of turning M2 on. R1 could even be 100K, remember it takes a negligible amount of current to turn a FET on or to hold it off. If R1 was omitted, M2 has no way of turning off and therefore in this particular case is absolutely essential.

R3 in my diagram in POST #6, is doing this very same job, but in a LOW SIDE switching N-Channel configuration.



Regards,
Mort.
 

Hemi345

Senior Member
I posted a schematic of a possible solution for the turn indicator buttons but decided to delete. Without knowing exactly how the turn signals are wired, it would probably just confuse any further discussion on that topic.
 

hamtt

Active member
I posted a schematic of a possible solution for the turn indicator buttons but decided to delete. Without knowing exactly how the turn signals are wired, it would probably just confuse any further discussion on that topic.
The summary I saw in the notification seemed correct.

For this part the Picaxe is only supplying the PWM'd supply for the dim lights, the car relay creates the flashing action and pulses +12v through from the other side.
 

lbenson

Senior 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.
 
Top