4-20mA Analog Output

  • Hi all!


    I just added a Beckhoff EL4024 module for analog outputs (4-20mA) to the EK1100 coupler inside KRC4.
    In that sense, seems that it's working fine: ANOUT= 0.0 gives 4mA; ANOUT = 1.0 gives 20mA.


    The thing is, from what I have read, KSS lets you any value from -1.0 to +1.0 to any ANOUT.
    In my mind, that makes sense if you have a 0-10DC module, as it goes from -10 to +10V.
    But do negative values make sense for mA? What could/should happen if I set -1.0?
    It might be a very basic question, but I didn't want to try before asking.


    Thanks!


    PS: KRC4 // KSS 8.3 // WV 4.0
    PS2: I haven't been able to find any similar post regarding this question. Apologies if it's repeated.

  • Place your Ad here!
  • It depends on the device you've connected. I've never seen a mA analog module that is bipolar, but they may exist. There are definitely Voltage output modules that can go + or -.


    The trick is that, for any analog FieldBus module (either input or output), the analog value is converted into a digital equivalent for transmission over the bus. Just how this occurs depends on the specific module.


    For example, a 12bit 0-10V module (unipolar) might ignore the sign bit entirely, or incorporate it into the entire I/O word. An unsigned 12bit value maxes out at 4095, so the resolution of the module would be 2.5mV.


    OTOH, a 12bit -10 to +10 module from the same manufacturer would use the 12th bit as the sign bit, meaning the integer word would swing from -2047 to +2047 (with some caveats for different encoding schemes), so the resolution would be 4.8mV.


    The math works the same for any analog module attached to a KRC's ANOUT or ANIN. The encoding differences for the different bit ranges and voltage/current ranges is handled at the bus/module configuration level. When set up properly, the full scale of the analog module (5V, 10V, 20mA, whatever) should map to a simple 0-1.0 or -1.0 to +1.0 ANOUT/ANIN value.


    Basically, you can treat the ANOUT/ANIN values as a % of the maximum signal of the analog module. A 10V module should put out 5V for an ANOUT of 0.5, and a 5V input module should report an ANIN of 0.5 when detecting 2.5V.


    Sending a negative value to a module that accepts only positive values could have unpredictable results. Not "blow up" unpredictable, just mathematically unpredictable. It depends both on the module, and on exactly how you configure the module's conversion factor in IOSYS.INI or in the I/O mapping of WorkVisual.

  • Thank you so much!


    Quote

    The math works the same for any analog module attached to a KRC's ANOUT or ANIN. The encoding differences for the different bit ranges and voltage/current ranges is handled at the bus/module configuration level. When set up properly, the full scale of the analog module (5V, 10V, 20mA, whatever) should map to a simple 0-1.0 or -1.0 to +1.0 ANOUT/ANIN value.


    Quote

    It depends both on the module, and on exactly how you configure the module's conversion factor in IOSYS.INI or in the I/O mapping of WorkVisual.


    Where could I check /set that? What I've done is get the .xml from Beckhoff -> DTM, add it to the project, map signals from Fielbuses and deploy/activate project.
    I can see the attached image when I open the module settings.



    Quote

    Sending a negative value to a module that accepts only positive values could have unpredictable results. Not "blow up" unpredictable, just mathematically unpredictable.


    Does it mean I'm safe to try out a negative value and check w/ the multimeter?


    Again, thanks for the help.

  • Well, when you grouped the signals in WV, did you set them as I/O, INT, UINT, DINT, etc?


    For some bipolar devices, the MSB is the "sign" bit and the other bits are "magnitude", so (for a bipolar 16bit device) a binary value of 1000000000000001 is the same as 000000000000001, just opposite polarities. Assuming a +/-10V device, this would be -0.009mV and +0.009mV, respectively.


    However, some devices encode differently -- 1000000000000001 would -10V, and as the binary value "below" the sign bit gets bigger, the analog value decreases, so 1111111111111111 would be -0.009mV.


    That's what I meant about "unpredictable" behavior -- if you send a negative value to your unipolar device, just what would come out would depend on which encoding it was expecting you to use.


    For testing, I usually just make a program that increments the ANOUT by one bit at a time (I usually map my analog devices as digitals, so I can directly control the "raw" binary), and record the output on a multimeter at each step. Then I plot both values against each other in a scatter plot in Excel, or something similar.


    For analog inputs, pretty much the same, except I wire a potentiometer into the input and slowly dial it up/down, while recording the ANIN and the multimeter reading, for a similar plot.


    That will usually show me pretty quickly how the combination of the device and WV configuration behaves.

  • Cool, thanks!


    Quote

    Well, when you grouped the signals in WV, did you set them as I/O, INT, UINT, DINT, etc?


    I totally missed that row in I/O mapping! :icon_eek:
    Changing it to UINT would make it.



    Quote


    For testing, I usually just make a program that increments the ANOUT by one bit at a time (I usually map my analog devices as digitals, so I can directly control the "raw" binary), and record the output on a multimeter at each step. Then I plot both values against each other in a scatter plot in Excel, or something similar.


    That's interesting! And makes a lot of sense.
    The thing is WV lets me assign WORD, as well as SINT/USINT and INT/USINT, but I don't know against which output should I map it.
    Analog Outputs let me choose only SINT/USINT & INT/UINT.

  • Yeah... the WV docs don't go into any detail concerning exactly how SINT/USINT/DINT/etc are defined at the binary level. And I usually didn't want to be bothered with it, so I usually went for "raw" I/O and did the encoding/decoding in KRL, did everything in "digital," and avoided the ANIN/ANOUTs almost entirely. Probably not the most elegant way to proceed, but I'm an Old Fart. :tired:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now

Advertising from our partners