 # How do i make readings from a high voltage AC source

How accurately must you detect the zero crossings? If you got a 200V input would a detection at +/- 2 Volts be OK. Or should it be +/-200mV?.

How much delay can you afford between the mathematical zero crossing and the time you detect it?

A symmetrical 20Hz signal gives you 40 zero crossings per second (every 25ms).

My idea of using a voltage divider (see my previous post) does not work when you have to detect the zero crossing as soon as possible. The voltage divider would not give you the required accuracy.

If all you want to do is to simply detect the zero crossings with maybe a delay of several milliseconds my solution would be an easy to implement solution.

If the timing is imporant, you will need a voltage comparator (special OP-Amp). The bad thing about this solution is that you would need a split voltage supply.

However, a simple lowcost ICL7660 will give you a negative voltage and a couple of milliamperes to feed your comparator chip. A rail-to-rail comparator with a single voltage source will not do the job, because you would need measurements in the one digit millivolts range (referenced to ground).

arduinoaleman

polymorph: How about an NE2 bulb with resistor, heat shrink to a phototransistor?

You said this is a 20Hz sine wave. Continuous? If so, you could use the time that the NE2 turns on and off again to determine the approximate zero crossing. The NE2 turns on at a somewhat higher voltage than it turns off, so it'll be just a bit before the halfway point when the NE2 is dark.

How accurate must this be?

Or are these individual pulses, arriving at about 20Hz rate, but the pulses are much faster?

Yes this is a continuous sine wave. Its not enough to simply detect the zero crossing though, I need to detect the zero crossings from the piezo and then turn on a switch that is connected to some control circuitry every time this happens.

Accuracy is pretty important.

arduinoaleman: How accurately must you detect the zero crossings? If you got a 200V input would a detection at +/- 2 Volts be OK. Or should it be +/-200mV?.

How much delay can you afford between the mathematical zero crossing and the time you detect it?

A symmetrical 20Hz signal gives you 40 zero crossings per second (every 25ms).

My idea of using a voltage divider (see my previous post) does not work when you have to detect the zero crossing as soon as possible. The voltage divider would not give you the required accuracy.

If all you want to do is to simply detect the zero crossings with maybe a delay of several milliseconds my solution would be an easy to implement solution.

If the timing is imporant, you will need a voltage comparator (special OP-Amp). The bad thing about this solution is that you would need a split voltage supply.

However, a simple lowcost ICL7660 will give you a negative voltage and a couple of milliamperes to feed your comparator chip. A rail-to-rail comparator with a single voltage source will not do the job, because you would need measurements in the one digit millivolts range (referenced to ground).

arduinoaleman

I've tried to use the ua741 as a comparator (like the one in this site: http://www.circuitstoday.com/op-amp-comparator) since this was easily available in the lab that im at. However, the output is not correct at all and the transitions to positive saturation do not happen at the zero crossing.

Accuracy is important. The switching needs to happen exactly (or as close as possible) at the zero crossing. Would I get better performance if i used some other IC instead? Like the one that you have suggested. I'm still not sure why the ua741 does not give me accurate pulses though since the input is only 20hz.

Is it not possible to implement this using the arduino at all btw? Would it not work if i used some sort of voltage divider and then a DC offset to make a 5V peak to peak input?

TomGeorge: Hi,

You started by talking about a piezo "damper", can you tell us the full application. What is the damper connected to and what do you want the output of the arduino to control. In other words what is the full application of your project.

What is the piezo you are using, and a picture of your project or its components will help immensely.

Tom..... :)

Working on a vibration damper using piezoelectric ceramics. its basically to reduce vibration in beams etc. There is one piezo patch that acts as a sensor (this is what generates my input 20hz sine wave) and then there is another piezo which acts as a controller. Every time the sensor piezo gives me a zero crossing i need to be able to turn on a switch that completes the circuitry attached to the control piezo which will increase the rate at which the beam gets damped and thus reduce the vibration.

