Jump to content

Recommended Posts

Hello Wizards,

I am trying to do a voltmeter which would show the mains voltage and current consumed by the load in Amperes on LCD. I am using a 16F877A for that. I would be reading the mains value at port A0 (Channel 0). I think I can read the values, but what about displaying them back? I am bit of confused. The problems I think:

1. The ADC readings corresponding to the mains supply are kind of non linear. I am using 2 opto couplers to sense the mains (one for each half cycle). The mains is connected to LED through a 220K and a diode (1N4007). A 12V supply is given to the collector of photo transistor(O/P) and the Output is taken from the emmiter so that changes in the mains reflect in this output. Now these values seem to linear(somewhat) between 150 Volts and 260 volts. Above and below these levels the reading dont seem to be linear. Now if I have to convert this value to the original mains value, I have to derive some formula which can accomodate all the values and correspond them to their original value.

E.g: The reading for Mains voltage 50 Volts is 0.356 V dc, while for 100 Volts, it is 1.031 V dc. I dont know what could correlate these values.

2. Is there anything related to the transistor of Opto working in active region.

3. Is it inevitable to use floating point math for the same.

4. I dont have space for a transformer, if in case I am thinking to deploy transformer => Rectifier => Voltage Divider => Filter =>ADC pin

 

All your help would be much appriciated.

Thanks in advance

Regards

Shree

P.S: I took readings deploying transformer and rectifier. Not much differenece in the ouput.

Link to post
Share on other sites

Shree,

 

The way you are trying to monitor the mains is all wrong if you want accuracy AND isolation. Not ALL optocouplers are lousy - try looking at Avago (HP) HCNR201 datasheet and associated application notes.

You also need to decide on what information you want to display and how to display it.

 

Are you trying to build a mains power monitor? Try searching for such a beast, you may find some useful information on monitoring mains voltage and currents. An initial search found this:

 

http://openenergymonitor.org/

 

Not only will you have to worry about RMS, Peak, Average values etc. but Power Factor also comes into the equation if you are to display power.

 

One final caution. I am sorry if I am wrong but I get the feeling from your posts that you may not have sufficient electronics knowledge (at the moment anyway) to play around with mains voltage. Use an isolation transformer whenever possible to supply your circuits so you can ground your test equipment to minimise the risk of working live. Please be extremely careful and don't take chances.

 

davidb

Link to post
Share on other sites

Hello Wizards and thanks for your replies

do you want to measure peak voltage, or RMS? Instantaneous, or averaged?

 

And... schematic?

 

Optocouplers are lousy for linear transfers.

I want to display a RMS value.

 

Shree,

 

Are you trying to build a mains power monitor? Try searching for such a beast, you may find some useful information on monitoring mains voltage and currents. An initial search found this:

 

http://openenergymonitor.org/

 

Not only will you have to worry about RMS, Peak, Average values etc. but Power Factor also comes into the equation if you are to display power.

Thanks for that link. I dont want to display power, so I hope PFC wont come into picture and as said earlier I would like to display RMS value.

The way you are trying to monitor the mains is all wrong if you want accuracy AND isolation. Not ALL optocouplers are lousy - try looking at Avago (HP) HCNR201 datasheet and associated application notes.

Is this opto commonly available?

You also need to decide on what information you want to display and how to display it.

I wanted to display RMS Voltage of the phase (input AC mains supply) and the current in that phase.

One final caution. I am sorry if I am wrong but I get the feeling from your posts that you may not have sufficient electronics knowledge (at the moment anyway) to play around with mains voltage. Use an isolation transformer whenever possible to supply your circuits so you can ground your test equipment to minimise the risk of working live. Please be extremely careful and don't take chances.

Thanks for that david and yes I am not as good as one might be with electronics yet. But I have been playing with the mains for a while and excercise most of the do's and dont's. I have heard about one more option to get linear readings which is precision rectifier (using an opamp), but I suppose it might also need a step down transformer as the opamp would work with +-15V or 18V. But the more pressing issue would lie in the code. If a get some readings which are say linear. Now these readings would ultimately be some value ranging from 0 to 1023 (10-bit ADC). So what code might be written in C to convert back this value for displaying it as Mains AC voltage?

One of my friend using CCS suggested that I must plot the graph of the readings in MS-EXCEL and derive a formula from there and then just put that formula in my code and I would get the voltage reading. The formula that I got was something like (29.687 X 1.01^x). Now I dont know whether boost C accepts this thing or not or moreover is this a right way to get the readings?

I know I am bit lousy with explaining my point, but still hope you all would bear with me.

Thanks again

Regards

Shree

Link to post
Share on other sites

Shree,

 

The way you measure the mains voltage and current depends on what precision and response time you require as well as how far you want to go with complexity and expense. If you need isolation then that is yet another factor.

 

I would recommend using a current transformer for current measurements. Don't forget that current measurements in particular based on sinusoidal waveforms will be innacurate with anything other than pure resistive loads. If the voltage waveform is also distorted then you will have even more inaccuracy.

 

If absolute accuracy and fast response is unimportant then a simple way to measure the mains voltage might be to use a small transformer for isolation followed by a full-wave rectifier, capacitive filter and small load. Depending on the capacitor value this should give a DC voltage approximating the peak of the mains but scaled by the transformer ratio.

 

Pot this voltage down further to be within the AD range of the PIC for the expected maximum and minimum mains voltage. Take precautions against overvoltage etc. to avoid damaging the PIC input. If you include a factor of x 0.707 in the potential divider then the DC voltage at the ADC input of the PIC will represent the rms value (but not true rms). There will of course be ripple on the voltage but this can be digitally filtered by your PIC software if you take enough samples to obtain a smooth reading. You will obviously have to calibrate your particular setup to take into account any errors introduced by the rectifier diodes, transformer magnetising current etc.

 

More accurate and hence more complex and expensive designs could include the HCNR201 or similar linear opto-isolator followed by a precision rectifier etc. You could also do the rms to DC conversion in hardware. Try looking at devices made by Linear Technology e.g. LTC1968, or Analog Devices e.g. AD637.

 

Do as much conversion as possible in hardware and avoid floating point maths.

 

I don't know how easy it is for you to obtain parts in your location but try Farnell, RS, Digikey etc.

 

Regards

 

davidb

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...