Maker Pro
Maker Pro

4-20mA circuit and MCU

Nickb1969

Aug 28, 2016
19
Joined
Aug 28, 2016
Messages
19
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)
 

shrtrnd

Jan 15, 2010
3,876
Joined
Jan 15, 2010
Messages
3,876
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.
 

Alec_t

Jul 7, 2015
3,587
Joined
Jul 7, 2015
Messages
3,587
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
 

Nickb1969

Aug 28, 2016
19
Joined
Aug 28, 2016
Messages
19
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.
View attachment 34330

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.
 

Nickb1969

Aug 28, 2016
19
Joined
Aug 28, 2016
Messages
19
No. The ADC input should not exceed the supply voltage of the MCU.

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 ?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Is there any set protocol for the voltage range.
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.
 

Alec_t

Jul 7, 2015
3,587
Joined
Jul 7, 2015
Messages
3,587
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 ?
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.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
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
 

Alec_t

Jul 7, 2015
3,587
Joined
Jul 7, 2015
Messages
3,587
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
 

Attachments

  • Multi-sensors-to-current-loop.asc
    3.8 KB · Views: 120
Top