Shop OBEX P1 Docs P2 Docs Learn Events
RS-232 to 4-20ma Current Loop: Quick RS-232 side question — Parallax Forums

RS-232 to 4-20ma Current Loop: Quick RS-232 side question

xanatosxanatos Posts: 1,120
edited 2012-10-31 05:48 in General Discussion
Does a current loop converter (232 to 4-20) require a continual refresh of the RS-232 data, or is it a send once and shut up until a new level setting is required? In other words, do I need to continually loop with a SEROUT to maintain the 4-20 output, or just when the sensed signal on the stamp-side of things changes? My stamp is driving the 4-20 converter, and it's a one-way communication).

Thanks!

Dave

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-10-30 11:30
    In one state it should be pushing 4 mA and in the other state it should push 20 mA. So, one is default/idle/mark and the other is space.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-30 11:42
    I have never understood 4-20ma current loops. I'd love to hear more from PJ.
    As absurd as it might seem, I did not know it was two states -- or binary. I thought it was some sort of calibrated analog communications. Does it have a bit rate?

    Or is it more akin to pulse wide modulation?
  • localrogerlocalroger Posts: 3,452
    edited 2012-10-30 11:46
    You are confusing 4-20mA, which is an analog signal, with 20mA mark/space which is digital and uses the same timing as RS232. The 4-20 signal actually goes to a D/A converter, then the receiver uses an A/D converter to recover the signal.

    The answer to Xanatos' question is highly device specific. It could be implemented either way. Holding the last received value is the easiest thing to do but in some applications you'd want a timeout to prevent a held value from being assumed true if comms are lost. That in turn might be configurable.
  • JordanCClarkJordanCClark Posts: 198
    edited 2012-10-30 11:53
    Ones that I've used in a previous life have been set-and-forget. Once the value was in it's register, that's the one it would use until changes our the power was cycled.
  • JordanCClarkJordanCClark Posts: 198
    edited 2012-10-30 12:01
    I have never understood 4-20ma current loops. I'd love to hear more from PJ.
    As absurd as it might seem, I did not know it was two states -- or binary. I thought it was some sort of calibrated analog communications. Does it have a bit rate?

    Or is it more akin to pulse wide modulation?

    Sorry, my post was later than yours, which fell off the screen!

    No bit rate or PWM to a signal like this. It's a scaled analog value. An example may be a transmitter for a thermocouple that would transmit 4mA at 40 degrees and 20mA at 250 degrees. Current loops are popular because they tend to be more noise immune than voltage loops over longer distances.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-30 12:19
    Thanks, it all makes sense to me now. It was just when this conversion to RS-232 from 4-20 ma was mentioned that I began to wonder if I'd been completely wrong. Current immunity to noise certainly makes sense as it has a kind of momentum behind it. Voltages can so easily spike from electromagnetic influences.
  • stamptrolstamptrol Posts: 1,731
    edited 2012-10-30 12:27
    I still think theres a measure of confusion circulating in this thread.

    Reading the OP, it looks like its a serially controlled 4-20 mA interface. Send it a serial string and the output would be maintained at some analog level between 4mA and 20mA until reset to another level.

    The other device mentioned (more commonly called a 20mA current loop converter) is used to transmit serial data in electrically noisy environments. The rs-232 signals are converted to a data stream of 1's and 0's corresponding to 0mA and 20mA. It is also possible for the 0mA to be some slightly higher value (4mA) so that it is easier to tell if no signal is caused by a low bit or a broken wire(open circuit).The receiver runs the current through a resistor and turns the resulting voltage mark/space into a serial string.


    B&B Electronics' website has numerous technical articles on everything in digital communication.

    Cheers,
  • xanatosxanatos Posts: 1,120
    edited 2012-10-30 12:31
    Hi all, thanks! Yes, this is as I understand it a digital to analog type of thing. I'm monitoring a tank fill level. The data I send to my 4-20ma converter initially comes to me as a measurement of inches, which I convert to a percentage of full, basically (0% to 100%) and then as I understand it, I will send whatever RS-232 data I need to send to teh converter so that at 0% I am outputting 4ma, and at 100%, I am outputting 20ma.

    The converter I am using is here: http://www.l-com.com/item.aspx?id=6981

    I'm hoping it's set-n-forget... :-)

    Dave
  • stamptrolstamptrol Posts: 1,731
    edited 2012-10-30 12:43
    The converter you link to will not do what you want. It is the 20 mA current loop device I mentioned in my post.

    Essentially what you want is an analog-to-serial converter. Your level goes in one side from the level transducer and a serial string comes out the other side. If this is a hobby project, it will be cheaper to use a Stamp and an a/d converter chip (LTC1287) than find a suitable commercial product.

    Feed the 4-20mA through a 250 ohm resistor to generate a voltage. Get the Stamp to read the voltage and send out a serial string as the analog level changes.

    Cheers,
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2012-10-30 12:51
    Hi All;

    Any of the current loop and particularly the 4-20mA version is very immune to noise and often used in industrial environments.
    The best way to implement these is to have a power source, often 24V, at one location, usually the master location. The loop is twisted pair wire.

    Noise pulses hitting the twisted pair wire inductively couples equally to each wire in the pair, effectively canceling the noise.

    Duane J
  • xanatosxanatos Posts: 1,120
    edited 2012-10-30 13:10
    stamptrol wrote: »
    The converter you link to will not do what you want. It is the 20 mA current loop device I mentioned in my post... Cheers,

    Hi Tom,

    Actually, it's the other way around - I need to send the RS-232 out to the converter. I'm not receiving the current loop, I'm sending on it. Are you saying the converter I've specified does teh mark-space thing and not the level thing?

    Dave
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2012-10-30 13:49
    Hi xanatos;
    xanatos wrote: »
    Actually, it's the other way around - I need to send the RS-232 out to the converter. I'm not receiving the current loop, I'm sending on it. Are you saying the converter I've specified does teh mark-space thing and not the level thing?
    I read the datasheet.
    It looks to me these are not the analog 4-20mA type.
    They are used to communicate digitally in Full duplex , 19.2Kbps up to 4000ft.
    Definitely not analog, as I see it.

    Duane J
  • xanatosxanatos Posts: 1,120
    edited 2012-10-30 13:56
    Of course, I've only been *assuming* that I'm interfacing to the analog 4-20 ma current loop... I'm waiting to hear back tomorrow on what type of "PLC" I'm talking to with this thing. All he knows for certain is that it's a 4-20ma current loop interface. I interpreted that to mean analog.... but right now, I'm waiting for confirmation. I put the L-Com order on hold, though, just in case! :-)

    Thanks folks,

    Dave
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2012-10-30 14:13
    Here is a link that has analog types.
    A/D and D/A
    There are probably many others.

    Duane J
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-10-30 14:26
    Here's one that converts RS232 or RS485 data to an isolated 4-20ma or 0-10V output, using a choice of several protocols:

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2012-10-30 14:31
    @xanatos

    That RS232 to Current Loop Converter is definitely not what you need to do what you describe in post #9. It converts the digital data represented by the + and - RS232 voltage levels to digital data represented by 0 mA and 20 mA current levels.

    What you need is a D/A converter that produces 4 mA at 0% and 20 mA at 100%. A current output D/A will do that, but you will have to do some math.
  • localrogerlocalroger Posts: 3,452
    edited 2012-10-30 16:41
    Xanatos, both "four to twenty milliamp" (scaled analog) and "twenty milliamp" (digital) are regularly shorthanded to just "current loop." That "four to" is important. If you are communicating with a PLC there is about a 99% chance that what you wil need is the 4-20 analog version.

    On that wayjun site this is the device you will need:

    http://www.wayjun.net/index.php?main_page=product_info&cPath=3&products_id=41&zenid=0b4262bd26c8d8c6c3ba3764b806af98

    You will need to hook it up to a terminal for bidirectional communication to set it up, as described in the manual. Setup is a bit obscure but once you get it configured you can blindly send it output level commands in set-and-forget mode. I strongly recommend setting it up with a terminal and sending it commands while you watch the output with a milliameter to get a feel for how it works. As described above, when you send "zero" the output should read 4 mA, and when you send it "max capacity" it should read 20 mA. You can just hook the milliameter directly across the current loop output terminals.

    In the field, you may need to calibrate the levels so that the PLC reading agrees with what you intend to send. That will probably be easier to do at the PLC end; you'll want a test mode where you can force zero and full-scale for this purpose.

    Coincidentally I just did this in the other direction, with one of their products that takes the 4-20 signal and converts it to digital. It doesn't broadcast -- I have to poll it for the current reading.
  • jmgjmg Posts: 15,183
    edited 2012-10-30 17:43
    xanatos wrote: »
    Of course, I've only been *assuming* that I'm interfacing to the analog 4-20 ma current loop... I'm waiting to hear back tomorrow on what type of "PLC" I'm talking to with this thing. All he knows for certain is that it's a 4-20ma current loop interface. I interpreted that to mean analog.... but right now, I'm waiting for confirmation. I put the L-Com order on hold, though, just in case! :-)

    Perhaps if you clarify what bits you are in charge of, and what you are given, and what you need to talk to.
    So far I have decoded Tank Fill on one end and PLC on the other.

    Tank fill implies a Sensor with ?? output, and PLC will most likely expect a linear 4-20mA Analog value.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-10-30 19:04
    It never ceases to amuse me that, in some control environments, perfectly good digital sensor data has to get converted to -- and communicated as -- analog before it gets reconverted back to digital for use by a PLC. There are serial protocols available to eliminate this analog two-step, yet entrenched systems persist to this day.

    -Phil
  • stamptrolstamptrol Posts: 1,731
    edited 2012-10-31 03:52
    If an industrial PLC is involved, its quite likely the converter you'll need will be the analog output variety. Clarity from your client is needed.

    Again, the device you referenced is for digital communication. Some of the most recent posts describe the device you'll need.
  • localrogerlocalroger Posts: 3,452
    edited 2012-10-31 05:48
    It never ceases to amuse me that, in some control environments, perfectly good digital sensor data has to get converted to -- and communicated as -- analog before it gets reconverted back to digital for use by a PLC. There are serial protocols available to eliminate this analog two-step, yet entrenched systems persist to this day.

    If you have ever tried to get that sensor data into a PLC you'd understand why analog persists. It's the only universal standard. You don't have to worry about baud rates or worse protocol tics or parsing or repeat rates or timeouts. Solutions to the all-digital route have been tried, and none has gained universal traction; everything is particular to either a manufacturer (e.g. modbus) or an industry (e.g. SMA). If you want to be SURE some random industrial controller will read your output, you will provide it in analog form.
Sign In or Register to comment.