Also, once i manage to detect the zero crossings and generate some sort of a pulse when they happen, is it enough to use a relay for completing the control circuit (this basically consists of the control piezo and an inductance)?

How can you recommend a circuit or solution if you don't know the exact specs of the sensor. Is this a common 1" piezo disc/buzzer, or some special sensor. Piezos have problems with low frequencies. Their self-capacitance and the load resistance creates a high pass filter. You might have to "load" a piezo with 20-100megohm to detect 20herz reliably. Post detailed info about the piezo first.

Did you think of using a contact speaker as pickup. Leo..

If you can live with the fact that my circuit (see attachment) will detect the zero crossings at 0.8 Volts instead of 0 Volts you will have a solution that requires only 4 parts.

The voltage in a sinewave is rising/falling extremely fast near the zero crossing point. When your input signal is 200 volts, 0.8 volts is very close to the mathematical zero crossing point.

All you need: 2 resistors, one high voltage diode, one 4.7 Volts zener diode.

The high voltage diode will cut out the negative half wave. So you do not have to deal with a negative voltage.
R1 and R2 are a voltage divider. However, the 4.7 Zener diode will not allow for higher voltages than 4.7 volts across R2 (Arduno analog input).
So only when the input voltage will drop below 5.4 Volts (4.7 zener and other diode´s 0.7 volts drop) the resistor network will work as a linear voltage divider. A linear voltage divider (my original idea in a post earlier in this thread) would not allow for enough accurancy.

So when you have a 0.8 volts input signal (very close to the zero crossing) you will see 50mV at resistor R2 (feeding the arduino input) - you lose 0.7 at the diode and the other half of 100mV on R1.

50mV is good enough for an Arduinos analog input to be analyzed.

Be careful - the Arduino can give you a DAC (digital-analog-converter) output of 0 thru 1023. However, you will rarely see “0” on account of voltage drops on the signal and power lines. So use a value that is a litte bit higher when it comes to “detecting” the zero crossing.

If 0.8 volts are not accceptable and you want to define your zero crossings at 0.5 volts you might use a Schottky diode as your rectifier diode (0.4 volts voltage drop instead of 0.7).
However, they have a higher reverse leakage current and might create a negative voltage on R2 during the negative halfwave of your input signal - this would be very bad for your Arduino.

And being so close to the zero crossing point I think there will not be much difference.

As far as the rest of your project is concerned, I hope other people will support you.

One last hint:

Do not use mechanical relays when it comes to speed.

200voltszerocrossing.pdf (85.8 KB)

100k resistors might give random readings, because the A/D likes to see <= 10k on it’s input.
200k might load the unknown piezo, so what will be it’s phase shift…

No real experience with this kind of problem, but I would try a (mid-biased) charge amp circuit.
Leo…

you may be right.

however, 10 kiloohms would be too low in this case. the input voltage is up to 200 volts and would fry a standard resistor and overload the zener diode.

as long as you do not touch the input signal you will not have a changing capacitive load. and you better do not touch a wire that gives you voltages up to 200 volts.

if both resistors are close to the analog input (important with these high resistor vales) you will not have a problem

Piezo devices are very hi impedance voltage sources. Without any specs of the piezo, its impossible to know how to connect it to anything. Simply connecting a random resistive divider will load the piezo down so that its output waveform will simply not resemble the unloaded waveform.

I have always assumed that the input impedance on the A/D pins had to be low (>= 10K). Otherwise you would be punished with reading errors.

So I wrote a volt meter test sketch. It takes a sample every second from pin A1.

A0 was not used, bacause that was connected to the buttons of the LCD shield. UNO r3, with 9volt supply on the DC jack.

Measured a ~4.5volt battery directly... 4.500volt Measured the battery through a 10k resistor... 4.500volt Measured the battery through a 470k resistor... 4.500volt Measured the battery through a 1meg resistor... 4.500volt Measured the battery through a 10meg resistor... ~3.900-4.100volt Mainly because of hum being pickup up by the wiring and the resistor. During the test, I grounded and connected ajacent analogue pins to +5volt. Only when I used the 10meg resistor it made some difference.

