HiHi,
Just wondering, why such an elaborate zero crossing detector?
Only thing I can think of is to synchronize AC load switching with zero crossing. But that's more applicable to solid state load switches (TRIACs, etc.). Relays are too slow.
HiHi,
Just wondering, why such an elaborate zero crossing detector?
But do you need such a complicated circuit to do that? That's all I was wondering. Since I don't know exactly what you want or need from this, I can only suggest a rough circuit you can use. It's always your choice of course.Hi
Only thing I can think of is to synchronize AC load switching with zero crossing. But that's more applicable to solid state load switches (TRIACs, etc.). Relays are too slow.
Hi,at least MrAI , hes decided on a circuit and is moving forward.
I don't disagree Mr Al, it was a rhetorical statement.But do you need such a complicated circuit to do that? That's all I was wondering. Since I don't know exactly what you want or need from this, I can only suggest a rough circuit you can use. It's always your choice of course.
To start, you have an optocoupler. It has an LED internally that when you drive it with maybe 5ma it turns 'on'. Depending on load though, you may get away with even less current.
Now with a full wave rectified sine input, you drive the LED though maybe a 50k resistor. Now the voltage threshold is dependent on the drop of two diodes and one LED. That total drop might be about, let's say, 3 volts. Now 3 out of 325 is less than 1 percent, so the conduction angle will be low. That means you'll get an output signal that goes higher around the zero crossing and stays low above that 3 volts. That's your zero crossing signal.
You can even set the pulse width to be wider by adding an extra diode drop. That ensures a wider pulse to work with.
The error in say calculating the RMS voltage using that signal as a start and end time would be minimal. It could be very low less than 0.1 percent. We can go over that calculation though if you like.
So this circuit requires a full wave rectifier, a resistor on the output that feeds the optocoupler input, and a pullup resistor on the output of the optocoupler. That's pretty simple, but of course you have to figure out if that is good enough for what you are doing.
Hi,Hi
Only thing I can think of is to synchronize AC load switching with zero crossing. But that's more applicable to solid state load switches (TRIACs, etc.). Relays are too slow.
Yes. His circuit shows relays to switch the taps on the (Load) auto-transformer.Hi,
I am not sure what you mean. You mean he is using relays?
Hi,Yes. His circuit shows relays to switch the taps on the (Load) auto-transformer.
I don't think ZCD is useable with relays cause they're too slow. The purpose ZCD is to synchronize the tap switching devices so switching occurs exactly at zero cross every time, to reduce transients. Most fast electro-mechanical relays take about 10-20ms to begin moving the armature and another 5-10ms to transfer the contacts, so at worst 30ms to complete the switching operation once commanded. The designer would also be up against device manufacturing tolerances.Hi,
Oh ok, then I would think he would want to try to time it somehow, if that is possible.
Another possibility is to sense the current in the coil of the relay and use that as feedback in order to adjust future activations. Maybe that would help anyway.
Hi,I don't think ZCD is useable with relays cause they're too slow. The purpose ZCD is to synchronize the tap switching devices so switching occurs exactly at zero cross every time, to reduce transients. Most fast electro-mechanical relays take about 10-20ms to begin moving the armature and another 5-10ms to transfer the contacts, so at worst 30ms to complete the switching operation once commanded. The designer would also be up against device manufacturing tolerances.
Just my humble opinion...
yep.But do you need such a complicated circuit to do that? That's all I was wondering. Since I don't know exactly what you want or need from this, I can only suggest a rough circuit you can use. It's always your choice of course.
To start, you have an optocoupler. It has an LED internally that when you drive it with maybe 5ma it turns 'on'. Depending on load though, you may get away with even less current.
Now with a full wave rectified sine input, you drive the LED though maybe a 50k resistor. Now the voltage threshold is dependent on the drop of two diodes and one LED. That total drop might be about, let's say, 3 volts. Now 3 out of 325 is less than 1 percent, so the conduction angle will be low. That means you'll get an output signal that goes higher around the zero crossing and stays low above that 3 volts. That's your zero crossing signal.
You can even set the pulse width to be wider by adding an extra diode drop. That ensures a wider pulse to work with.
The error in say calculating the RMS voltage using that signal as a start and end time would be minimal. It could be very low less than 0.1 percent. We can go over that calculation though if you like.
So this circuit requires a full wave rectifier, a resistor on the output that feeds the optocoupler input, and a pullup resistor on the output of the optocoupler. That's pretty simple, but of course you have to figure out if that is good enough for what you are doing.
All questions you asked here is solved at least.Thank you
Sorry with so.many hundreds of posts , it's easy to get lost.
So your happy with your AC reading circuit and code.
That's great .
Have you tried it with the range of AC values in your expecting to work over ?
Is the voltage value you decode updated in your code on a fixed period , or randomly as the main loop runs ? I.e. if you add to the main loop , the period between readings would get longer
What is the plan for the output code ?
This I think has to take as input the voltage value , and output control lines to select which relays to activate or not.
Sounds to me like a state machine ?
Trying to implement in HW, but I know how FW is converting it.Hi,
Just wondering, why such an elaborate zero crossing detector?
What I will do if story is going on ? People loves to share knowledge, loves to add more any more no matter its not specific or not. By the way you are not busy now days ?"panic mode, post: 2021705, member: 141873"]
no kidding... 300+ posts.
.the first circuit shown in post #16 is a naive attempt to measure and sync to mains. chosen part is an AC optocoupler with low CTR. that is the reason for lower series resistor and output that resembles rectified AC sine. this optocoupler is meant for only checking AC presence, not measuring amplitude. the good news is that one can sample this signal by ADC and determine voltage as well as zero crossing points. there are also bunch of useless parts (C1,C2,R2)
My code has calibration formula, you can not avoid it because you are handling AC sampling.the bad news is that already bad CTR is only going to get worse and this means need for repeating calibration over time. the same happens if it ever need to be replaced. also since signal is rectified sine wave, there are no steep edges to sync onto. and syncing on peaks is not reliable doe omnipresent noise. so not something i would consider a first choice.
This circuit has ability to attenuated the signal, but other circuit also have larger R values. Good point is we can syncronized sensing A0 and ZCD at pin 2. Better measurement capabilities for sure.the second circuit has more parts but... it is a better, more mature design. it also contains useless parts (R4,D3,D5) thate are only making clutter. one of the advantages of this circuit is that current draw is small due to much larger value of resistor. this optocoupler is DC type but with much higher CTR, so with moderately high value of R3 transistor easily saturates. this means output is digital signal and the shape will be true even with aging. and current limiter sets the current to some 0.4mA so average current is the same but no high peaks. capacitor is charged and discharged slowly which translates to pulse width. falling edge is nice and rather sharp - great for syncing. it is drifting slightly depending on mains voltage but this is negligible (15-20uS over 20ms is under 0.1%) and if needed can be compensated by measured voltage. rising edge is not as steep but measurement will be consistent since sampled by same GPIO. and - no ADC is needed. post #314 talks about synchronisation to every half-cycle which is not true. this circuit only synchronizes to positive half-periods. which is once per period, not half-period.
But do you need such a complicated circuit to do that? That's all I was wondering. Since I don't know exactly what you want or need from this, I can only suggest a rough circuit you can use. It's always your choice of course.
To start, you have an optocoupler. It has an LED internally that when you drive it with maybe 5ma it turns 'on'. Depending on load though, you may get away with even less current.
Now with a full wave rectified sine input, you drive the LED though maybe a 50k resistor. Now the voltage threshold is dependent on the drop of two diodes and one LED. That total drop might be about, let's say, 3 volts. Now 3 out of 325 is less than 1 percent, so the conduction angle will be low. That means you'll get an output signal that goes higher around the zero crossing and stays low above that 3 volts. That's your zero crossing signal.
You can even set the pulse width to be wider by adding an extra diode drop. That ensures a wider pulse to work with.
The error in say calculating the RMS voltage using that signal as a start and end time would be minimal. It could be very low less than 0.1 percent. We can go over that calculation though if you like.
So this circuit requires a full wave rectifier, a resistor on the output that feeds the optocoupler input, and a pullup resistor on the output of the optocoupler. That's pretty simple, but of course you have to figure out if that is good enough for what you are doing.
so what is the plan for the code / hardware to take your voltage reading to control your relays ?All questions you asked here is solved at least.
#314Which of the circuit parts is complicated to you? Post #16 or #293? You want me to use full wave rectifier in which configuration ?
Simple is always a beauty! But very simple fails in market, for that reason people use post #16#314
I am not saying to definitely use the alternate idea, just to consider a simpler solution.
This one is very easy:
Use a full wave rectifier to rectify the input sine.
Connect a resistor from the positive output and to the optocoupler input (LED).
The output of the opto still needs a pullup, as large as you can get away with so you can make the input resistor as high as possible.
I was asking if that would work for your application also.
It's great you have decided on a final input circuit. It's not my favourite as others have explained, but it will probably do for your application , esspecialy in simulation .Simple is always a beauty! But very simple fails in market, for that reason people use post #16
Professor @drjohsmith It has been said several time to see my code in the post, but may be you are tired on watching same thing.so what is the plan for the code / hardware to take your voltage reading to control your relays ?
// Relay pins (adjust as needed)
int relayPins[8] = {2, 3, 4, 5, 6, 7, 8, 9};
// Calibration factor
float calibration = 0.52; // Adjust after testing
// Delay between switching (ms)
unsigned long switchDelay = 1500;
// Track last switching time
unsigned long lastSwitch = 0;
Using a full wave bridge will give you average and not true RMS, so what did you want?Average-responding meters (or averaging RMS) are digital multimeters that measure the average value of an AC signal and multiply it by a scaling factor (
) to estimate the Root Mean Square (RMS) value, assuming a pure sine wave. They are accurate only for pure sine waves and often inaccurate for distorted waveforms.