OpAmp or Transistor

Hello folks,

I want to understand the best way to do a level shift from 0-5v PWM to 0-10v PWM. I made these 2 circuits attached. One using an opamp and the other using NPN transistor.

What is advantages/disadvantages of each one?

Thanks,

Wagner

Mainly power. how much power do you need from your 10 V PWM?

A comparator may be a better choice for speed, eg LM339. With the transistor, incorporate a collector resistor. For simplicity I would use a transistor.

not so much. signalling is minimal.

On another forum, a guy told me 2 advantages using opamp: - current source capability - easy to adjust gain multiplier

what is current source capability?

Current Source capability = Amount of current it can supply (Also know as power). Op amps (which is what comparators basically are), will work fine, and you don't even need a complicated amplifier circuit. If you use it as a comparator it will probably work better.

The advantage of a transistor is size and cost. However the signal will get inverted in a standard common-collector setup (though you can always use 2 transistors). You forgot a pull up resistor in your transistor design.

So, now I have 3 choices, normal opamp, transistor(and I invert on code analogWrite(pin, ~value)) and comparator.

I know nothing about comparator. I supply 2 voltages and opamp output the greater? How do I wire to have 10v PWM from 5v?

There is one info missing - what you want to drive with the 10V pwm and how.. An LED or a speaker or a motor? That is important to know.. :P

It's a LED Driver. more specifically meanwell ELN60-48P.

if I give 5v PWM, it dim to 50%. I know PWM is digital, and this meanwell design is terrible. it's how it works. I need 10V amplitude PWM signal.

I found these 2 examples(transistor and opamp) and want to have answers before decide which one is better.

[quote author=Wagner Sartori Junior link=topic=228268.msg1649144#msg1649144 date=1395688838] So, now I have 3 choices, normal opamp, transistor(and I invert on code analogWrite(pin, ~value)) and comparator.

I know nothing about comparator. I supply 2 voltages and opamp output the greater? How do I wire to have 10v PWM from 5v? [/quote]

A comparator is just an op-amp set up to not try to amplify an analog signal but instead is working digitally. I don't have an easy circuit diagram handy but you can probably google one up. Basically the comparator (Which is an op-amp) will swing to the positive voltage rail (Vsupply+ on your op-amp) when the voltage on + > voltage on - and swing to the bottom rail (Vsupply-) when the voltage on - > voltage on +. Basically you would then put Vsupply+ to 10V, Vsupply- to 0V, and then set the voltage on - to around 2.5V with a voltage divider. You feed your signal into +. One of the other downsides of op-amps is they can be sensitive to noise without proper filtering since their inputs are high impedance, so if the environment is electrically noisy, then you could run into problems.

He had mentioned signalling, which to me indicates low current.

Another advantage of the op-amp is you don't have to swing between 0V and the rail current, you can set V+ and V- to whatever is allowed by the op-amp.

Sounds to me a simple NPN or PNP switch will do what you want.

It is not clear from the datasheet what current is required to drive the OCP (or what the input impedance of the PWM input is like). So I would use a NPN transistor with a collector resistor of 10k connected to 10V and from the collector I would go into the PWM input (your schematics is ok with 10k resistor in the collector wired to +10V source, from the collector go into the PWM input). Mind the NPN transistor inverts the duty cycle ratio.

[quote author=Wagner Sartori Junior link=topic=228268.msg1648955#msg1648955 date=1395682259] Hello folks,

I want to understand the best way to do a level shift from 0-5v PWM to 0-10v PWM. I made these 2 circuits attached. One using an opamp and the other using NPN transistor.

What is advantages/disadvantages of each one?

Thanks,

Wagner [/quote] Firstly the opamp circuit won't work unless the opamp positive supply is about 13V or more as the LM358 cannot drive to the +ve supply rail (only its inputs are rail-to-rail).

Secondly the opamp circuit is slow, nothing like logic speeds (the slew rate limit is, as far as I can tell about 0.6 V/us, meaning about 15us rise and fall times.)

The transistor circuit, with a good fast switching device will go to a higher frequency, but you need a pull-up resistor on the output to +10V, which should be 1k for fast response, but 10k will work for slower risetimes - assuming the receiving circuit doesn't require a low-impedance source.

As a side note, you may want to investigate a ULN2803 driver ( also needs a collector resistor ). On second hand, the o/p low might be too large.

with this exactly transistor circuit I first posted, It works fine without any pull-up. this is why I have 2 wires from led driver. one goes to 10v supply and the other to the transistor emitter.

I already tried ULN2803, it worked, but output voltage were lower than 10v, I think because of the diodes it has inside.

this is why I have 2 wires from led driver. one goes to 10v supply and the other to the transistor emitter.

You cannot connect the collector directly to 10V - that is wrong. It may work when your 10V power supply gives you few mA when shorted, otherwise you brick the transistor (or the meanwell as well) . You need a pullup resistor. What 10V power supply do you use??

it's a 12V walwart with LM317 regulated to 10v.

I just didn't understand why are you thinking I'm plugging 10v on collector. I'm not. PWM-10v is actually output to the other side of PWM Led Driver. Like GND-10V, PWM-10v is GND and the other leg is on 10v directly.

My current understanding of how to drive the Meanwell is following:
(provided as-is, no warranties of any kind)

dim.jpg

pwm.jpg

Usually you include everything in a schematic (like a block, resistor, lamp etc.) including the load element.

LarryD: Usually you include everything in a schematic (like a block, resistor, lamp etc.) including the load element.

yup, sorry for that!

pito: My current understanding of how to drive the Meanwell is following:

The main problem is that without an oscilloscope I can't see the signal and what my circuit is doing. I'll try to find one and take a look.

The main problem is that without an oscilloscope I can't see the signal and what my circuit is doing.

O'scopes vendors will like you :) Have fun!