Connect with us

4-20mA circuit and MCU

Discussion in 'General Electronics Discussion' started by Nickb1969, May 30, 2017.

Scroll to continue with content
  1. Nickb1969

    Nickb1969

    19
    0
    Aug 28, 2016
    Hi guys,

    I am looking for some some help with 4-20mA circuit.

    The basic setup is a micro controller with 8 to 24 digital inputs. Each input is one on / off sensor. Together the inputs form a stepped level for a column of water. 8 sensors = 8 steps, 14 sensors = 14 steps etc.

    I am trying to create a 4-20mA output using the micro controller and any other components needed. I was hoping that the micro controller would be able to take the digital inputs and generate a 4-20mA signal.

    I really do not know where to start, I am not an electronics expert or had any experience with 4-20mA circuits.

    Could someone point me in the best direction for this. I am happy to use an AD421 if this is the correct way to go. An help would be great but please don't talk technicals because it will go over my head. I understand basics of 4-20mA and very basic functions of micro controller. The micro controller has not been selected yet, but looking at a 64 pin ARM Cortex (NXP 9MKE04Z64VLH4)
     
  2. shrtrnd

    shrtrnd

    3,795
    503
    Jan 15, 2010
    4-20mA constant current source is an industrial standard for process control instruments.
    I'd start Googleing manufacturers in the business, ALL of them have application notes concerning uses for their product lines. You might get some good ideas from checking their websites.
    Eaton, Newport, Omron, Red Lion, Veeder-Root, IDEC, Autonics, ABB, many more.
     
  3. Alec_t

    Alec_t

    2,927
    797
    Jul 7, 2015
    Here's one approach.
    In this simulation the sensor outputs are combined by a simple resistor network.
    The combined output (yellow trace) rises non-linearly as the number of sensors is increased from 1 to 24. One ADC input of the micro would be used with a look-up table to convert this combined signal to a linear voltage ranging from 0.4V to 2V, for driving a conventional 4-20mA generator comprising an opamp, current-sense resistor R2 and Q1.
    4_20mA_from_multi-sensors.PNG
     
  4. Nickb1969

    Nickb1969

    19
    0
    Aug 28, 2016
    Hi there,

    Thanks for the reply...... I have experimented with this and gave up when I realised the outputs were not linear, but at least I go some form of signal. I have to day I do quite understand the schematics. I do not have 24V in the system, only 12V and 5V. I get that I have a resistor on each sensor circuit and each contributes a part to the total voltage. I gather that the voltage can be either 1-5V or 2-10V and others as well. Will the micro controller accept a 10VDC input into the ADC, I have looked and can not find any reference to max voltages. I did read that it is best to have at least a 10% margin on the supply voltage, so with 12VDC supply 2-10VDC would be a good range.

    I will do some research on lookup tables and how they work but if you could give me a little help on the basics, it would be great.

    One step at a time and I will undersatnd better.
     
  5. Amar Dhore

    Amar Dhore

    129
    12
    Dec 2, 2015
  6. Alec_t

    Alec_t

    2,927
    797
    Jul 7, 2015
    No. The ADC input should not exceed the supply voltage of the MCU.
     
  7. Nickb1969

    Nickb1969

    19
    0
    Aug 28, 2016
    OK I get that. Is there any set protocol for the voltage range. As I have 5VDC supply for the MCU and the Opto osolators, can I use 5VDC for the supply to the summing circuit, giving 0v to 5v for the range ?
     
  8. Harald Kapp

    Harald Kapp Moderator Moderator

    11,006
    2,506
    Nov 17, 2011
    This is a parameter specified in the datasheet of the µC.
    The datasheet for the 9MKE04Z64VLH4 for example states in chapter 6.4.1:
    Vrefl <= Vadin <= Vrefh and Vrefl = Vssa, Vrefh = Vdda
    With Vssa = 0 V and Vdda = Vdd (3.3 V ... 5 V) your effective input range is 0 V ... 3 .3 V or 0 V ... 5 V depending on Vdd used in your circuit.
     
  9. Alec_t

    Alec_t

    2,927
    797
    Jul 7, 2015
    5V supply for the summing circuit will give somewhat less than 0-5V range if using a simple resistor summing network. Alternatively you could use an inverting opamp to do a linear summation.
     
  10. Harald Kapp

    Harald Kapp Moderator Moderator

    11,006
    2,506
    Nov 17, 2011
    One way to generate a low bitcount input to the MCU from a high number of one-hot encoded inputs is a priority encoder.
    You can use for example the 14532B which has 8 inputs but can be cascaded for 16 inputs or more (3 chips needed for 24 inputs)

    The one hot encoded inputs are the signals from your switches, with their logic level suitably adapted to the circuit e.g. by using resistive dividers.
    The output is a direct binary representation of the number of the highest active input signal. A 5 bit output will encode all 24 possible inputs. This 5 bit code can easily be read by the MCU and converted in whatever way you wish.
    The XTR 111 mentioned by @Amar Dhore in post #5 is just one suitable IC. Other vendors have similar ICs, e.g. Analog devices' AD694. All you need i the suitable application circuit and a voltage output from the MCU to the transmitter chip. The voltage output from the MCU can be via an integrated ADC or simply by filtered pwm (as the levels change rather slowly, I think).

    It is even possible to get along without MCU:
    The binary encoded data from the priority encoder can be converted to an analog voltage with a linear characteristic by using a simple resistor ladder network. The resulting analog voltage can be input to the 20mA transmiter chip and you're set:

    upload_2017-6-2_8-8-25.png
     
  11. Alec_t

    Alec_t

    2,927
    797
    Jul 7, 2015
    Using an opamp for the summing (as mentioned in post #9) leads to a simple analogue implementation.
    Here's a sim demonstrating the principle. It uses five sensors but more can be added.
    MultiSensorsCurrentLoop.PNG
     

    Attached Files:

  12. Harald Kapp

    Harald Kapp Moderator Moderator

    11,006
    2,506
    Nov 17, 2011
    Also a good solution.
    Many ways lead to Rome.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-