Author Topic: Capture phase of ac adapter, and use for DC power?  (Read 668 times)

0 Members and 1 Guest are viewing this topic.

Offline mayor

  • Regular Contributor
  • *
  • Posts: 182
  • Country: ca
Capture phase of ac adapter, and use for DC power?
« on: April 22, 2021, 06:33:49 pm »
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.

 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 1426
  • Country: us
Re: Capture phase of ac adapter, and use for DC power?
« Reply #1 on: April 22, 2021, 06:47:22 pm »
Have a look at the Atmel/Microchip application note "AVR465: Single-Phase Power/Energy Meter with Tamper Detection". Lots of discussion on how to create a transformer-less power supply and take measurements on mains lines.

http://ww1.microchip.com/downloads/en/AppNotes/Atmel-2566-Single-Phase-Power-Energy-Meter-with-Tamper-Detection_Ap-Notes_AVR465.pdf

 

Offline mayor

  • Regular Contributor
  • *
  • Posts: 182
  • Country: ca
Re: Capture phase of ac adapter, and use for DC power?
« Reply #2 on: April 22, 2021, 06:49:10 pm »
Hi!

Excellent, thank you!

Still, out of curiosity, does this circuit make any sense?
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 1426
  • Country: us
Re: Capture phase of ac adapter, and use for DC power?
« Reply #3 on: April 22, 2021, 07:05:28 pm »
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.


 

Offline mayor

  • Regular Contributor
  • *
  • Posts: 182
  • Country: ca
Re: Capture phase of ac adapter, and use for DC power?
« Reply #4 on: April 22, 2021, 07:18:28 pm »
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.
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 1426
  • Country: us
Re: Capture phase of ac adapter, and use for DC power?
« Reply #5 on: April 22, 2021, 07:45:10 pm »
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.


« Last Edit: April 22, 2021, 08:03:30 pm by ledtester »
 

Offline mayor

  • Regular Contributor
  • *
  • Posts: 182
  • Country: ca
Re: Capture phase of ac adapter, and use for DC power?
« Reply #6 on: April 22, 2021, 08:00:46 pm »
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.

Quote
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?
 

Offline fourfathom

  • Frequent Contributor
  • **
  • Posts: 625
  • Country: us
Re: Capture phase of ac adapter, and use for DC power?
« Reply #7 on: April 22, 2021, 08:35:55 pm »
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.
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 1426
  • Country: us
Re: Capture phase of ac adapter, and use for DC power?
« Reply #8 on: April 22, 2021, 08:51:11 pm »
Quote
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:

Quote
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?
 

Offline theHWcave

  • Contributor
  • Posts: 31
  • Country: gb
Re: Capture phase of ac adapter, and use for DC power?
« Reply #9 on: April 22, 2021, 09:24:29 pm »
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
 

Offline mayor

  • Regular Contributor
  • *
  • Posts: 182
  • Country: ca
Re: Capture phase of ac adapter, and use for DC power?
« Reply #10 on: April 22, 2021, 11:19:26 pm »
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?
 

Offline mayor

  • Regular Contributor
  • *
  • Posts: 182
  • Country: ca
Re: Capture phase of ac adapter, and use for DC power?
« Reply #11 on: April 22, 2021, 11:24:55 pm »
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.
 

Offline theHWcave

  • Contributor
  • Posts: 31
  • Country: gb
Re: Capture phase of ac adapter, and use for DC power?
« Reply #12 on: April 23, 2021, 09:35:08 am »
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)
 

Offline mayor

  • Regular Contributor
  • *
  • Posts: 182
  • Country: ca
Re: Capture phase of ac adapter, and use for DC power?
« Reply #13 on: April 23, 2021, 10:27:50 am »
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.
 

Offline theHWcave

  • Contributor
  • Posts: 31
  • Country: gb
Re: Capture phase of ac adapter, and use for DC power?
« Reply #14 on: April 23, 2021, 11:09:42 pm »
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.
 
The following users thanked this post: mindcrime

Offline mayor

  • Regular Contributor
  • *
  • Posts: 182
  • Country: ca
Re: Capture phase of ac adapter, and use for DC power?
« Reply #15 on: April 24, 2021, 12:04:15 pm »
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!
 

Offline theHWcave

  • Contributor
  • Posts: 31
  • Country: gb
Re: Capture phase of ac adapter, and use for DC power?
« Reply #16 on: April 24, 2021, 07:58:24 pm »
No problem.

Why does it go through the rectifier? Assuming you removed the erroneous GND at V1 (as in my initial post), if you trace GND at the end of R3 in your schematic back to V1 you find that it goes through one diode of the rectifier. This messes up the wave form.

BTW, I did a post on PZEM-004T https://www.eevblog.com/forum/testgear/using-a-modified-peacefair-pzem-004t-module-as-cheap-mains-data-logger/msg3553868/#msg3553868 This is why it came to mind when I understood your project  :)
 

Offline mayor

  • Regular Contributor
  • *
  • Posts: 182
  • Country: ca
Re: Capture phase of ac adapter, and use for DC power?
« Reply #17 on: April 25, 2021, 11:24:03 am »
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.
 

Offline gcewing

  • Regular Contributor
  • *
  • Posts: 99
  • Country: nz
Re: Capture phase of ac adapter, and use for DC power?
« Reply #18 on: April 25, 2021, 12:14:20 pm »
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.
 

Offline theHWcave

  • Contributor
  • Posts: 31
  • Country: gb
Re: Capture phase of ac adapter, and use for DC power?
« Reply #19 on: April 25, 2021, 03:59:56 pm »
Yes, that would be another possibility.  :-+
 

Offline mayor

  • Regular Contributor
  • *
  • Posts: 182
  • Country: ca
Re: Capture phase of ac adapter, and use for DC power?
« Reply #20 on: April 27, 2021, 02:00:20 pm »
Great video, great mod, btw!
 
The following users thanked this post: theHWcave


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf