CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

how to get a constant Voltage
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

how to get a constant Voltage
PostPosted: Mon Aug 08, 2011 8:12 am     Reply with quote

I have an 4-20ma input, i put a 10ohms resistor wrt grd and get 40mV and 20mV respectively and give that to ADC and display value. everything is fine till here, now i have the same current which is going ahead to some unknown load, how do i display the values in this case?
Please give some feedback.

thanks!
sid
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: how to get a constant Voltage
PostPosted: Mon Aug 08, 2011 8:46 am     Reply with quote

Sid2286 wrote:
I have an 4-20ma input, i put a 10ohms resistor wrt grd and get 40mV and 20mV respectively and give that to ADC and display value. everything is fine till here, now i have the same current which is going ahead to some unknown load, how do i display the values in this case?
Please give some feedback.

thanks!
sid


A bit of clarification first.

    WRT gnd is not relevant as 4 to 20mA sensors are typically isolated (floating).
    I suspect in this case you have grounded one leg of the sensor.
    [list=]
    It is a matter of semantics. Strictly speaking, in a 4 to 20mA system, the "load" is the sensor. I suspect you mean the sensor is being excited by an unknown source, typically a series resistor, let's call it RL, to an excitation voltage source.

    Think of this as three series resistors across the excitation voltage source and let's call the negative terminal of the source ground. Your existing 10ohm resistor (Rsense) connects between ground and the negative terminal of the sensor. The + terminal of the sensor goes the the series excitation resistor with the other end of the excitation resistor to the voltage source.

    You measure the voltage across Rsense, just as you are doing now. The value of RL is selected based on the sensor datasheet and the nominal excitation voltage.

    In practive you would probably want to add another resistor between Rsense and ground. This is to move the sensing threshold further away from ground to ensure you are running in the linear range for the amplifier stage or ADC input.
[/list]
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

PostPosted: Mon Aug 08, 2011 9:11 am     Reply with quote

Well somewhat close.. But not exactly what i meant!
I wasn't getting the name.. I want to build a loop indication.. That means I get 4-20mA, display the PV on certain range and that loop is further connected to plc or HMI.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Aug 08, 2011 9:32 am     Reply with quote

Sid2286 wrote:
Well somewhat close.. But not exactly what i meant!
I wasn't getting the name.. I want to build a loop indication.. That means I get 4-20mA, display the PV on certain range and that loop is further connected to plc or HMI.


That's trickier. Your Rsense now has to go in series with RL so that current flowing though Rsense does not produce a voltage measured by the PLC.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

PostPosted: Mon Aug 08, 2011 10:05 am     Reply with quote

Yes, its quite confusing. Is there a way of programming PIC wherein I get voltage across Rsense as input and then Rsense is further connected in series to whatever external load ?
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Aug 08, 2011 10:24 am     Reply with quote

Sid2286 wrote:
Yes, its quite confusing. Is there a way of programming PIC wherein I get voltage across Rsense as input and then Rsense is further connected in series to whatever external load ?


Yes. The PLC does not see it, because the PLC sits directly across the sensor however this assumes the RL is external to the PLC.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Aug 08, 2011 10:42 am     Reply with quote

You could put a 250r resistor in the 4-20ma loop and have a differential amplifier measure the voltage across it. With proper resistor selection for the diffamp, it'll output say 1 volt for 4ma, 5 v for 20 ma. This output can easily be read by the PICs ADC.
There are commercial chips/modules that do this but for a one-off project and as a learning tool, it's best to do it yourself.
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

PostPosted: Mon Aug 08, 2011 11:10 pm     Reply with quote

Accepted that the maximum load will be 250r at the plc. But it won't be necessarily 250r it may be less...in that case the readings will be different!
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Tue Aug 09, 2011 1:59 am     Reply with quote

