Shop OBEX P1 Docs P2 Docs Learn Events
4-20mA output from Propeller... — Parallax Forums

4-20mA output from Propeller...

FORDFORD Posts: 221
edited 2007-02-13 17:24 in Propeller 1
Hi All,
Sorry if this is more hardware related, but I am looking at using a Propeller to control some valves which have a 4-20mA signal to set their position.

Can anyone point me to some links which would show the hardware required to produce a 4-20mA output.

Does having a 3.3v supply complicate things ?

Cheers,
Chris,
West Oz.
«1

Comments

  • OzStampOzStamp Posts: 377
    edited 2007-02-13 00:00
    Hi Chris

    There is a chip called an AD421·· this does the trick.
    Not sure if anybody carries this in stock in OZ but try Farnell RS and possibly Arrow Electronics.
    PDF file attached

    Ronald Nollet··
    Australia
  • FORDFORD Posts: 221
    edited 2007-02-13 00:39
    Thanks Ron,

    Will look into that...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-02-13 03:55
    Here's a circuit I remember from a Design Idea in one of the trades several years ago. It uses a triple opto isolator, like the Sharp PC817 series, available from DigiKey. It has the advantage not only of optoisolation, but of being able to either source or sink current, depending on the app. The receiver, of course, will have to provide the excitation voltage.

    The input is a single Propeller pin, driven by one of the counters' DUTY outputs. This is filtered to a voltage that ranges from 0 to 3.3V. The op amp drives the optoisolator LEDs in series, so each receives the same amount of current. The op amp's output voltage will have to be at least three LED diode drops above ground at max drive current. This will probably mean a 5V or greater supply voltage for the op amp. For 4-20mA output, the op amp's input common mode range will need to include 0.66V and 3.3V. For 0 to 20mA, the input common mode range will have to include ground. Depending on the op amp, it may also be necessary to add a transistor follower to boost its drive current to at least 10mA. This will also raise the op amp's Vdd requirements by another 0.6V to account for the transistor's VBE.

    The feedback for the op amp comes from one of the phototransistors. It will range from 0 to 10mA which, across the 3.3K resistor, results in a feedback voltage of 0 to 3.3V. The other two phototransistors are paralleled, which yields double the feedback current, or 0 to 20mA. These may be wired to the receiver in any fashion, consistent with the device limitations of the optical isolators.

    This circuit relies on the fact that three isolators in the same package will be farily well matched and will be subjected to identical temperatures. So the feedback current should accurately track the output current.

    I've never tried this circuit. But if I were going to produce a 4-20mA output device, this is where I'd start.

    -Phil

    Update: Added a link to the opto datasheet and additional requirements for the op amp.

    Post Edited (Phil Pilgrim (PhiPi)) : 2/13/2007 4:39:13 PM GMT
    747 x 460 - 5K
  • FORDFORD Posts: 221
    edited 2007-02-13 04:43
    Many many thanks Phil
  • bambinobambino Posts: 789
    edited 2007-02-13 14:30
    Phil,

    Is the Sharp PC817 the op-amp of you drawing or is your drawing a breakdown of the Sharp PC817.

    I too could benifit from a homegrown 4-20ma sensor conditioner. If I could beef it up to 11V output I could use it.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2007-02-13 14:39
    The sharp device is a quad opto-coupler, the op-amp is an additional device.

    Graham
  • bambinobambino Posts: 789
    edited 2007-02-13 14:46
    Any link to a datasheet for the coupler, all I get is salesmen.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-02-13 16:40
    Bambino,

    I added a link to the datasheet.

    -Phil
  • bambinobambino Posts: 789
    edited 2007-02-13 17:24
    Graham, Phil,

    Thanks, That definitly gave me something to chew on.
    The sensor conditioner sold with my accelorometers goes for $150 a hit.
    In the end we have always said we where going to build our own, And this gives me yet another way to do it. My other circuit relied heavily on precision resistors, transitors not readily available.
  • Phil linked to this thread from the isolated RS-485 thread.

    I wanted to give the circuit suggested by Phil above a try. I'm hoping to use parts I have on hand.

    For the optoisolators I was planning to use this chip.

    I have some LM3358N dual opamps purchased from Parallax. I'm hoping these will work well enough to test out the circuit. Here's a link to the datasheet.

    It looks like the voltage drop from the three opto isolator LEDs is 1.2V each giving a total drop of 3.6V. I figure the max current through the LEDs should be 20mA which leaves me with a 70 ohm resistor to limit the current through the LEDs from the opamp's output.

    I'm not sure what resistor to use between the Prop's I/O pin and the opamp's non-inverting input. I figured I'd try an 100 ohm resistor to start with and watch for smoke.

    I plan to use a 0.1uF cap on the non-inverting input of the opamp.

    I'll likely be back with more questions but in the meantime if anyone sees something wrong with my plan I hope you let me know. I'll check back before powering up the circuit.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-10-01 17:48
    Duane,

    When using the quad part, if you need high-voltage isolation, clip the four pins off of one of the middle isolators, and use the singleton on the end for your feedback. The reason for this is that all the isolators face the same direction, and you don't want pins from the two sides of the isolation barrier next to each other.

    There is a possible downside to this, though, in that the feedback isolator won't be in close thermal proximity to the others, and the CTRs may not track as well if there's a thermal gradient. If that's a problem, and you don't need high-voltage isolation, put the feedback isolator between the other two.

    -Phil
  • jmgjmg Posts: 15,173
    Important question: What precision does the OP need ?
    This circuit relies on the fact that three isolators in the same package will be farily well matched and will be subjected to identical temperatures. So the feedback current should accurately track the output current.
    That is simple, but the tracking will be modest - I'd guess not better than 5%.
    You have different voltage drop across the elements and that gives a different operating point, as well as different local heating. Lots of variables = poor precision.

    There is a Dual-Photodiode coupler, that is better suited to isolated-linear-feedback.
    (this needs an opamp on the secondary side)

    Search for
    dual photodiode linear optocoupler
    finds
    TIL300, IL300, LOC110, LOC210, HCNR200/201

    Data on those show .01% linearity, but they do need a calibrate pass to get better than 5% matching on the diodes. (std optocouplers will be much worse)
    LOC110 looks cheapest, with higher initial offset variance of roughly -30% + 20%
    K3 0.668 < 1 < 1.179
  • jmgjmg Posts: 15,173
    jmg wrote: »
    Important question: What precision does the OP need ?
    This circuit relies on the fact that three isolators in the same package will be farily well matched and will be subjected to identical temperatures. So the feedback current should accurately track the output current.
    That is simple, but the tracking will be modest - I'd guess not better than 5%.
    You have different voltage drop across the elements and that gives a different operating point, as well as different local heating. Lots of variables = poor precision.

    There is a Dual-Photodiode coupler, that is better suited to isolated-linear-feedback.
    (this needs an opamp on the secondary side)

    Search for
    dual photodiode linear optocoupler
    finds
    TIL300, IL300, LOC110, LOC210, HCNR200/201

    Data on those show .01% linearity, but they do need a calibrate pass to get better than 5% matching on the diodes. (std optocouplers will be much worse)
    LOC110 looks cheapest, with higher initial offset variance of roughly -30% + 20%
    K3 0.668 < 1 < 1.179

    Addit: Devices like Si8920 look to give isolation with much better out of the box precision, but they just manage 4mA Icc ceiling, and getting a current from the output structure looks difficult.
    Or, there are Digital Isolaters, that would allow a small MCU to operate the current sense side.
  • Thanks for the extra suggestions guys.

    We want pretty good precision. I'm not sure what the exact value is but I think less than a 1% error is desired in the current output. I think we would be willing to calibrate the device if it would improve the accuracy.

    I'm not so sure how this is going to work with these optoisolators. Even with 25mA running through the LEDs on the devices I don't get a full 5V output. There appears to about a 0.1V drop across the photo transistor.
    I see in the datasheet a "Collector-Emmitter Saturation Voltage" which is listed as 0.1V to 0.2V. Am I assuming correctly this is the voltage drop I'm seeing?

    I'm guessing the only way around this would be to increase the voltage to the collector?

    Again, pardon my ignorance but is the reference to "counters' DUTY output" suggest I setup a counter in a similar fashion as I would to produce a PWM signal?

    I used the code from the PEK to produce the output.
    PRI PwmCounterSingle | cycleTimer  
    '' Based on chapter 7 of the Propeller Education Kit (PEK).
    '' I copied what was done in chapter 7.
    '' Counters and I/O pin states should be set from within the cog
    '' using the counters and pins.
    '' See the value of "MAX_ALLOWED_FREQUENCY_SINGLE" for the
    '' maximun frequency possible with a single channel.
    
      ctra[30..26] := %00100        ' Configure Counters to NCO                   
      ctra[5..0] := enablePins[MOTOR_A]
      frqa := 1
    
      dira[enablePins[MOTOR_A]] := 1
    
      cycleTimer := cnt             ' Mark counter time
      repeat                        ' Repeat PWM signal
        phsa := -pwmOnTime[MOTOR_A] ' Set up the pulses 
        cycleTimer += pwmTime       ' Calculate next cycle repeat
        waitcnt(cycleTimer)         ' Wait for next cycle
    
    

    Am I on the right track with the code to drive the non-inverted input on the opamp?

    As always, I sure appreciate the help you guys provide. Thank you very much.
  • DUTY mode is not the same as PWM. The mode value for DUTY output is %00110. it requires no additional code to maintain, and it's easier to filter than PWM. The filtered output voltage is proportional the the value in FRQx.

    -Phil
  • jmgjmg Posts: 15,173
    Duane Degn wrote: »
    I'm not so sure how this is going to work with these optoisolators. Even with 25mA running through the LEDs on the devices I don't get a full 5V output. There appears to about a 0.1V drop across the photo transistor.
    I see in the datasheet a "Collector-Emmitter Saturation Voltage" which is listed as 0.1V to 0.2V. Am I assuming correctly this is the voltage drop I'm seeing?

    This is designed for Current Out, so you want to avoid the saturation region of the Isolators.
    If you want to turn 4-20mA into 1-5V with a 250 ohm load, you will need headroom of 7-9v.
    Avoid too much headroom, or the optocouplers will drift more, as they warm up.


    Better is the Dual photodiode design which does not push thermal or V-I curves or Hfe changes...

  • jmg wrote: »
    If you want to turn 4-20mA into 1-5V with a 250 ohm load, you will need headroom of 7-9v.

    I should have known this. Thanks.

  • jmgjmg Posts: 15,173
    edited 2015-10-03 00:31
    jmg wrote: »
    If you want to turn 4-20mA into 1-5V with a 250 ohm load, you will need headroom of 7-9v.
    Avoid too much headroom, or the optocouplers will drift more, as they warm up.

    Looking some more at this issue, to allow the conventional 24V region supply on 4-20mA,
    maybe a 1 part addition is a Depletion mode MOSFET

    http://www.infineon.com/cms/en/product/power/power-mosfet/small-signal-mosfet/60v-600v-n-channel-depletion-mode-mosfet/channel.html?channel=ff80808112ab681d0112ab6a586204b8

    that gives a low and somewhat stable voltage across the opto-trx, but would allow 9-24V plus in the system design.
    20V & 20mA is 400mW, which is best not in the opto device.

    Seems you get bands of Vgs, per reel (or tape), on the BSP149H6906
    For BSP149, best is -1.4V @ 10mA, but you might get -0.7V @ 10mA
    Vgs varies about 180mV with a 5:1 current ratio,, so is quite consistent on a load line.
    Also varies ~ -2.5mV/°C

    Using two BSP149, one on each side, would further improve the balance & drift more as the Opto devices then have very similar Vce trackings, that also batch-track.
    Of course, that does cost a little more.

    A cheap quad Isolator, with > 100% CTR is TLP293-4(V4-GB,E - but has no matching specs on elements. Quad would allow 6.66mA peak current per opto node as 1+3.

    Vishay ILQ615 commits only to
    Channel/channel CTR match IF = 10 mA, VCE = 5 V CTRX/CTRY better than 2 to 1

    The Toshiba parts look to be well ahead of others on Temperature flatness, so a calibrate step on those, with 2 x BSP149, looks the best PhotoTransistor-coupler based design.

  • Duane, I missed why you came here from the isolated RS232 thread. An accurate but non-isolated 4-20mA converter can be built with a simple op-amp circuit, with duty mode input. To add isolation, it might be easier to run the duty mode or pwm input through a digital isolator, rather than to isolate the analog side.

  • I meant to attach a diagram...
    631 x 361 - 17K
  • We previously used a XTR111 for the 4-20mA but this wasn't isolated.

    I mentioned the 5V regulator aspect of the XTR111 in this post (includes a link to datasheet).

    My boss would like to have both the RS-485 and the 4-20mA isolated. I originally thought we could just use a digital isolation on the DAC used to control the XTR111 but this same DAC is used to generate a 0-5V output. If the DAC were moved to the isolated section of the circuit I don't think we couldn't use it to set the 0-5V output any longer. My initial thought was to just use a second DAC. One on each side of the isolation.

    In case it's not obvious, this stuff is outside my comfort zone. I'm just trying to familiarize myself with these various options so I can hopefully sound a bit more educated when I talk to my boss (who will also likely read this post).

    The XTR111 circuit worked well (after a bit of trouble shooting on my part). I was thrilled to figure out what was going on enough to find the problem with the earlier circuit and once the glitch was fixed it worked great. Part of me wants to stick with the XTR111 since I kind of understand how it works (magic). But if there's a better way to produce the 4-20mA output I'd like to learn what these options are.

    We'll have a 24V supply to the sensor with a 5V switching regulator with a portion of the 5V dropped to 3.3V with a linear regulator. From what I understand, we want to isolate the RS-485 line which I believe includes using a separate ground for RS-485 output (thanks to the other thread, I think I've kind of got this figured out). The 4-20mA driver will have an option of being powered externally. A jumper will be used to set the power source of the 4-20mA circuit. I believe when the 4-20mA circuit is powered externally, the supply will also be 24VDC but not necessarily referenced to the same ground as the main power supply. I think a lot of this sort of stuff is common knowledge to those working with industrial sensors but it's not common knowledge to me. (I was hired to program the firmware.)

    As I mentioned, I have a slight bias to the XTR111 circuit since I have some experience with it but I'd really like to understand the various options available. I think I'm repeating myself now so I'll stop.

    Again, thanks for all your help guys. I think this stuff is a lot of fun and it's thanks to this forum I know as much as I do.
  • jmgjmg Posts: 15,173
    Duane Degn wrote: »
    ... Part of me wants to stick with the XTR111 since I kind of understand how it works (magic). But if there's a better way to produce the 4-20mA output I'd like to learn what these options are...
    TI have a range of parts, some similar to XTR111 with fewer added parts.
    They also have DAC161P997/DAC161S997/DAC8760 series with serial in, which could be isolated, with better precision than multiple optocouplers. (but also a higher price...)

  • ... it might be easier to run the duty mode or pwm input through a digital isolator, rather than to isolate the analog side.
    True enough. You just have to make sure that the digital isolator can handle the DUTY/PWM frequency (max = 40 MHz for DUTY) and that the rise times and fall times are equal.

    -Phil
  • If you want to make life easy use a AD694 transmitter ic. You'll have to drive it with Dac like a MCP4922 but you will get precise 4-20 control. Believe me I ran the gambit of making my own using the lm339's, 2n2222, with a reference etc. The AD694 is a little pricey (I think about $14-$16 ) but we'll worth it for the precise control and ease of set up and configuring.
  • ... it might be easier to run the duty mode or pwm input through a digital isolator, rather than to isolate the analog side.
    True enough. You just have to make sure that the digital isolator can handle the DUTY/PWM frequency (max = 40 MHz for DUTY) and that the rise times and fall times are equal.

    -Phil

    And true enough again. Conventional PWM from the prop at a more relaxed speed would be far easier to handle. Even a though a high speed optocoupler like the Toshiba TLP117 lays claim to equal output rise and fall times of 3 ns, the skew in propagation delay can be as much as 16ns.

    Another approach, I've used the Silicon Labs SI8600 i2c buss isolator for interface to a high resolution ADC for input from resistance bridge circuits used in hydrology (subject to ground conduction). That could just as well tie into a 4-20mA output scheme. However, with isolated supplies etc. etc., these things do end up with quite a few parts on a circuit board.

  • jmgjmg Posts: 15,173
    edited 2015-10-03 21:31
    Another approach, I've used the Silicon Labs SI8600 i2c buss isolator for interface to a high resolution ADC for input from resistance bridge circuits used in hydrology (subject to ground conduction). That could just as well tie into a 4-20mA output scheme. However, with isolated supplies etc. etc., these things do end up with quite a few parts on a circuit board.

    Yes, seems there are two levels of choice :
    Full digital with 4-20mA side 16b DAC & ref, can get well under 1% error, but with a PCB area and BOM impact (isolated PSU often also needed).

    The Photocoupler design above has a simplicity appeal, (no PSU or steps) and I think with careful choices and a design-pass boost to remove the main error sources, could be useful for modest 4-20mA apps.

    ie Opto: TLP293-4{GB} + 2 x dmMOSFET BSP149H6906 => Sub $1.50 BOM
    and needs a Calibrate pass once assembled. Drift may get < 1% here ?

    Should be easy to mockup and test, just 3 parts and resistors and a variable power supply to check common mode tolerance.

    Certainly anything in a control loop is not so absolute tolerance critical.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-10-03 21:54
    Another option would be to add a cheap 6- or 8-pin micro with analog or PWM output to Tracy's circuit. The micro would accept serial data over a cheap opto like the H11L1. You'd need a regulator for the micro, but no crystal. Auto-baud detection would keep things in sync. Of course, things would have to be arranged so that the micro's current consumption is less than 4mA and figures into the overall output current.

    -Phil
  • jmgjmg Posts: 15,173
    Another option would be to add a cheap 6- or 8-pin micro with analog or PWM output to Tracy's circuit. The micro would accept serial data over a cheap opto like the H11L1. You'd need a regulator for the micro, but no crystal. Auto-baud detection would keep things in sync. Of course, things would have to be arranged so that the micro's current consumption is less than 4mA and figures into the overall output current.
    True - a device like EFM8BB1 is ~ 30c, and has 12b ADC and can get under 1mA, the H11L1 is fast, but specs 5mA max operating so a design would have to rely on typical values (or use a slower opto).
    The EFM8BB1 has a ~ 2% reference error, and 50 ppm/°C & 400 ppm/V, so a non-calibrated starting point of an ADC tracked PWM+MOSFET would be around 2%, but the EFM8 could store calibration value easily, to push down toward 0.1% error region, and it can linearize for free....

    It could manage multiple 4-20mA channels easily 3 x 11b PWM is a natural limit.

    The Opto+dmMOSFET would be much faster, should be < 10us response times (not that I've had any 4-20mA designs that needed sub-ms responses )
  • If you want isolation try the avago HCNR 201. However I did not find their 4-20ma circuit to be very precise. But you could still use it as a precision analog isolation amplifier.
  • jmgjmg Posts: 15,173
    DigitalBob wrote: »
    If you want isolation try the avago HCNR 201. However I did not find their 4-20ma circuit to be very precise. But you could still use it as a precision analog isolation amplifier.

    Yes, that is the Dual-Photodiode coupler mentioned above.
    Those come with 5% (or 15%) matching, but good linearity, so the 5% can be calibrated out.

Sign In or Register to comment.