TheQuestionMark?
Posts: 17
Joined: Thu Mar 23, 2017 9:23 am

I have problems with my electronic circuit

Thu Mar 23, 2017 2:10 pm

Hi Guys i’m so lost. Can anyone please help me?

I want to light up 8 leds (each 2.8 watt, 12V) one after the other. I’m going to controll that from a raspberry pi 3. I'll use a 12v power supply.
Now my question is: Which transistor should i buy and which resistors will i have to use?.
Last edited by TheQuestionMark? on Tue Oct 16, 2018 1:04 pm, edited 1 time in total.

W. H. Heydt
Posts: 13636
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: I have problems with my electronic circuit

Thu Mar 23, 2017 10:08 pm

Look for optoisolators to keep the 12v strictly away from any electrical connection to the Pi...it will let the magic smoke out.

boyoh
Posts: 1531
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: I have problems with my electronic circuit

Thu Mar 23, 2017 10:39 pm

TheQuestionMark? wrote:Hi Guys i’m so lost. Can anyone please help me?

I want to light up 8 leds (each 2.8 watt, 12V) one after the other. I’m going to controll that from a raspberry pi 3. I'll use a 12v power supply.
Now my question is: Which transistor should i buy and which resistors will i have to use?
More information is needed on the 12v led, are they the cluster lights , used in domestic lighting.
Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

boyoh
Posts: 1531
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: I have problems with my electronic circuit

Thu Mar 23, 2017 10:41 pm

TheQuestionMark? wrote:Hi Guys i’m so lost. Can anyone please help me?

I want to light up 8 leds (each 2.8 watt, 12V) one after the other. I’m going to controll that from a raspberry pi 3. I'll use a 12v power supply.
Now my question is: Which transistor should i buy and which resistors will i have to use?
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

pcmanbob
Posts: 10175
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 10:05 am

TheQuestionMark? wrote:Hi Guys i’m so lost. Can anyone please help me?

I want to light up 8 leds (each 2.8 watt, 12V) one after the other. I’m going to controll that from a raspberry pi 3. I'll use a 12v power supply.
Now my question is: Which transistor should i buy and which resistors will i have to use?
Hi.

So making the assumption that the 12v 2.8W LED is some kind of LED bulb and not just a bear LED all you would need is a 2n2222 transistor and a 1K resistor to drive each LED.

Image

if how ever your LED is in fact just a bear LED you may also need a current limiting resistor for the LED but would need more details about the LED to advise.
( as always test and prove circuit before connecting to Pi )
Last edited by pcmanbob on Fri Mar 24, 2017 11:59 am, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 10:52 am

That circuit won't work properly - with a 1k resistor the base current will be limited to (3.3V-0.7V)/1K = 2.6mA. From the 2N2222's datasheet, the gain (Hfe) will be around 60, so the collector current will be around 150mA, less than the 250mA a 2.8W 12V load demands.

You could use a lower value resistor to up the current, but bear in mind that eight of these are needed on the one Pi, so better to use a Darlington pair or MOSFET. A logic level n-channel MOSFET is what I'd go for - zero load on the Pi's GPIO.

pcmanbob
Posts: 10175
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 11:03 am

Well I bench tested it using a PC fan as I don't have an LED bulb suitable, fan was drawing 214mA measured using a meter, supplied from 12 psu, base current was 2.2mA.
and LED will draw 0.23333333A or 234mA not 250mA
Last edited by pcmanbob on Fri Mar 24, 2017 11:25 am, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 11:14 am

There'll be a variation, part to part, of the Hfe. The next transistor you pick may not work so well, it's on the limit.

User avatar
PeterO
Posts: 5974
Joined: Sun Jul 22, 2012 4:14 pm

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 11:34 am

I hope you've mislabeled the bottom right connection in the diagram. If it really is -12V then DON'T connect it to the PI's 0V/GND line.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

pcmanbob
Posts: 10175
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 11:55 am

PeterO wrote:I hope you've mislabeled the bottom right connection in the diagram. If it really is -12V then DON'T connect it to the PI's 0V/GND line.
PeterO
The only reason I labelled it like that was in the past I labelled a diagram 12V + and Gnd and I got complaints saying it should be 12v+ and 12V- seems I can't win. may be I can please every one with 12V gnd :lol:
image amended :D
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

pcmanbob
Posts: 10175
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 12:04 pm

gregeric wrote:better to use a Darlington pair or MOSFET. A logic level n-channel MOSFET is what I'd go for - zero load on the Pi's GPIO.
not wishing to be adversarial, but if you have a better solution then post some device numbers and suggested resister values for connecting them. after all that's what was asked for by the original poster.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

