# Need help designing a buck converter

#### jmcca

Joined Jul 9, 2021
4
Hello all,
I'm new to the forum and honestly quite new to electronics in general. I'm working at the moment on a school project in which my teacher told us to design a buck converter using raspberry pi. The final goal should be to use a solar panel to power the circuit and use MPPT to charge a battery. For now I'm still trying to make the circuit work using a power supply. I'm working with a 100kHz signal from raspberry pi and 12V power supply. I'm trying to charge a 3.7V battery. You'll find attached the circuit schematic.

For now I've achieved the circuit working and it actually charges the battery, but not exactly the way it should.

The problems I'm facing at the moment are:
- The circuit is working and it charges the battery, however I've calculated the components based on the Vin/Vout, frequency and duty cycle, and I'm obtaining the inverse duty cycle that I'd be supposed to get. For example, I should be getting aroun d 36% duty cycle, and the result I'm obtaining on the raspberry pi is 64% (it matches somewhat the value on osciloscope too)

- The duty cycle that raspberry pi shows doesn't match the osciloscope by some percentage. There's 4-5% discrepancy at 100 kHz. If I increase the frequency, the duty cycle error between the Pi and the osciloscope gets bigger.

- The solar panels we will be testing deliver around 5V. I've tried lowering the power supply voltage to around 5V but then it isn't enough to trigger the mosfet driver. It needs around 10V to work properly. Is there anyway I can make it work with less voltage?

I'm sorry if I'm making stupid questions and basic errors. I should add my teacher doesn't really understand much on the subject (he's a substitute teacher) and all the answers he gives me are related to "do a google search". I also have few bases in electronics so I'd be glad if you can refer some literature you might think is appropriated. Also, sorry if the schematic isn't correct, it's my first time using EDA. I'm kinda learning everything at the same time because I'm on a tight deadline. I feel quite lost

#### Attachments

• 27.6 KB Views: 25

#### crutschow

Joined Mar 14, 2008
33,983
but then it isn't enough to trigger the mosfet driver. It needs around 10V to work properly. Is there anyway I can make it work with less voltage?
Logic-level type MOSFETs (Max Vgs threshold less that 2V) will work with a Vgs of less than 5V.

#### ronsimpson

Joined Oct 7, 2019
2,878
C3 & D2 are not connected to ground.
C3 is shorted.
Why C2?
IR-2104 has a minimum operating voltage.
IR-2104 is make to drive N-MOSFETs not "P".
IR-2104 not used correctly. No capacitor Pin8-6.

#### Papabravo

Joined Feb 24, 2006
20,985
That's a pretty vague requirement. Could you be a bit more explicit about the requirements? For example tell us the required input and output power levels and what the role of RPi is supposed to be.

#### dl324

Joined Mar 30, 2015
16,658
I'm working at the moment on a school project in which my teacher told us to design a buck converter using raspberry pi.
Is this a project for which you will be graded?

#### jmcca

Joined Jul 9, 2021
4
Thank you all for your kind responses

Logic-level type MOSFETs (Max Vgs threshold less that 2V) will work with a Vgs of less than 5V.
So if I understand correctly it might be enough to change the MOSFET to one more appropriate and remove the gate driver entirely? Or would it still be necessary?

C3 & D2 are not connected to ground.
C3 is shorted.
Why C2?
IR-2104 has a minimum operating voltage.
IR-2104 is make to drive N-MOSFETs not "P".
IR-2104 not used correctly. No capacitor Pin8-6.
View attachment 252006
I fixed the schematic (attached), I'm sorry, my mistake.

C2 is used only to protect my raspberry Pi, since I've burned one already. I'm not sure if that's the way to prevent current from flowing back into the Pi, but when I searched for it online I found that to work. Correct me if I'm wrong.

As for the IR2104 I got quite confused reading the datasheet. It says it is compatible with 3.3 and 5V logic levels, which I assumed would be suitable to activate it using a Pi, or that it would mean a 3.3/5 supply would be enough. On the datasheet the VCC also seems to range from -0.3V to 25V. Am I reading it wrong?