The whole point about 4-20mA drivers, is that they produce a precisely defined _current_. If the loop is producing 12mA (say), then a 100R resistor in the loop, will always measure 1.2v _whatever else is in the loop_ (within the limits of the driver's ability to generate voltage). There should be a figure from the manufacturer of the device driving the loop, giving the maximum resistance it is able to drive. Typically something like 500R. Provided the total resistance in the loop does not exceed this, the current will remain the same whether you insert a 100R resistor, or a 200R resistor, and whatever other devices are in the loop.
You choose either the resistor itself, or the gain of the op-amp between the sense resistor, and the PIC's ADC, to give the voltage you require. Remember that the PIC's 5v supply is generally not accurate as a Vref, so if you use (say) a 2.5v Vref, and a 100R resistor, you can read from 0 to 25mA - a lot of 4-20mA devices use a higher current like 24mA, as an 'error' indicator, and if you can read to 0mA, you can detect that nothing is driving the loop. You'd then have 655counts for the 4-20mA range, and limited error detection as well.

Best Wishes
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

PostPosted: Tue Aug 09, 2011 8:41 pm     Reply with quote

Thanks temtronics and Ttelmah. I got what is required but i would like to know if the way I'm programming is right!
Now lets say I've 4mA input, I use a diff amplifier and get say 1.5V, I use a read_adc() function and find out its value as 255. Now again I read the value for 20mA and find the voltage as 3.5v and adc value as say 800. So I use these, 255 as my min and 800 as max, I calibrate on a scale of range 0-100. Is this the right way to do?
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

No reply
PostPosted: Fri Aug 12, 2011 3:44 am     Reply with quote

Please any replies or suggestions :(
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Aug 12, 2011 9:50 am     Reply with quote

Sid2286 wrote:
Thanks temtronics and Ttelmah. I got what is required but i would like to know if the way I'm programming is right!
Now lets say I've 4mA input, I use a diff amplifier and get say 1.5V, I use a read_adc() function and find out its value as 255. Now again I read the value for 20mA and find the voltage as 3.5v and adc value as say 800. So I use these, 255 as my min and 800 as max, I calibrate on a scale of range 0-100. Is this the right way to do?


It depends. Does your sensing logic give a linear output proportion to the current?

You are should be measuring the voltage across a known resistor. Ideally, if you measure 1.5V with a 4mA current, implying a 375 sense resistor, then at 20mA, the voltage should be 7.5 volts.

Seeing as that is not what you have it would imply there is an offset. Using the numbers you have given, a delta I of 16mA results in a delta V of 2 volts implying the effective sense resistance is 125 ohm. At 4mA the voltage across this should be 0.5 volts and at 20mA it should be 2.5 volts. Your results potentially implies constant offset of 1 volt.

Does your schematic apply a constant offset of 1 volt? If so then the conversion is straight forward.

output value = (reading - 255)/(800-255)*100
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Aug 13, 2011 9:08 am     Reply with quote

Industry standard 4-20 mA loop indicators like E+H RIA141 https://portal.endress.com/wa001/dla/50002285073/000/05/TI106Ren_1108.pdf
are loop powered and are designed with a low resistance shunt (only limited voltage drop) and a Z-diode like voltage limiting circuit to supply the processor and display, both connected in series. In my opinion, the design requirements are quite obvious, when you think about it.
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

PostPosted: Wed Aug 24, 2011 6:37 am     Reply with quote

I tried using a differential amplifier but it seems to be not working! It works for a certain condition(without any load..when load is connected to ground), however when the load resistance changes...the voltages at TP1 and TP2 changes with respect to ground. and thus, my differential output changes giving no constant adc input for 4mA and 20mA.

My circuit diagram is as follows:

http://www.freeimagehosting.net/71122
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Wed Aug 24, 2011 9:08 am     Reply with quote

Hopefully R6 is not as shown in the picture?. 10K!.... Won't work.
U1B, is not needed, or doing anything really.
There is a potential problem, if the 4-20mA driver is not fully floating, depending how the ground in the PIC circuit relates to the 4-20mA driver circuit voltages, and the common mode range of the op-amps.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group