4-20mA and voting logic via micro controller

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
My current project involves having between 8 and 24 inputs into a micro controller (for which I am receiving help with learning how to programme).

This is a theoretical question about possibilities, so I know which way I can go with the design of PCBs (layouts etc). The number of inputs will be set when the system is built, therefore I can have a different programme for 12 input channels and 16 input channels for instance. I would like to use the micro controller to generate a 4-20mA loop, each input channel provides a voltage step towards the 4-20mA loop. I believe 1-5 volts is the way to go because I am using a micro controller with 5V supply.

The other feature that I would like to incorporate is 2 sets of 2 out of 3 voting logic. The input channels would need to be selectable, eg 1,2,3 or 2,3,4 or 3,4,5. I know the micro controller already has logic functions but from what I can understand, there is not enough function for 2 sets of voting logic. I think this feature is a little easier for me as I have already done this with logic gates, and switches. I am thinking that a switch on 3 inputs of the micro controller, one for channels 1,2,3, one for channels 2,3,4 and one for channels 3,4,5. The user selects which set of channels they want to use with one of the switches, the programme will run the voting logic on the desired channels and output to a relay and LED.

Any general help on if this is possible would be great, especially with the 4-20mA.
 

Sensacell

Joined Jun 19, 2012
3,432
Really hard to understand your intent here.

Are you saying the 4-20 mA loop is the OUTPUT - to some other device?
The input channel groups set the current, through some voting logic??
Why a 4-20 mA loop?

Maybe it would help if you 'zoom out' a bit and explain the larger context of the problem.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
Really hard to understand your intent here.

Are you saying the 4-20 mA loop is the OUTPUT - to some other device?
The input channel groups set the current, through some voting logic??
Why a 4-20 mA loop?

Maybe it would help if you 'zoom out' a bit and explain the larger context of the problem.
The 4-20mA and the voting logic bit are 2 completely different parts of the system, so only need to address one at a time.

4-20mA is still an industry standard way of communicating between transmitters etc and control systems. The equipment is a level indicator. It has upto 24 points of for level sensing in a vertical column. As the water level rises and falls, the sensors are closed circuit for water and open circuit for steam. Each sensing circuit is input into the micro controller and from there, visual displays etc are driven.

So each sensing circuit provides one step (out of max 24) between full and empty. 24 sensing circuits = 24 steps, 16 sensing circuits = 16 steps. I would like to use the micro controller to generate the stepped 4-20mA signal the will be connected to whatever system the end user wants.

I hope this explains better.
 

Sensacell

Joined Jun 19, 2012
3,432
Ok, so basically you want to convert 16 or 24 digital inputs (steps from a sensor) into a 4-20 ma signal?
This is an interface between a sensor and normal factory instrumentation that accepts 4-20 mA?

The steps always go in sequence?
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
Ok, so basically you want to convert 16 or 24 digital inputs (steps from a sensor) into a 4-20 ma signal?
This is an interface between a sensor and normal factory instrumentation that accepts 4-20 mA?

The steps always go in sequence?
Basically yes, but it could be anything from 8 to 24 digital inputs. The number of inputs would be set when programming the PIC. The design of the system means that the customer can ask for a system with ** number of channels and the system will be programmed for that number.

There is a sensor for each channel. 24 digital inputs means 24 sensors, 12 digital inputs means 12 sensors. The system takes the information from each sensor and provides a visual display of the level of the water, relay outputs, trip logic and 4-20mA.

Yes the steps are always in sequence. Imagine a tank of water and the sensors reacting to being in water of not being in water.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
I can guess that you mean a resistor on each channel? I am not sure how it works for different number of channels. I would like to use the PIC is possible.
 

Sensacell

Joined Jun 19, 2012
3,432
A PIC seems like the wrong solution here- totally over complicates the project.

You could employ a resistor for each channel, feeding an opamp sum circuit.
Change just the feedback resistor to allow different numbers of channels.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
A PIC seems like the wrong solution here- totally over complicates the project.

You could employ a resistor for each channel, feeding an opamp sum circuit.
Change just the feedback resistor to allow different numbers of channels.
Thanks for the reply. I already have the PIC for other parts of the system and all the channels are already fed into the PIC. I was hoping the I could use that for the 4-20mA. That way the 4-20mA could be generated at a slave along with the LED display. Will safe the user lots of extra wiring.
 

Picbuster

Joined Dec 2, 2013
1,047
I think that you need additional information on 4-20mA standard ( the common used std in measurement and control systems)
It is passive or active working @ 24V DC ( yes some equipment will operate at a lower voltage but have to accept or generate 24V)
Active: your HW generate 24V
Passive: your HW accept 24V
Both produce a current variation of 0-16mA plus an offset of 4mA resulting in a 4-20mA Loop.
The 0-4mA is in passive mode often used to power the sensor.

