How to control external voltage via PWM

Using an Uno's PWM output (driven by a photo-resistor used as input), how can I control an external voltage source (an LM2596S voltage regulator module set to 8 vDC right now) to deliver a variable output voltage between 8 and 7 volts? I'd like this control to be linear so the ratio between the Uno's PWM and the desired single volt (between 8 and 7) are in synch, by reducing output from 8vDC to lower values. For instance:

if the PWM were 156, the controlled voltage output would drop to about 7.6vDC.
if the PWM were 128, the controlled voltage output would drop to about 7.5vDC;
if the PWM were 100, the controlled voltage output would drop to about 7.4vDC;

I'm posting this because I want to learn what hardware I can use to do that (as inexpensive as possible), and how would I connect it all using PWM from the Uno as the "trigger" of the control?
Thanks.

Then we have to assume the module allows remote setting of the output voltage?
Paul

Nope. I set the voltage on the module by a variable resistor. I'm hoping to find some hardware I can "inject" between the voltage regulator's output and my load.

Then, do you have schematic of the module?
Paul

Unfortunately not. The URL where I got it is: https://www.fasttech.com/products/0/10002934/1219200-10pcs-dc-dc-3-40v-to-1-5-35v-3a-buck-converter
The page doesn't have a link to a schematic, just some pictures. Sorry.

I really don't expect people to buy what you have just so they can answer your question. Have you looked for modules that do allow remote voltage change?
Paul

No.
You might be able to replace the adjustable resistor with a digipot.

I don't expect anyone to buy stuff, either. I'm looking for external components to go between the voltage regulator and my load -- components that can be controlled by PWM from the Uno -- components that will lower (and then raise) the voltage regulator's output voltage based on PWM, thus affecting my load.
As for the digipot... that's a good idea. I'll look into it. Thanks.

I guess a N-MOSFET might help. (A Logic level one). By applying a PWM signal to the Gate you can control the voltage and current that flows out from the output.

Set the Buck converter for max output.

Then follow this schematic:

image (Output: + wire not the GND).
This should work. You can use any Logic level N-Channel MOSFET.

HTH.

Devanshu_Acharya,
That's why these forums are so good. Never in a thousand years would I have just "known" about a device like an N-MOSFET. I do have a question, though - if you can answer it... how does this device work without having ground wired into it as a reference? I trust it DOES work, but I'm curious. Thank you very much for your input and for the very easy-to-understand schematic!

Actually when you wrote this post you already used millions on transistors (MOSFETs) on that electronic gadget.

N-MOSFET stand for N-channel MOSFET. See these few videos to clear some of your doubts:

Videos (There are loads of videos on the Internet)

Working of Transistors | MOSFET - YouTube
Transistors Explained - How transistors work - YouTube
MOSFET BJT or IGBT - Brief comparison Basic components #004 - YouTube

I am also a student so I may not explain much clearly, but actually what happens is that with a variable PWM signal, the MOSFET acts as a variable resistor and drops some of the voltage.

I suppose you know what a PWM is, if not see the below image:

As the voltage on the Gate increases, the resistance (RDS(on)) decreases and the voltage increases.

Sorry, I made a mistake in the original schematic follow this schematic:
image

Note

I am also a beginner, so this schematic may not work, I built this based on my knowledge, I have not tried it myself.

Regards.

Thanks for the schematic update. I'm now waiting for parts I've ordered. I ordered some RFP3006LE MOSFETs and some digipots (thanks, Steve!).
With respect to my ground question, I think I figured that out. I wondered how the MOSFET worked without any ground connection. But really, the ground reference is probably found through the variable output and the load connected to ground. As long as it works...

Devanshu_Acharya,
Thanks for yet another update to your response. From some other things I had read on the web about MOSFETs, I thought (as your most recent schematic shows) that the load would go between the high voltage (the output from my voltage regulator) and the drain on the MOSFET. Then when the gate is energized, current would flow through the load, the drain, and then out the source to ground. Just why the names "drain" and "source" seem to be backwards is a mystery to me. I'd think they'd be the other way around. I guess it's because this is a N type MOSFET. But as I said before, as long as it works!
Many thanks!

@ugfrog What you read is absolutely right, because N-Channel MOSFETs are made for high side switching (Load is connected to supply voltage). My updated schematic should work just fine. By controlling analogwrite() at the gate you can get a variable voltage at the load and the rest of the volatge would be dropped by the MOSFET. If required, use a heatsink with the MOSFET.

I had the same doubt :slight_smile: and I probably know the answer.

In a N-Channel MOSFET, conventional current (simply current) flow from Drain to Source. This is because electrons flow from Source to Drain. Source is named as source because it "sources" electrons and the Drain is named as drain because it "drains" electrons out.

Always remember that electron flows in the opposite direction of current flow.

Regards.

I got the project working, but not without some experimentation. Remember my ground question back in post #10? Something seemed odd to me about using ONLY the positive output from the high voltage source. None of the posts or schematics I could find on the web seemed to say anything about the high voltage source's ground connection. When I started working with the MOSFET, nothing worked. Then, I connected the high voltage source's ground to the UNO's ground, and everything worked. Noobie error!!! Thanks for all of your comments.
P.S. I'm waiting for a delivery of digipots so I can try that route, too -- just to learn about them.

No, that is low-side switching - the switch is on the low side of the load, at ground, the load it on the high-side.

The charge carriers come from the source through the channel and exit to the drain.
In an n-channel MOSFET the carriers are negative (electrons). Conventional current flows in the opposite direction to electrons (and the same as holes).

The same naming convention applies to BJTs, the charge carriers come from the emitter, diffuse across the base, and end up on the collector. In an NPN device the carriers are negative electrons, in a PNP they are positive holes.

Oh, very sorry my bad.

@ugfrog The GND symbol I showed you in the schematic is the High Voltage source ground. And Yes, you did it correct, you always need to have a common ground when using an external source of power.

Electronics is all about experimenting and this is why I love messing up with electronics and robotics.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.