Hello,
I need to capture the phase of an AC adapter using an ADC. I am also wondering if it's OK to regulate its output to DC and use that to power the circuit?
Attached is an example of what I have in mind (don't mind the resistor values, I'll do proper math later). Feels kind of weird.
Hi!
Excellent, thank you!
Still, out of curiosity, does this circuit make any sense?
I have to admit that I missed that you are measuring the output of an AC adaptor, so you are not directly connected to mains and are probably using low voltages.
Actually, your resistor network doesn't make sense to me. It could produce a voltage greater than 3.3V (which I assume is your Vcc) on the ADC input which would be bad.
Have a look at section 2.3.1 in the app note for another way of approaching the voltage measurement.
Hi,
2.3.1 seems to only properly work when power factor is 1, so might not work for me.
The left-hand part of the resistor network scales down to 3.3V (it may not be clear that the AC adapter is 6V), and the right-hand part lifts it above 0. Simulator seems to think it's ok, but the circuit just kind of feels weird, but I just don't know.
The left-hand part of the resistor network scales down to 3.3V (it may not be clear that the AC adapter is 6V), and the right-hand part lifts it above 0. Simulator seems to think it's ok, but the circuit just kind of feels weird, but I just don't know.
It may look like it simulates fine but that's just because you have 20 M-ohms of resistance which is hiding the fact that the ADC input node is ever so slightly above 3.3V.
If V1 is greater than 3.3V then every node on the path V1 -> R4 -> R5 -> R6 -> 3.3V is also greater than 3.3V.(Let me think about the above a bit more.)
The other problem with the two 10 M-ohm resistors is it will force you to slow down your ADC sample rate. For instance, on the atmega 328P the source impendence to an ADC pin shouldn't be more than 10K. The sample and hold capacitor in the ADC needs to charge/discharge to the new input voltage and a high source impendence slows down that adjustment time.
Heh! I'll try to find resistor values that make sense. Thanks for the tip on the ADC, haven't actually read up on how to properly use one.
If V1 is greater than 3.3V then every node on the path V1 -> R4 -> R5 -> R6 -> 3.3V is also greater than 3.3V.
It is? The R4-R3 divider drops it to just above half of 6V, doesn't it? Am I completely misunderstanding this?
D2 is shorted by the GND connections, and D4 is always reverse-biased. Neither one does anything. If your AC source was floating and didn't have that GND connection, then you would have a full-wave bridge rectifier (as I assume you intended).
That spice configuration of the Voltage source gives you 6V peak, which will be the DC output of the rectifiers (minus diode drop). If you actually have a 6V RMS output the rectified voltage will be higher, about 8V, and you will over-volt your ADC input.
If V1 is greater than 3.3V then every node on the path V1 -> R4 -> R5 -> R6 -> 3.3V is also greater than 3.3V.
It is? The R4-R3 divider drops it to just above half of 6V, doesn't it? Am I completely misunderstanding this?
Yeah - just ignore that.
I'm curious about your power factor concern:
2.3.1 seems to only properly work when power factor is 1, so might not work for me.
Are you concerned about the AC coupling capacitor introducing a phase shift?
This won't work because you have shortened D2 (both ends are connected to GND)
Even if you remove the GND at the signal source so that the DC part works, you still have a problem with the GND at R3. In my opinion it is very difficult to use the same directly connected signal to generate your operating voltage and measure the AC signal without distortion by the DC part. What frequencies are we talking here? Can you use a transformer to separate the DC part from the signal? This would then allow you to tap the AC before the transformer via R4
This won't work because you have shortened D2 (both ends are connected to GND)
Even if you remove the GND at the signal source so that the DC part works, you still have a problem with the GND at R3. In my opinion it is very difficult to use the same directly connected signal to generate your operating voltage and measure the AC signal without distortion by the DC part. What frequencies are we talking here? Can you use a transformer to separate the DC part from the signal? This would then allow you to tap the AC before the transformer via R4
Oh no! Ground at the anode of D2 is a mistake. That's supposed to be a bridge rectifier... I'll try to correct that.
It's 60 Hz as this is to measure mains phase. I'm doing so indirectly through the AC power supply because I'd rather not deal with high voltage.
I'm having a bit of trouble understanding where you'd have the transformer. Before the regulator or at the R4-R3 junction?
This won't work because you have shortened D2 (both ends are connected to GND)
Even if you remove the GND at the signal source so that the DC part works, you still have a problem with the GND at R3. In my opinion it is very difficult to use the same directly connected signal to generate your operating voltage and measure the AC signal without distortion by the DC part. What frequencies are we talking here? Can you use a transformer to separate the DC part from the signal? This would then allow you to tap the AC before the transformer via R4
Hi - just going on what the app note states:
"when voltage and current are not in phase crosstalk will have a nonlinear effect on the measurements, which cannot be calibrated."
Entirely possible I'm just not understanding the exact impact here.
Before going further, I am still not sure what you are trying to do. Measuring phase (an angle) with respect to what reference? The circuit seems more intended to record the wave form not a phase angle? Is the purpose to record a more or less sine-shaped curve of around 60Hz? Another question is the signal source. Is this mains directly or are you going through an (isolated) AC adaptor?
I am asking this because if you are after phase, not wave form, then something big is missing here, namely the reference signal. Also it would be necessary to design the circuit to avoid phase shifts (e.g. when measuring through a capacitor)
Before going further, I am still not sure what you are trying to do. Measuring phase (an angle) with respect to what reference? The circuit seems more intended to record the wave form not a phase angle? Is the purpose to record a more or less sine-shaped curve of around 60Hz? Another question is the signal source. Is this mains directly or are you going through an (isolated) AC adaptor?
I am asking this because if you are after phase, not wave form, then something big is missing here, namely the reference signal. Also it would be necessary to design the circuit to avoid phase shifts (e.g. when measuring through a capacitor)
Hi, what I am showing here is only part of the circuit. The idea is to measure power consumption with current transformers, referenced to the the sine wave above, which was intended to go through an AC adaptor from mains.
Hope that clarifies it!
I'm open to any approach, really.
Ok, that makes more sense now. Not to spoil your fun in DIY, but are you aware that you can get a simple module that does this? The PZEM-004T for example costs about $13 including a 100A current transformer and delivers the voltage, current, active power, energy, frequency and power factor over a serial interface using the MODBUS protocol.
To do it yourself is not going to be trivial. The current transformer will introduce a phase shift that needs to be calibrated out. If you tap the voltage through an AC isolation transformer (which for a DIY built is definitely the safer way), that transformer itself will introduce its own phase shift to the voltage. Also most stuff, apart from incandescent light bulbs and heaters connected to mains distort the current massively. No resemblance to sine curves at all. Some pretty cool signal processing is needed to calculate active power and accumulate to energy. So besides the challenge of coming up with a circuit that works, you need to think how to calibrate this and verify that the results are reasonably correct.
That said, in principle you are on the right track with your circuit but you need to change your AC transformer to one that has 2 independent secondary windings. One which you you use to produce your DC power from, and the other to get an AC voltage that is referenced to the same ground as the DC and still preserves its shape
It has to be 2 secondary windings, because in your current method, the AC wave form will be totally offset and distorted through the rectifier diodes, it is unavoidable with one common winding.
Excellent, thank you. That's just what I needed.
One remaining question though is you say the AC waveform goes through the rectifier, but I don't see how? ie, I am tapping it before the rectifier with the divider network?
It's pretty academic at this point, since I will most likely use a ready-made module!
Ah, right! Thank you.
I'll check out your videos. I'll also have to look into combining 2 or 3 of these and capture serial data of each.
you need to change your AC transformer to one that has 2 independent secondary windings.
Or you could use a centre-tapped secondary, with a half-wave rectifier on each leg, and the centre tap being the ground reference for both the AC and DC sides.
Yes, that would be another possibility.
Great video, great mod, btw!