Get it right the first time & learn smarter today

# The Zero Crossing Detector Engineering Essay

Disclaimer: This work has been submitted by a student. This is not an example of the work written by our professional academic writers. You can view samples of our professional work here.

Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of UK Essays.

Published: Mon, 5 Dec 2016

The X 10 transmitter sends data timed with the zero crossing of the power line, thus each unit needs to have a built-in zero crossing detectors. Mainly, the X10 manufactures are using PIC16F8XXX family to detect zero crossing by applying the external interrupt on the RB0 pin, which links to the power line through 5M resistance (to limit the current into the PICmicro) as it is shown in the figure 00.

The PICmicro has a protection diodes which are designed to clamp any voltage higher than VDD or lower than VSS. Thus, when a negative half cycle of the AC voltage is applied, the RB0 pin clamps the voltage to VSS – 0.5V, this can be interpreted as a logic-0. At the same time, as the AC voltage rises to or over VDD, the logical value will become logic-1. RB-0 is configured for external interrupts, whereas the input buffer is a Schmitt trigger. Therefore, the input threshold (0.2 VDD = 1V) on the falling edge and (0.8 VDD = 4V) on a rising edge. So there is an interrupt occurs on every zero crossing.

The following equation is used to calculate the RB0 pin state which will change in relative to the zero crossing

V = Vpk*sin(2*ƒ•*f*t), where Vpk = 320Vand f = 50 Hz

On the rising edge, RB0 can go high about 64 µ s after the zero-crossing. However, on the falling edge, it can go low about 16 μs before the zero-crossing.

## 120 kHz Carrier Generator

X-10 transmitters use 1msec bursts of a 120 kHz to send information over 50 Hz power lines. Different techniques could be used in order to generate 120 kHz, however, in x10 units are mainly use one of the PICmicro MCU’s CCP modules as it is shown in the figure100. The CCP (Capture/Compare/PWM) module of PIC 16F67xA is used in PWM mode to produce a 120 kHz square-wave with a half duty cycle of (50% of the duty cycle). In order to generate the carrier frequency of 120 kHz, the system oscillator capacity was chosen to be 7.680 MHz,

Where the frequency of the PWM is the inverse of the period (1/period)

And since one instruction is taking four oscillation periods we come up with the term of 4Tosc

Main oscillator is 7.680MHz, Tosc = 1/7.680MHz

PWM period = 1/120 kHz = 8.333µs

PWM period = [(PR2) + 1] * 4 * Tosc * (TMR2 prescale value)

= [(0) + 1] * 4 * 1/7.680MHz * (16) = 8.333µs

After initialization, the CCP (Capture/Compare/PWM) is always enabled, and the register TRISC bit is used to gate On and Off the PWM output. By sitting the TRISC bit = 1, then the pin is an input and the 120 kHz signal is blocked and not accessible to the pin, other than When the TRISC bit = 0, the pin becomes an output and the 120 kHz signal is free and coupled to the AC power line. Before the 120 kHz coupled to the powerline, it will pass through 200â„¦ resistance, a transistor amplifier and high pass filter as depicted in the Figure 5.

Since the impedance of a capacitor is Zc = 1/(2*ƒ•*f*C),

If f = 120kHz

Zc = 1/(2*ƒ•*120k*0.1*10-6)

If f = 50kHz

Zc = 1/(2*ƒ•*50k*0.1*10-6)

The capacitor of the high pass filter is equal to 0.1 μF which presents low impedance to the 120 kHz carrier frequency, but with 50 Hz power line frequency it will present high impedance. Therefore high pass filter will safely couple the 120 kHz signal to the 50 Hz power line. Finally, the 12 kHz signal should well match with the synchronize of zero crossing with maximum delay about 300 μs from the zero-crossing to the beginning of the X-10 envelope in order to be compatible with other x10 receiver.

Since the maximum delay of the zero-crossing detector = 64 μs

300 μs – 64 μs = 236 μs