TheQuestionMark?
Posts: 17
Joined: Thu Mar 23, 2017 9:23 am

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 12:14 pm

gregeric wrote:That circuit won't work properly - with a 1k resistor the base current will be limited to (3.3V-0.7V)/1K = 2.6mA. From the 2N2222's datasheet, the gain (Hfe) will be around 60, so the collector current will be around 150mA, less than the 250mA a 2.8W 12V load demands.

You could use a lower value resistor to up the current, but bear in mind that eight of these are needed on the one Pi, so better to use a Darlington pair or MOSFET. A logic level n-channel MOSFET is what I'd go for - zero load on the Pi's GPIO.

Thanks a lot for your answer...i have a question though.
Lets say i use a logic n channel mosfet (is that a special transistor which isolates an other circuit with higher voltage from the raspberry?), do i then have to care about resistors and the voltage i use to "activate" the mosfet. Can it be any mosfet or do i have to take a specific one...
Could you make me a electronic schematic for me to visualize the whole thing?

By the way i'm using led chips.

Thanks again for your help so far:)

User avatar
PeterO
Posts: 5974
Joined: Sun Jul 22, 2012 4:14 pm

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 12:20 pm

pcmanbob wrote: The only reason I labelled it like that was in the past I labelled a diagram 12V + and Gnd and I got complaints saying it should be 12v+ and 12V- seems I can't win.
No you can win by labelling it correctly as I described.
image amended :D
Still not quite right, but it is better and unambiguous ;)
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 12:56 pm

OK, here's how I'd do it:
mosfet.png
mosfet.png (8.93 KiB) Viewed 3465 times
R2 ensures the MOSFET is off if ever left floating. It also overcomes the default ~50k pullups on GPIOs 0-8 to ensure it's off during booting.

If you connect instead to one of GPIOs 9-27 (with default pulls down at boot), you could omit R2 & even R1.

There are other MOSFETs which can be driven fully on with he Pi's 3V3 logic. Look for low Vgs & low Rds.

TheQuestionMark?
Posts: 17
Joined: Thu Mar 23, 2017 9:23 am

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 7:59 pm

Hi guys

Thanks a lot for your ideas and suggestions. I didn't expect that many responses :)
I think i'm going to go with the MOSFET idea from gregeric.
Just one last question: Can all GPIO pins be used to control a led (be able to light it up or not). I'm especially talking about pins: 3, 5, 8, 10, 19, 21, 23, 24, 26, 27, 28 because i dont know what they are good for.
If yes i would like to use some of them to control a mini lcd display (lcd 1602)

User avatar
rpdom
Posts: 17736
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: I have problems with my electronic circuit

Fri Mar 24, 2017 8:42 pm

Most GPIO pins can be used for general purpose input/output. From the pins you listed I would use 19, 21, 23, 24, 26.

Pins 3 and 5 are used for the i2c bus if it is enabled. Otherwise it is safe to use them. Just be aware that they have 1k8 Ohm pull-up resistors on the board for i2c.

Pins 8 and 10 are used for the UART (serial port). You can connect a (3.3v) serial console to those pins and see the boot messages and log in. If you disable the serial console you can use those pins for your own purposes.

Pins 27 and 28 are reserved for HAT ID eeproms. You shouldn't really use those for anything else (but it is possible if you really know what you are doing). To be safe, leave those pins alone.

Some 1602 LCDs use i2c, in which case you can just connect them to ground, power and pins 3 and 5 and it will work with the right software.

Otherwise you will need to connect it to six GPIO pins (four for data and two for control lines), plus power and ground. There is lots of software available to drive this type or the i2c type.

TheQuestionMark?
Posts: 17
Joined: Thu Mar 23, 2017 9:23 am

Re: I have problems with my electronic circuit

Sun Mar 26, 2017 6:52 pm

Thanks for your help rpdom!

I just bought a lcd backpack which makes it able to control it using only 4 pins (Gnd, 3v3, i2c).

dloranger
Posts: 46
Joined: Wed Nov 02, 2016 1:56 am
Location: Seattle

Re: I have problems with my electronic circuit

Sun Mar 26, 2017 9:06 pm

gregeric wrote:OK, here's how I'd do it:
mosfet.png
R2 ensures the MOSFET is off if ever left floating. It also overcomes the default ~50k pullups on GPIOs 0-8 to ensure it's off during booting.

If you connect instead to one of GPIOs 9-27 (with default pulls down at boot), you could omit R2 & even R1.

