Sie sind auf Seite 1von 4


Speed Sensor MOC7811

This is an optoelectronic sensor. It consists of an IR emitter and a photo detector. It is a slotted
coupler which is moulded in the same case. The detector is a photo transistor which turns on
when it receives an IR pulse from the emitter. Thus a disc connected to the shaft of the WEG is
allowed to run between the slots. Thus a pulse train is obtained which is proportional to the
speed. Thus speed can be sensed [4].
3.3.1. Testing of Speed Sensor
As per the requirements an optoelectronic sensor is selected the features of which are
mentioned above. The following is the test circuit of the speed sensor which is given in the

Fig 6 : Testing of speed sensor

The output pulse coming out of the sensor is visualised across the emitter and the ground
and the corresponding voltage value across the terminals is also measured. The usage of
reflective type sensors without the usage of disc is not done because of the complexity involved
in placing the sensor close to the machine for sensing the speed.
3.4 Chopper

The chopper required with the dummy load can be fabricated with either Thyristor or
MOSFET the latter is a better option if rated current requirements are not very high. A grid
power failure will be reflected as reverse power flow towards the grid which anyway will be
sensed and preventive measure; increasing dummy load current will be adopted by the controller.
This control action can also be modified to isolate the WEG in case of islanding.
3.5 Selection of the Micro-Controller
The controller has three main functions:
Sense the speed of the WEG thereby determining the mode of operation of the machine.
The speed is sensed from the width of the pulse train given by the speed sensor

(MOC7811). Hence a speed sensor code is realized and tested in the laboratory.
Calculate the frequency of the grid, based on this frequency it has to operate the chopper
to prevent the excess power flow to the grid. This frequency is calculated from the input
given from the step down transformer and can be calculated by using the ADC module in

the controller [5].

Generate the PWM signals which serve as the duty ratio to the chopper. The pulse width

of the PWM signals depends upon the frequency increases from the base frequency.
To suite the above specifications of the controller we go in for PIC16F877A

This is capable of performing the above all the above tasks. The following components in the
PIC enable us to perform the above tasks:
The Compare, Capture, PWM module (CCP module) is used to measure the pulse width
of the incoming pulses from the speed sensor. It uses the capture module to capture the
rising edge of each pulse. The time difference between two rising edges gives the time

period of the pulse from which the speeds can be measured.

The PWM signals can be easily generated by the PIC. The TMR2 can be used to generate
the PWM signals of required pulse width. This can be used to control the chopper duty
ratio, thereby the power flow to the dummy load.

Its ease of operation has led to selection of PIC16F877A.

3.6 Algorithm for frequency sensing

Step1: Start
Step2: Initialization function, Configure the port C as input (RC2 pin).
The interrupt register CCP1 is initialized for capture mode. The ports of TMR1 are cleared and
enabled. TMR1 is initialized with a prescaler value of 1:8
Step3: Interrupt function, clear the interrupt, switch on the timer and switch off the timer. Clear
the CCPR1H, CCPR1L register.
Step4: Calculation function, check the captured timer value with base values and generate the
PWM pulses according to the input frequency. Base values should be in hexa decimal so that
easily compared with the captured value.
Step5: output of pic will be PWM pulses from the pin CCP2(RC1) pin is given to the gate driver
3.7 Algorithm for Speed Sensor
As mentioned earlier, the speed sensor used is optoelectric sensor (MOC7811). The
sensor senses the speed and the output is sent to the PIC16F877A where the calculation of speed
is performed. The algorithm and the coding for the calculation is given below.

The following is the algorithm of the speed sensor,

Step 1: Start
Step 2: Initialization function, configuring the ports and timers for initial operation
A) Port B and Port D of the microcontroller are initialized as output ports.
B) The interrupt register CCP1 is initialized for capture mode.
C) The ports of TMR1 are cleared and enabled
D) TMR1 is initialized with a prescaler value of 1:8
Step 3: Interrupts and interrupt function, capturing the pulse
A) When rising edge is detected it is captured by CCP1 and the TMR1 values are
stored in variables a1 and b1 initially.
B) When rising edge occurs again the CCP captures the value and stores the
corresponding values in a and b

Step 4: Calculation function, calculating and displaying the speed

A) The difference of a, a1 and b, b1 respectively gives the pulse width
B) The value obtained is in hexadecimal, so it is converted into a 16 bit value.
C) The time period (In ms) of the pulse is calculated.
D) The speed (In RPM) is calculated from the time period.
Step 5:
A) The 16 bit value obtained is converted into four 8 bit values.
B) The values are passed on to the look up table which displays the speed through
four individual 7 segment displays.
Step 6:
The TMR1 values are cleared again.
Step 7:
The control waits for the next interrupt to occur. When it occurs go to step3.