Picbuster
 

MrChips

Joined Oct 2, 2009
30,720
You can roll your own current loop driver using a couple of opamps and an output transistor.

Or you can use an AD421 which gives 16-bit resolution and you need only 5-bit resolution.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
I think that you need additional information on 4-20mA standard ( the common used std in measurement and control systems)
It is passive or active working @ 24V DC ( yes some equipment will operate at a lower voltage but have to accept or generate 24V)
Active: your HW generate 24V
Passive: your HW accept 24V
Both produce a current variation of 0-16mA plus an offset of 4mA resulting in a 4-20mA Loop.
The 0-4mA is in passive mode often used to power the sensor.

Picbuster
Hi, The application is measurement and control. The ideal situation is that the 4-20mA loop be transmitted via the RS485 to the slave units, this way it can be accessed from any slave device.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
You can roll your own current loop driver using a couple of opamps and an output transistor.

Or you can use an AD421 which gives 16-bit resolution and you need only 5-bit resolution.
That looks like a good bit of kit. I need to try and understand how it works with the micro controller.
 

Sensacell

Joined Jun 19, 2012
3,432
Hi, The application is measurement and control. The ideal situation is that the 4-20mA loop be transmitted via the RS485 to the slave units, this way it can be accessed from any slave device.
I am totally confused now...

4-20 mA is an analog protocol, RS-485 is a serial digital protocol. Who is transmitting what to where? and via what medium?
You seem to be throwing apples and oranges together without context.

I think it would be appropriate to post a block diagram of your intended system, that will help clarify what you are trying to accomplish
 

MrChips

Joined Oct 2, 2009
30,720
Nick is trying to send information over a long distance, say 10m. Twisted pair RS-485 is a good medium but this requires a communication protocol.

He needs to send one of 16 values. 4-20mA is a workable solution. A level senor detects one of 16 levels. He can transmit this via a current source to a receiver. All he needs to do is replicate the one of 6 levels on 16 LEDs at the receiving end.

(While 4-20mA is a common industry standard, you don't have to confirm to 4-20mA. 0-5mA would also do the trick).
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
4-20mA is industry standard for this type of equipment. Yes it is easy enough to implement 4-20mA in the control unit but I would like to access the 4-20mA loop via the master and slave RS485 connection of the micro controllers. The slaves could be up to 1km away from the master mcu. By being able to make the 4-20mA loop available at a slave unit by using the RS485 communication that will already be there will simplify installation and reduce installation costs hugely.

All I really need to know is..... is it possible for a slave device to have a connection for 4-20mA loop using the 4 core RS485 connection in place for controlling the displays?
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
Nick is trying to send information over a long distance, say 10m. Twisted pair RS-485 is a good medium but this requires a communication protocol.

He needs to send one of 16 values. 4-20mA is a workable solution. A level senor detects one of 16 levels. He can transmit this via a current source to a receiver. All he needs to do is replicate the one of 6 levels on 16 LEDs at the receiving end.

(While 4-20mA is a common industry standard, you don't have to confirm to 4-20mA. 0-5mA would also do the trick).
The 4-20mA side of things is separate to the displays. I really want to be able to drive the leds and provide a 4-20mA loop at the slave.
 

MrChips

Joined Oct 2, 2009
30,720
The 4-20mA side of things is separate to the displays. I really want to be able to drive the leds and provide a 4-20mA loop at the slave.
Sorry, I misread you.
So you want one twisted pair for RS-485 comm over 1km
and one pair to supply power (not 4-20mA loop) maybe +12VDC or +24VDC.
 

Thread Starter

Nick Bacon

Joined Nov 7, 2016
130
Sorry, I misread you.
So you want one twisted pair for RS-485 comm over 1km
and one pair to supply power (not 4-20mA loop) maybe +12VDC or +24VDC.
Yes I would have 3 pair cable. Signal, 5v and 12v. 5v for micro controller on the slave and 12v for the leds etc.

Do you get what I mean about the 4-20mA loop being available in the slave units?
 

MrChips

Joined Oct 2, 2009
30,720
Yes I would have 3 pair cable. Signal, 5v and 12v. 5v for micro controller on the slave and 12v for the leds etc.

Do you get what I mean about the 4-20mA loop being available in the slave units?
No, I don't get what you mean.

Also, have you determined the resistance on 1km cable on two wires, and hence the voltage loss on 1km cable?
 
Top