Thus the firmware must begin the transmission of the 120 kHz envelope with maximum time of 236 μs after detection of the zero-crossing to.

## 120 kHz Carrier Detector

In order to receive a x10 signal, it is essential to detect the presence of the 120 kHz signal on the 50Hz AC power line. This application requires a specific hardware structure which? contains three blocks placed between the PIC and the power line and subsequence the 120 kHz carrier will bass through all of them to reached RC pin of the PIC. The first block from the power line side is the decoupling capacitor which contains e a 0.1µ capacitor in parallel with 1Mâ„¦ resistance. The next one is the high bass filter and the final one is the envelop detector which is connected to the PC pin of the PIC as it shown in figureXX.

Since the impedance of a decoupling capacitor is Zc = 1/ (2*ƒ•*f*C),

If f = 120 kHz

Zc = 1/ (2*ƒ•*120k*0.1*10-6) =1/ 0.075 = 13.26 â„¦

Zc of 120 kHz = 13.26 â„¦

If f = 50 kHz

Zc = 1/ (2*ƒ•*50*0.1*10-6) = 1/31×10^-6 = 32.25 k â„¦

Zc of 50 Hz = 32.25 k â„¦

The capacitor of the decoupling filter is equal to 0.1 μ farad which is presenting low impedance (13.26 â„¦) to the 120 kHz carrier frequency, but with 50 Hz power line frequency it will present high impedance (32.25 k â„¦). Therefore the decoupling filter will safely couple the 120 kHz signal detector to the 50 Hz power line and allow only 120 kHz to bass through it. The next block is another high pass filter, design an RC filter that will pass only 120 kHz carrier and attenuate the entire 50Hz. The second high pass filter scheme is shown below

Where the high pass filter characteristics is shown in the next scheme

ωp is the passband edge of the high pass filter

ωp = 1 / CR where C = 150 pF and R = 33 k â„¦

ωp = 2 ƒ• fp

fp = 1 / 2*ƒ•*C*R

fp = 1/(2*3.14*33*10^3*150*10^-9).

fp = 32 kHz.

Where, fp is the frequency of the passband edge that will assures all the 50 Hz signal is completely attenuated, at the same time as the 120 kHz signal is passed through the filter to the amplifier stages. The signals are inter the amplifier stage with a value between ten millivolts to a few hundred millivolts. The module must amplify the carrier to certain limit and converted to a logic level signal that the PIC can detect. The amplification, however, must be carefully selected in order to prevent the signal will pass through the first stage which is the tuned amplifier stage where the 120 kHz signal is amplified by using a series of 4069UB inverters to configure as high gain amplifiers. The tuned amplifiers operate with peak response at 120 kHz at the first two stages while the next two stages are untuned amplifier but provide additional amplification. The amplified 120 kHz signal is passed to the envelope detector block which is containing a diode, capacitor, and resistor. The output of the envelope detector is buffered through an inverter and finally the inverse of the amplified 120 kHz is presented to an input pin (RC3) of the PIC16F8xxx. When the zero crossing is interrupt the RC3 will checked to see whether or not the carrier is present within the 1 ms transmission envelope. A stream of 1 volt is representing the presence of the carrier while 0 is the absence of the carrier.

Transformerless Power Supply

X10 modules used PIC16F877A or any other PIC requires a 5V supply to feed the board circuit. Since X-10 units are intended to be plugged into a wall outlet, a transformerless power supply is used to provide the require voltage.

There are two significant characteristics of transformerless supplies that should be kept in mind: lack of isolation from the 240 volt AC and limited current capacity. Figure00 illustrates the transformerless power supply diagram used in this application. As it shown in figure00, a 220v VDR (voltage dependent resistor) being and connected between Line and Neutra to protect the circuit from spikes on the AC power line. 1Mâ„¦ resister connects in parallel with two capacitors to provide a discharge path for the voltage left on the capacitors when the module is unplugged from the wall. The voltage across 1000Mfarad was rectified by using two diodes and finally a 5.1V Zener diode to produce a 5V supply for the circuit.