Also in IRLZ34N datasheet it is named as a N type mosfet, but I might be misreading it. I made the corrections you mentioned on the schematic and inserted the capacitor between Pin8-6. I tried the circuit again and obtained the same results with the capacitor.

That's a pretty vague requirement. Could you be a bit more explicit about the requirements? For example tell us the required input and output power levels and what the role of RPi is supposed to be.
Sorry for being so vague. The goal with this project is to use a buck converter on a solar panel (which I have no real datasheet as it wasn't provided. I tested it with a light bulb and it delivers around 5V to the circuit) to charge a 3.7V lithium battery. The final goal would be to use MPPT with the solar panel for maximum efficiency, but for now I'm trying to make it work with a fixed supply voltage of 12V. The raspberry Pi is used to send a pwm signal into the circuit to control the voltage into the circuit (I can provide the python code I'm using, maybe you'll understand better). I'm working with 100 kHz right now. For instance, after the buck converter my voltage varies from 4-8V depending on the duty cycle the raspberry pi "chooses". I'm reading 1.1W of power after the buck converter.

I'm not sure I was clear, I'm sorry. If it wasn't clear or you need more details I will try to provide them.

Is this a project for which you will be graded?
Yes, I will be graded for this project.

Thank you so much for all your replies guys, I really appreciate it. And I'm sorry, I feel like I'm quite dumb on the subject.

#### Attachments

• 29.3 KB Views: 8

#### Papabravo

Joined Feb 24, 2006
20,985
I see the basic buck converter components, and I see the input voltage of +12V but the output voltage and the required current are still a mystery. Also I asked for a description of the role of the RPi in this scheme. Connecting it via a capacitor is almost certainly the wrong thing to do.

#### dl324

Joined Mar 30, 2015
16,658
Yes, I will be graded for this project.
You should be aware that the code of conduct for any reputable school would consider getting help grounds for disciplinary action. This site has a Homework Help section where members should know not to do the work for students.

#### jmcca

Joined Jul 9, 2021
4
I see the basic buck converter components, and I see the input voltage of +12V but the output voltage and the required current are still a mystery. Also I asked for a description of the role of the RPi in this scheme. Connecting it via a capacitor is almost certainly the wrong thing to do.
Hello! The output voltage should be 4.1V as that is the voltage necessary to charge the battery. As for the output current, it is 300mA (it drains more current, up to 2A but I still don't have a way to dissipate heat from the MOSFET with that current, it gets extremely hot, so for now I limited it to 300 mA on the python code).

The role of the RPi is only to provide a PWM signal (currently at 100kHZ) and will then be to MPPT with the solar panel connected. I thought the capacitor would prevent the current from going back into the RPi, so I added just as prevention (because I've burned my previous Pi with wrong connections) . I'm not sure if it works like that, but when researching it online it was one of the solutions I found.

You should be aware that the code of conduct for any reputable school would consider getting help grounds for disciplinary action. This site has a Homework Help section where members should know not to do the work for students.
Thanks for the warning, I really didn't know about that. Thank you for moving the thread to the right section. I just need some direction as I'm really struggling and all the questions I bring up to the professor end up with a google search answer.

#### Papabravo

Joined Feb 24, 2006
20,985
The capacitor will block any DC signal and produce a series of positive going and NEGATIVE going pulses that can potentially damage the IR2104. You need better solution. If the Power supplied to the IR2104 is not compatible with the RPi and you need to isolate the two devices then an opto-isolator is the way to go. A 4N35 is a viable part number. There will be a 3-5 μsec delay through the opto, but that will qpply to both edges. Are you able to simulate the circuit before you try testing it in the lab?

#### Audioguru again

Joined Oct 21, 2019
6,604
What is the maximum allowed charging voltage and current of your lithium battery?