PWM to MOSFET - output too high

Hi All,

I am looking to control a Meanwell CC power supply via additive voltage. Since my Arduino is only outputting 5V, I am using this mosfet:

Code for testing is:

// Define Pins

#define FAN1 5


void setup()
{
Serial.begin(19200);
pinMode(FAN1, OUTPUT);
digitalWrite(FAN1, LOW);
}

// define variables
int FAN1Value;

// main loop
void loop()
{
#define delayTime 100 

FAN1Value = 10; 





analogWrite(FAN1, FAN1Value);
Serial.println(FAN1Value);
delay(delayTime);



}

I am inputting 12V to the MOSFET. However, the lowest output voltage I get is 7V (when FAN1Value = 1). When I use higher values I get up to 12V output. The MOSFET states it will take input frequencies from 0-20KHz. Pin 5 frequency duty cycle is ~1KHz, so that should be in range. I'm sure I'm just doing something silly, but not sure what...

Thanks,

Pete

don't call analogWrite until you need to change the output. now you restart PWM every 100 milliseconds. for a test put analogWrite into setup(() and let the loop() empty

Oops - thanks. That makes sense.

So so here is the new code:

// Define Pins

#define FAN1 5


void setup()
{
Serial.begin(19200);
pinMode(FAN1, OUTPUT);
digitalWrite(FAN1, LOW);

// define variables
int FAN1Value;

FAN1Value = 1; 


analogWrite(FAN1, FAN1Value);
Serial.println(FAN1Value);

}



// main loop
void loop()
{


}

However I am still having the same issue. For instance: : FAN1Value = 1, 7.0 V output, FAN1Value = 200, 11.6V output.

Note just tested this code for my fans, which worked fine but I didn't need the MOSFET (CPU fan, so PWM like already there). Something to do with the MOSFET but not sure what.

Regards,

Pete

Is this with the 'Meanwell CC power supply' connected to the mosfet ?
How are you trying to control this thing ?

also 'made for PWM'

they can break due to static discharge, and usually that results into them not closing properly anymore, but somehow i doubt that is the case. They are normally suited to the cause, but there maybe a capacitor somewhere beyond them on the PSU input.

Hi Deva,

Here is the Meanwell HLG-480H-54B datasheet:

That PS takes a 0-10V input, or a 10V PWM signal. I tried to hook it up directly to the 5V Arduino PWM output, but it didn't work (only outputted full 54V, same as if nothing is connected to the PWM input). Therefore, I am taking the 5V PWM and looking to convert it to a 0-10V analog signal as the Meanwell also takes that as input (see datasheet).

HOWEVER, that PS is not currently hooked up while I test. All I have is my Arduino to the MOSFET PWM input, and a 12V supply to the MOSFET power input. I am using a multimeter to measure output, which should be 0-12V based on the PWM input.

Thanks,

Pete

That multimeter has a small capacitor on the input and can not measure the voltage correctly. That is my guess.
You should not use 12v PWM to control something that takes 10v PWM.
To convert it to an analog signal i use a system with 1 diode, 2 resistors a transistor and a couple of capacitors, but since it takes PWM i would stick to that and use some kind pf level shifter, but maybe not those high power mosfets that you have now, although they should be able to do the job.

Don't expect stable analog voltage from a PWM signal. Connecting the MOSFET drain and source to DIM+ and DIM- should work with PWM, the 10V are supplied by the PSU. And of course connect gate and source to Arduino PWM and GND.

As I understand the data sheet the output voltage is controlled only by the built-in potentiometer. The PWM input only has current limiting effect. I.e. this PSU is suitable only to control LED current, not as a controllable voltage supply.

Which exact PSU type do you have - see table of Model Encoding.

Ah, I guess I had assumed that the output of that MOSFET board was smoothed and not PWM, but I guess I was wrong, so I would need an oscilloscope to check (which I don't have). Hmmm...

Hi DrDiettrich,

I have the HLG-480H-54B. When testing the voltage I was hooking up to my load, so if I limit the current I should reduce the voltage at the same time - voltage was just easier for me to test.

Pete

Your topic was moved to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

It will help you get the best out of the forum in the future.

Thank you

Your MOSFET PWM driver is rated to drive a load that is too high for the minimal load required by the DIM connections of the power supply. Looking at the resistance control graph for reference, the maximum resistance is 100K. This means only a weak PWM control signal is required. I think an opto isolator would be a much better choice.

This is very confusing... Are you trying to control a fan with an LED power supply?

The MOSFET board MIGHT work directly with the fan. You shouldn't be using a constant current power supply for a fan.

Did you get a schematic or application data with the MOSFET board? ...I wouldn't recommend buying from 3rd-party Amazon suppliers, eBay, or other "unknown" suppliers unless you are a good hardware "hacker". You'll pay more from a reputable supplier but you'll get good documentation (and possibly a better product).

I'll bet 10V is built-in and that's why it gives full-output with nothing connected to the PWM control and that's why a pot works. So you probably only need a "small" (low power) transistor and a resistor in an open-collector circuit. Take a look at the 1st schematic here. (You don't need the LED & resistor. You can connect the collector directly to the PWM input.) You could use a MOSFET similarly in an open-drain circuit but a regular transistor is probably easier & better in this application.)