??? Leo..

Atmega 328P. ADC is specified as having a 100 MΩ input impedance. page 323, Rain "The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. If such a source is used, the sampling time will be negligible."

LarryD: Atmega 328P. ADC is specified as having a 100 MΩ input impedance. "The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. If such a source is used, the sampling time will be negligible."

So maybe for fast signals, and not for DC (or very low frequencies). Leo..

Measured the battery through a 10meg resistor... ~3.900-4.100volt

I always add one, because I have been told to, but this time I didn't. And the results were the same. Leo..

arduinoaleman: If you can live with the fact that my circuit (see attachment) will detect the zero crossings at 0.8 Volts instead of 0 Volts you will have a solution that requires only 4 parts.

The voltage in a sinewave is rising/falling extremely fast near the zero crossing point. When your input signal is 200 volts, 0.8 volts is very close to the mathematical zero crossing point.

All you need: 2 resistors, one high voltage diode, one 4.7 Volts zener diode.

The high voltage diode will cut out the negative half wave. So you do not have to deal with a negative voltage. R1 and R2 are a voltage divider. However, the 4.7 Zener diode will not allow for higher voltages than 4.7 volts across R2 (Arduno analog input). So only when the input voltage will drop below 5.4 Volts (4.7 zener and other diode´s 0.7 volts drop) the resistor network will work as a linear voltage divider. A linear voltage divider (my original idea in a post earlier in this thread) would not allow for enough accurancy.

So when you have a 0.8 volts input signal (very close to the zero crossing) you will see 50mV at resistor R2 (feeding the arduino input) - you lose 0.7 at the diode and the other half of 100mV on R1.

50mV is good enough for an Arduinos analog input to be analyzed.

Be careful - the Arduino can give you a DAC (digital-analog-converter) output of 0 thru 1023. However, you will rarely see "0" on account of voltage drops on the signal and power lines. So use a value that is a litte bit higher when it comes to "detecting" the zero crossing.

If 0.8 volts are not accceptable and you want to define your zero crossings at 0.5 volts you might use a Schottky diode as your rectifier diode (0.4 volts voltage drop instead of 0.7). However, they have a higher reverse leakage current and might create a negative voltage on R2 during the negative halfwave of your input signal - this would be very bad for your Arduino.

And being so close to the zero crossing point I think there will not be much difference.

As far as the rest of your project is concerned, I hope other people will support you.

One last hint:

Do not use mechanical relays when it comes to speed.

that seems to be the best option for me. I will try to implement this and get back to you with the results :D

If I require even more accuracy (i probably wont) I guess I could add some sort of a DC offset of 0.5 volts or something. But I think this would be accurate enough.

Hi, If you will have to have a threshold, otherwise you will be detecting noise, rather than signal zero crossing. 0.8V in 200V is damn good.

InvSin(0.8/200) = 0.229 Deg from zero crossing.

I could be wrong,

Tom.... :)

Thanks for doing the sinewave math calculation. It was 4 o clock in the morning when I wrote this article and made a hand drawing of the circuit so I could attach it.

I believe that your calculation is absolutely right. And even if ist was not, 0.8 Volts in a 200V sinevave is damn close to the zero crossing point.

I have to admit I have no idea how a 100 kilo ohms voltage divider (see comment below why it is not 200 K) will change the output of the piezo element.

I could simulate the input signal with the current provided by our electricity provider (220 Volts in Germany). However, the output of this signal could give me up to 16 amperes before the fuse blows (not in a circuit with a voltage divider in the 100 kilo ohms range of course). Do not write a post to tell me 220V are letal. I did all the electrical wiring in our house. In other words, the input voltage of my testing setup would not even change its voltage or signal form even if i would use 22 ohms 100 watts resistors. So all I could simulate is the input voltage, but not the waveform, the freaquency (50 instead of 20Hz) and the stability of your piezo element.