There are other MOSFETs which can be driven fully on with he Pi's 3V3 logic. Look for low Vgs & low Rds.
I agree with this approach, but suggest you always have the pull down resistor, and if doing it commercially, a 0.1uF right at the gate to ground. I have seen many circuits ring at the gate causing wierdness that is almost free to avoid. This is fairly typical in anything with high speed signals, might now be for your application, but its a good design habit.

I have actually just been messing with changing the default pin configs so you never know if you will have a pull up or down, better to design for that situation.

TheQuestionMark?
Posts: 17
Joined: Thu Mar 23, 2017 9:23 am

Re: I have problems with my electronic circuit

Sat May 06, 2017 8:51 am

gregeric wrote:OK, here's how I'd do it:
The attachment mosfet.png is no longer available
R2 ensures the MOSFET is off if ever left floating. It also overcomes the default ~50k pullups on GPIOs 0-8 to ensure it's off during booting.

If you connect instead to one of GPIOs 9-27 (with default pulls down at boot), you could omit R2 & even R1.

There are other MOSFETs which can be driven fully on with he Pi's 3V3 logic. Look for low Vgs & low Rds.

Hello guys :)
Well i finished my project when i noticed that something was wrong with my circuit board. I spent hours looking for a solution to i problem i couldnt determine. I didnt kow what i was really looking for.
Then i decided to unsolder the mosfet IRL2203N and test it on a breadboard.
I tried to imitate the schematics as much as possible but it ended up not working. Whether or not there was a voltage at the gate of the mosfet as soon as i supplied the whole thing with the 12v the mosfet became conductive.

Can someone please help me?
Attachments
image.jpeg
Did i connect everything correct
image.jpeg (36.64 KiB) Viewed 3089 times

pcmanbob
Posts: 10175
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: I have problems with my electronic circuit

Sat May 06, 2017 12:12 pm

I cant quite make out all your wiring connections for sure but it looks like it might be right.
when I have problems like this I break the problem down in to steps.
so I would disconnect every thing just, then start over put the12v to led and led to mosfet and mosfet to 12v gnd now power it up and see what happens. If all is well add the resisters one at a time, testing at each stage till it either works or you find were the fault lies.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

TheQuestionMark?
Posts: 17
Joined: Thu Mar 23, 2017 9:23 am

Re: I have problems with my electronic circuit

Sat May 06, 2017 2:43 pm

Hi pcmanbob
I did everything you said. I played around with the connections hoping something would work but every attempt failed.
As soon as there was a voltage on the mosfet's drain and source the mosfet turned on (while gate voltage = 0v).

Is it possible that i "burnt" the mosfet while soldering (ca. 300°C)

Any other ideas?

User avatar
Burngate
Posts: 6374
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: I have problems with my electronic circuit

Sat May 06, 2017 3:24 pm

This might be a red herring, but are you sure you have the right pins connected on the fet?
Image
I'm not sure I can make out from your picture quite how you've wired it - but I do like the idea of labelling the wires; I wish everyone would do it!

TheQuestionMark?
Posts: 17
Joined: Thu Mar 23, 2017 9:23 am

Re: I have problems with my electronic circuit

Sat May 06, 2017 4:27 pm

Yes i checked it a couple of times and it seems to be right. (By the way does it matter if i connect the 12v to the drain or to the source and the ground to the source or drain?).

I tested the whole thing with a 3.3v LED and it worked just fine. When i connected the gate to a 3v battery (imitating a raspberry pi output signal) it turned on.
Then i replaced the 3.3v LED by a 12v Lightbulb. The mosfet turned on right away without a gate voltage. Nevertheless i connected my battery with the gate and the lightbulb just got brighter. It dimmed a little when i disconnected the battery

pcmanbob
Posts: 10175
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: I have problems with my electronic circuit

Sat May 06, 2017 4:45 pm

ok power should go like this

12+ psu >>> 12+ LED

12- LED >>> pin 2 drain

pin3 source >> psu Ground

with no input to gate LED should be off

as for burning out mosfet depends how long you heated the pins for, to long and its possible.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

TheQuestionMark?
Posts: 17
Joined: Thu Mar 23, 2017 9:23 am

Re: I have problems with my electronic circuit

Sat May 06, 2017 5:33 pm

Ok guys

I disconnected everything and started all over again. I connected everything just like you mentioned in the previous posts. I tried it with three IRL2203N mosfets just to make sure the mosfet isnt burnt.

The result was as expected. The mosfet was "on" (conductive) without any voltage at the gate pin. Supplying the gate pin with 3v didn't make any difference.

Can anyone give me the golden solution?

Return to “General discussion”