# Problem with optoislated PWM signal

First of all sorry for my english,

I need to control a frequency inverter with 0-10v signal. Due to the noise of the inverter and motor I need an optoisolated output, and I have made the attached circuit. I connect the PWM of arduino to 4N25 optoisolator through an 390ohm resistor. I connect the output of 4N25 to an RC filter (the filter is slow but it work OK), but I have no 0-10v voltage at the output. ¿Has anybody any idea about if I’m doing somethig wrong?

As the circuit stands, there is no discharge path for the capacitor other than through the load (i.e. the input that accepts the 0-10V signal). So you will always get almost 10V output except when the PWM is zero. Try connecting a 2.2K resistor between pin 4 of the optoisolator and GND2.

The 4n25 has quite a low current transfer ratio, so you may need to decrease the 390 ohm resistor to 180 ohms to get it working properly.

Does the datasheet for the device that needs a 0-10V control signal say what its input resistance is?

just wondering if there has been any success with this mod to the circuit and does it work? i only ask because im trying to do the same but my method is much more complected (using an op amp)

Hi,

Thank you very much dc 42!. The problem is exacltly what you explain (there is no discharge path for the capacitor). Adding a 2,2k resistor I have a variable output depending on the pwm value, but not an 0-10V value. I thought a new design (attached) tha cen be works as I expected, and I want to know if somebody can give me a feed back before construc it.

The idea is to use other 4N25 (U3) for invert the signal of PWM, and give this inverted signal to 4N25 (U2). When the PWM of arduino is High U1 charges the capacitor, and when the PWM of arduino is low U2 gives a path for discharge the capacitor directly to GND.

Jonisonvespaa, I think that the circuit wit an opamp is more easy (I have do it and it works really fine), but I have a noise problem. My circuit regualtes an inverter with temperature sensors DS18B20, and when I connect the inverter and motor, I lose the temperatures from DS18B20. For do it I connect an RC filter at the output of the arduino’s PWM output for get an analogic 0-5V signal. After that I connect this signal to an opamp for get 0-10V. If you need more detail ask me.

Have a nice day!

Miquel

You need seriese resistors in line with those LEDs in the opto isolator. While it looks like it would work it is not the way to go about things. Just use a PNP and NPN transistor and drive that with a single opto isolator.

You don’t need 3 opto isolators, you only need 2. If you have a spare output pin, you can use the attached schematic. Drive the pin marked Dout HIGH after initializing the PWM pin.

thanks a lot!

Grumpy_Mike, sorry, but I don't know how to connect a PNP and NPN transistors to drive an optocoupler... :blush:

DC42, Obviously your circuit is 100 times better than mine... I will construct it and I will give a feed back.

Miquel

No you drive the two transistor's with the opto isolator not the other way round, in a simple class B configuration or a push pull output or a half h-bridge configuration, they all mean the same thing.

I believe that what GM means is this. One less pin and one less optoisolator than the solution I proposed. You’ll need to supply it with nearly 12V to get the full 10V output.

thank you again!. Also a great solution!

I will check both circuits. I do not know too much about transistors… ¿do you know references for this NPN and PNP transistors that can works?

Miquel

do you know references for this NPN and PNP transistors that can works?

It depends on the current you want to switch but for currents below 100mA then any transistor will do. Search your local suppler for the cheapest general purpose transistors.

Hi dc42,

I'm thinking in your circuit... ¿Is it possible to use a fix 5V from Arduino instead of Dout?

Thank you,

Miquel

Hi GM!

I'm trying understand your circuit. Following the schamatics of dc42:

• when PWM is high the optocoupler gives 10V to both transistors, so they conducts current. If i'm not wrong, at this moment there is a short circuit between 10V and 0V.

• when PWM is low, any transistor conducts current, so there is no path for discharge the capacitor.

Provably there is something that I don't understand correctly, otherwise it didn't work.

Thank you again.

Miquel

miquel333: Hi dc42,

I'm thinking in your circuit... ¿Is it possible to use a fix 5V from Arduino instead of Dout?

The problem with doing that is that when power has been applied to the Arduino but the pin mode for the PWM pin has not yet been set, both opto isolators will have forward current, so both of the output transistors will pass current. While there are ways to ensure that the current they pass is not too great to cause damage, the other problem is that your 0-10V output has an undefined voltage during this time. That might not be acceptable to you.

As for the transistors, commonly-available suitable transistors include BC337 or 2N3904 for the NPN, and BC327 or 2N3906 for the PNP.

Hi dc42

I understand. But... if I'm not wrong this is the same situation than occurs when PWM is low:

When PWM is High there is no voltage in the up side optocoupler of your schematics. When the PWM is Low, 5V from Dout are divided between 2 optocouplers, so both will pass current with consecuently short circuit