Did you have a load on the Meanwell power supply? With no load (or a light load) a constant-current power supply will go to maximum as it tries to push current through infinite resistance. (CC power supplies are "strange" but Ohm's Law is always true.)

Normally no. When a MOSFET or transistor is partially-on it dissipates power internally and heats up. When it's fully-on or fully-off it dissipates less power and that's a BIG advantage of PWM when you don't really need a variable analog voltage. PWM works great for DC motor speed control or light dimming.

But the output from the Meanwell power supply MIGHT be smoothed even when PWM controlled.

Since PWM isn't normal AC or DC, multimers are unreliable. (The inertia of an old-style analog meter will average the reading so it WILL work.)

1 Like

When in fact the opposite is true, the mosfet is fast switching and therefore can be used to 'amplify' a PWM signal or basically it can be used to sink more current than the original PWM signal and usually with higher voltage as well.
A mosfet should really only be used in a fully-on to fully-off state or it will heat up much faster. Transistors have similar qualities but to a much lesser extend. If you want something partly open at times a transistor would be a better choice. Still you only need low power for what you are intending to do.
I would use a simple transistor(i have a lot of BC547 B's ) with a 10K pullup to 10v, driven through a 10K resistor from th8e 5v PWM output. Simply connecting it to the input between the pullup and the BC547.
Assume that it works and connect it to the PSU, and then measure the PSU's output voltage to verify.
If you want to test it you could also just connect a LED, that would create some voltage drop which will be quite handy since you said you have 12v not 10v available. The LED can drop it down a but so it's safely below 10v for a logic HIGH or eh actually the signal will be inverted, but that is a different matter. (5v on the base of the transistor, opens it up grounds out the signal line to the PSU etc.)

1 Like

Sorry for the confusion - I will look to post a schematic soon. No, I will not be controlling a fan, I was just using that to help see if my PWM code was working. I will be using this to control in series Peltier modules (see Choice of temperature sensor for my previous post on this project).

Yup, I just tested voltage across DIM+ and DIM- of the PS and it is 10V. So that means that PWM works not by supplying a positive voltage but more by draining the voltage from the DIM+ ? And then the circuit you suggested appears to do just that - interesting. I will try and get back to you.

Yes, I hooked up the Peltiers in series when testing, so load should be good (maybe 20A)

Update: I tried the circuit you proposed and it works! Since when the Arduino signal is high, it drains the 10V Meanwell DIM+ everything is inverted, but I hooked it up to my load and tried different PWM output values and looks good. I will need to do a bit more testing, but for now I think the problem is solved - thanks!

One think I will need to think about: since the Meanwell output is inverse to the PWM, if there is a fault with my Arduino the PS will go to max, so I need a way to ensure that the DIM+ drains if there is no signal from the Arduino.

Thanks - let me read through the post you linked and think a little.

Hi All,

So I think it is OK to reply here even though the topic is solved ? Although the solution worked (see Schematic below, note PS is tied to a 20A load for testing purposes) I am worried if the Arduino malfunctions/ loses power then my PS will output max current (since then the transistor is OFF, the PS will be at max output). Then my house will burn down.

So, I have two potential solutions I would like help with. First, adding a pull up to the PWM to tie it high if the Arduino loses power. Not sure how to set the resistor value though - I think I need to understand how much current the PWM D5 pin can sink to that when the PWM is low, I don't get a false ON state for the transistor. I assume it is on the datasheet somewhere but I can't find it. Anyway, see schematic below:

Lastly, I could use another set of transistors so that if there is no signal from D4 of the Arduino then Q1 is on and the 10V signal from DIM+ is sunk to ground.

Thanks,

Pete

How can that help when the Arduino loses power? To which supply do you want to tie the pullup?

You also missed a current limiting resistor to the transistor base.

The drawing can become simpler and clearer when you flip the transistor image to emitter down, as usual for NPN transistors.

how about just 10K ? though keep in mind, if the arduino has not power where will you get power for the pullup ?
A much better solution would be to use an opto-coupler (like a PC817, but nearly any one will do) and put a limiting resistor as a Pull-down


(edit: oops i had the PC817 the wrong way around..)
I have open ends on this schematic, but so have you. The basic idea is to use a PNP transistor instead, but since we are dealing with 10v, we don't want that on the GPIO pin hence the Opto-coupler solution. The point between the Opto and the Resistor (on the output side) is LOW unless there is power on the input.

Hi DrDiettrich,

I was planning on using a separate 5V power supply (a wall wart of some type). I will look to add the current limiting resistor.

Sorry about the drawing - not sure about all the conventions - I flipped it so it looked cleaner when wiring to ground but understand how it is more confusing.

Pete

Hi Deva_Rishi,

Not sure I completely understand. PINS 1 and 2 of the opto will be PWM from Audrino and ground respectively? Is PIN 3 from the 10V DIM+? But then current if flowing the wrong way through the transistor.

Sorry, I think I'm especially dumb this morning.