Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

voltage to PWM or voltage to frequency

Status
Not open for further replies.

gehan_s

Member level 3
Joined
Aug 31, 2012
Messages
62
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
Sri Lanka
Activity points
1,797
hey all,

i am in a situation where i have to measure the AC main voltage using a PIC. i am planning to attenuate and shift the AC voltage to a 0 to 5V, 50Hz signal. to couple this signal to the microcontroller i was planning to use a linear optocoupler. but i cannot do that anymore as they are pricy, hard to find here and concerns about the linearity range.

so i am thinking about converting the 0 to 5V, 50Hz signal to a PWM signal where the pulse width changes according to the sin wave amplitude and then couple it using a normal optocoupler, LPF and then give it to the A-D of the PIC.
OR
use a VCO --> optocoupler --> frequency to voltage converter --> A-D of PIC.

are these methods feasible and how accurate will they be ?????

thanks in advance !!!!!!!!
 

crutschow

Advanced Member level 5
Joined
Feb 22, 2012
Messages
3,789
Helped
903
Reputation
1,804
Reaction score
888
Trophy points
1,393
Location
L.A. USA Zulu -8
Activity points
21,354
Converting the sinewave to PWM seems complicated and prone to error. How would you do that?

Why not just use a small transformer to isolate and convert the mains voltage to say 5V RMS. Then convert that to a DC voltage with a precision rectifier. You will need to calibrate the transformer to get good accuracy, but that is not difficult to do with a good multimeter. Of course that measures the average voltage, not true RMS, but that's generally adequate for standard AC mains voltages which have low distortion.

If you want true RMS, you would need to sample the sinewave voltage at a higher frequency, take the square of these samples, sum the squares, divide that by the number of samples for one cycle, and then take the square root to determine the RMS value.
 

gehan_s

Member level 3
Joined
Aug 31, 2012
Messages
62
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
Sri Lanka
Activity points
1,797
thanks for your reply,
we didn't consider the transformer option because it is going to increase the final product size. what about the VCO method ???? is that also a bad option and is there any other way other than the transformer method??????
 

crutschow

Advanced Member level 5
Joined
Feb 22, 2012
Messages
3,789
Helped
903
Reputation
1,804
Reaction score
888
Trophy points
1,393
Location
L.A. USA Zulu -8
Activity points
21,354
A power transformer can be made quite small if it doesn't have to deliver much power, such as one of these which is just 22mm square. It could also be used to power the rest of the circuitry.

The only choices I can think of to do what you want is with a transformer or with an opto coupler.

One way to use a digital opto coupler would be to place standard A/D circuitry on the power line side to generate a serial digital signal to transmit through the opto coupler. (I believe that's better than trying to do PWM or a VCO, which I think would be less accurate). You would need a simple power supply to power the A/D converter circuits from the power line. The converter could sample the voltage from a resistive divider and sent that across the coupler. The sample rate would be high enough (at least 10 times the line frequency) for the PIC to calculate either the average or RMS voltage, as desired.

The converter would need to be able to measure both the positive and negative values of the voltage. This can be achieved by either offsetting the input voltage to the half scale of the A/D or using a precision rectifier at the A/D input.

Where is the final signal from the PIC going?
 

gehan_s

Member level 3
Joined
Aug 31, 2012
Messages
62
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
Sri Lanka
Activity points
1,797
thanks again crutschow for replying ,

as you may know (as you have replied for my other threads in this forum and in others) this has all to do with my Power Meter project. so not only line voltage but i also have a sense resistor input which has to be coupled to the PIC. the PIC will then calculate active, reactive power, power factor, current etc...... and send it to a PC through the USB port. i am also hoping to power the PIC with the 5V of the USB.

if i am to use these transformers that you have mentioned should i use some additional circuitry apart from shifting and maintaining the maximum output to be a 0 to 5V sin wave???? and how accurate will the readings be ????
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top