So the remaining question is, how will R2 (100 kilo ohms) influence/change the output signal of the piezo element. The zener diode will shortcut R1 until the voltage is is in the 10 volts range. Your piezo element will see a 100 kilo ohms load most of the time.

If 100 kiloohms are not enough, you might try two 1 mega ohms resistors.

i would NOT use any capacitor at the arduino input. A 100 kiloohms or larger resistor will need SOME time to get it loaded. This results in a phase shift. So the time when you discover the zero crossing would be much later.

A capacitor at the analog input is very helpful when you have DC voltage and noisy inputs.

The only problem I can see with my design, is that a cable going from the piezo element to my voltage divider can pick up environment noise from electrical cable (50 or 60 Hz usually). 200 milliVolts would be enough to ruin the design.

When the piezo gives you 200 volts - you will not even notice the voltage overlay. When the piezo element gives you zero volts, the 200 mV overlay will be broken down to 100mV by the voltage divider.

My design was originally designed in such a way, that 50mV will be the detection point.

In that case shielded cables will help.

And this problem will also be existent in designs using OP-Amps and comparators, because you have to break down the voltage of 200V to a max of 15V anyway (using a voltage divider).

arduinoaleman

This post is not dealing with this thread directly.

It deals with some wrong conceptions in this thread.

I am NOT professor Einstein - There are many things I do not know.

1)

A capacitor at an analoge input of the Arduino is very good when the input is DC (direct current).

2)

A capacitor needs some time to load and if you want to measure an AC voltage level, the capacitor will give you wrong readings. The voltage level you would see (reading analog Arduino input) depends on the frequency of the input signal, the frequency how often you measure the input signal, the resistors and the size of the capacitor. So you might see anything from rain to sunshine.

The only exception are very very small capacitors to filter high frequency noise.

3)

Even if you do not use a capacitor, measuring the voltage of an AC input signal (like a sine wave) only makes sense, if you want to analyze the waveform or detect a certain voltage level.

4)

If you want to detect a certain voltage level for switching another device, you should know that a resistor in front of a capacitor (like in combination with a voltage divider) will give you a phase shift - something you will not want to have. If you know the frequency you can compensate for this. Otherwise good luck.

arduinoaleman

My knowledge comes from other peoples knowlegde - i have not invented anything that comes near to Ohm´s law. I have just tried to understand things and pass them on. I am still learning from other people´s posts. Lots of things I have never tried so far. We can only learn from each other.

Arduinoaleman - good post.

Curiosity14, what do you mean by "as close as possible"?

Back to reading this unknown sensor.
After some googling and educated guessing, I personally think it’s best to use just 3 resistors and a cap. No diodes or zeners.

Three 1-10meg resistors connected to an analogue input.
One to ground, one to +5volt, and one to a 10-100n/100volt cap.
Other side of the cap to the piezo (cap keeps DC off the piezo).

All the parts close to the Arduino , and a short shielded lead to the sensor.
Take care, these high impedances easilly pick up hash/hum.

The software should read ~512 from the analogue pin with no signal (= zero crossing).
You might have to program a “window”, e.g. 510-514, for your zero crossing detection.
Higher resistor values might have less phase shift at those low frequencies with those unknown sensors.
Leo…

What makes you think I know everything.

If you read all my last posts, you will see that I have tested this common 10k rule, and found opposite results.
I did measure a battery with an analogue pin, and had the same readings with very high value resistors.
Still not sure what to think about it.

I know, from using piezos with instruments, that you can’t “load” them if you want to read low frequencies.
How much is still unknown, because OP hasn’t posted the piezo’s capacitance.

I also know that protection zeners are useless when the device is off.
And I have been told that all the inputs have protection diodes to ground and supply.
If you limit the current to 1mA, any input signal will clamp at ~5.5volt and -0.5volt.
3x 10megohm should protect to more than 1000volt, positive and negative, if the resistor would be able to handle that.
Leo…

Edit: I think arduinoaleman has deleted the post before this one…