I'm trying to generate a 0-20mA signal for controlling an industrial actuator (the position of a 3-way valve) from a Teensy 3.2 system. Preferably, the mA-output should be galvanically isolated from the microcontroller to protect it properly.

In order accomplish that, I currently have a setup, where I am sending a PWM signal (at ~488Hz) from the teensy through a 4N26M optotransistor (4N26M datasheet).

The output of the 4N26M is sent through a RC filter into a TI XTR117 Current Loop Transmitter (XTR117 datasheet). This chip controls the current in a separate current loop sourced from a 24V PSU coupled in series with the actuator, which is controlled with the current signal. I measured an internal resistance of 100 ohms in the actuator. According to the datasheet, the XTR117 generates an output current which is a factor 100 higher, than the input current going into (pin 2) I_in. Therefore, the input on pin 2 needs to be between 0 mA and 20mA/100 = 0.2 mA to provide an output of 0-20mA.

The XTR117 features a regulated 5V line (V_reg) on pin 8 relative to pin 3 (I_ret). A pull-up to this line ensures a 5V output of the optocoupler, when it is in the ON mode.

The collector to emitter saturation voltage of the optotransistor is 0.5V according to the datasheet. When the optotransistor is "open", a voltage of 4.5V at pin5 of the 4N26M is expected. This means, that a current through R3 and R4 in the RC filter at 4.5V/22.5kΩ = 0.2mA is expected, which means an output of 100*0.2mA = 20mA in the main current loop. See the schematic below: Schematic

However, there are two problems in the circuit:

  1. When the PWM duty cycle is 100% (LED on in optocoupler) an output of approx. 2mA is generated, and not 0. I suspect that this is due to the saturation voltage of 0.5V in the optocoupler. At 0.5V, the current into XTR117 pin3 should be 0.5V/22.5kΩ = 0.02mA which should correspond to 100*0.02 ≈ 2mA on the output side. However, I can't think of a good design to avoid this scenario. What can be done?

  2. When the duty cycle is 0% (LED off), a measured output of 19.9mA is generated, which is acceptable in this scenario. However, the signal seems to be unstable, as the controlled valve is turning a bit back and forth all the time. But when I touch with a finger at the joint between R3 and R4, the problem is not visible (valve position is stable). This effect can be replicated every time. So what is the effect of touching it, and how can I implement that in the circuit?

I hope I'm making sense! Also, if you suggestions for completely different components, which can generate the desired signal, they are more than welcome!


2 Answers 2

  1. Add a CMOS logic gate after the optocoupler/R2. That will buffer the output and the voltage will be more accurate and the time constant will be the same for on vs. off.

  2. split R4+R3 approximately evenly (11K-ish) and put the capacitor to IRET in the middle. You're not really filtering the current input well by putting the capacitor where it is. The time constant will be the parallel combination of the two times the capacitance, so about 5500 ohms * 1uF or about 5 or 6ms. Adjust capacitance as required. I'm guessing 47uF or 100uF might be a better choice for a mechanical valve actuator. You probably want the ripple to be less than the hysteresis in the actuator control loop.

  3. Consider replacing the optocoupler with a logic-output type (eg. 6N137) which will be much faster (so a more true representation of the PWM on the isolated side), but retain the above two suggestions (unless the optocoupler has a CMOS output- the cheaper older ones tend to be bipolar).

  4. If you use the logic output optoisolator, you might want to consider upping the PWM frequency to a few kHz to reduce the size of the filter capacitor so a ceramic part can be used (and it will respond a bit faster).

  • \$\begingroup\$ Thanks a lot for your answer! I don't quite understand why splitting R4+R3 evenly and putting the cap in the middle provides better filtering - can you maybe elaborate on that? (Just for the sake of understanding. I'm not an electronics engineer :-) ) \$\endgroup\$ Jan 10, 2020 at 9:49
  • 1
    \$\begingroup\$ capacitors smooth signals by resisting voltage changes, the voltage change at the Iin pin is very small, so the capacitor can't smooth it out much, \$\endgroup\$ Jan 10, 2020 at 23:48
  • \$\begingroup\$ Jasen's explanation is good for intuitive feel, plus consider mathematically if it's the parallel combination of the split resistor parts it will be maximized (for a given total resistance) when the resistor is split in two and minimized when either part is zero. If one resistor is R*(1-a) and the other R*a for 0 <= a <=1 then Rp = a*(1-a)*R, which is maximized when d/da(Rp) = 0, which is when a = 0.5. \$\endgroup\$ Jan 11, 2020 at 0:38

The problem is that the optocouipler current must flow from the vreg of the controller. 5V into 2.3K is about 2mA. that current is comiing from the 4-20mA loop - so there's your minimum 2mA

to fix:

Swap the opto-coupler output and R2

This will invert the sense of the optocoupler, so that when the optocoupler is off it calls for less current in the loop, but now it's backwards to how it was. You can cure that in software, or:

re-wire the optocoupler input to be between +5V and R1 instead of between R1 and ground.


simulate this circuit – Schematic created using CircuitLab

A neat thing about optocouplers is that don't need to be grounded on either side.

Now with the PWM at 100% the optocoupler is off and no current is taken from Vreg, this causes Iin to go low turning off the loop current.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.