Activity How The Half Wave Rectifier Program Works

Remember our floor and superstructure analogy from the earlier part of this manual. Well, by commenting out these calls, what we've done is sealed off the first three floors of our software building while we work on the final two floors, just as we sealed off the Battery Charger experiment on the first floor while we worked with the solar cells. Also notice how simple, yet elegant, this is. By just a single comment in each call to Exp_1, Exp_2 and Exp_3 we have effectively disabled their software actions, since the BASIC Stamp program will skip these calls entirely and branch directly to Exp_4. Make a note of this software technique because professional programmers use it all the time to segment their programs for debugging and, also, to bring in or take out elements of the program at the proper times. So now that the DC experiments are "patched out", let's continue with our current experimental code.

First, look at what we added to the Declarations section:

sampleCount VAR waitCount 'Nib sampleArray VAR Byte(10)

The nibble variable, sampleCount, counts the number of times the A/D converter samples voltage readings (up to 16 counts max, the capacity of a nibble). Again, we are re-using variable space from a subroutine that won't be called in this experiment. Next comes sampleArray, a ten-element array for storing these converted voltage values. Don't worry too much about understanding these variables right now; their meanings will become clearer once you see them in the body of the code, which we'll get into right now.

a2dMuxId = A2dMuxId3 IF (sampleCount <> 10) THEN

GOTO Exp_4_Plot ENDIF

At Exp_4 the first instruction sets the A/D converter to CH3 (pin 6). The next instruction tests sampleCount for any value other then 10. If sampleCount is not 10 it implies that a previous sample of A/D values have been taken, so the program branches to the Exp_Plot label. However when sampleCount does equal 10 the if...then statement fails and the program prepares to take another 10 samples beginning at Exp_4_Wait_For_Zero.

Exp_4_Wait_For_Zero: GOSUB A2D

GOTO Exp_4_Wait_For_First_Peak

ENDIF

sampleCount = sampleCount + 1 IF (sampleCount = 10) THEN

GOTO Exp_4_Take_Samples ENDIF

GOTO Exp_4_Wait_For_Zero

The code segment under Exp_4_wait_For_zero gets a little ahead of our experiment at this point since the concept of a "smoothing capacitor" hasn't been introduced as yet. Nevertheless, the primary function of the code is to detect when the half wave rectified wave goes to zero. What we're trying to do is "sync up" to the next positive going wave that comes along, but in doing so we first need to find out where we are on the wave at this point. If the value of the A/D converted voltage is above zero (actually 0.10 volts where 5 * 0.02volts/bit = 0.10 volts due to possible biasing conditions) we may have captured the wave somewhere during its positive cycle. Or it may never go to zero if a smoothing capacitor is attached (there's more to come on this, so be patient). To properly sync up, we need to capture the wave at the very beginning of its positive cycle, and this is why we need to first capture the zero part of the wave; that is, to ensure that we will begin our samples at the beginning of the next positive wave cycle, which is what the code under Exp_4_Wait_For_First_Peak does.

Exp_4_Wait_For_First_Peak: GOSUB A2D

IF (a2dResult > 5) THEN Exp_4_Take_Samples GOTO Exp_4_Wait_For_First_Peak

Exp_4_Take_Samples:

FOR sampleCount = 0 TO 9 GOSUB A2D

sampleArray(sampleCount) = a2dResult NEXT

sampleCount = 0

When the code branches to Exp_4_Take_sampies we are "synced up" with the next positive wave. Therefore, the remaining code takes ten (0 - 9) A/D samples as quickly as possible and stores them to sampieArray. Once this is done, the sampleCount is reinitialized to zero so that the Exp_4_Piot routine can begin at the first sample of this group.

Exp_4_Plot:

ch3 = sampleArray(sampleCount)

sampleCount = sampleCount + 1

Exp_4_End: RETURN

The Exp_4_Plot routine reads the next value of converted data from the sampleArray into variable ch3 and increments sampleCount for the next time through Exp_4. The Plot_It routine handles the plotting of the ch3 value. The sampleCount is incremented to the next sample and the program exits. When sampleCount increments to the value of 10, the first part of the program under label Exp_4: detects this and will refresh the display by taking ten new samples.

Your Turn: Sampling and Displaying the Half Wave Rectifier Voltage Outputs

In order to take some reasonable samples of the half wave rectifier output, the table fan should be turning the turbine blades at a reasonably fast rate, and the stator should be securely fastened to a flat surface.

V Arrange your wind turbine and table fan so that the turbine blades are turning steadily and briskly.

V In the BASIC Stamp Editor, run Half-FullWaveRectifier.bs2, make a note of the COM port being used, then close the Debug Terminal.

V Open StampPlot Pro by clicking on Start ^ Programs ^ Parallax Inc ^ StampPlot ^ Experiments with Renewable Energy ^ sic_ewre_exp_45.spm.

V Set the COM port in StampPlot to the same one that was being used by the Debug Terminal.

V Click on the Connect button, and make sure the Enable Plotting box is checked.

What follows is the plot of half wave rectified voltage values using StampPlot (Figure 514).

Figure 5-14: StampPlot Plot o f Half Wave Rectified Voltage

Depending on how fast your turbine is spinning your plot should look close to, but not exactly like this one. Figure 5-14 used a 12 second time segment to capture this sample. As you can see, the plot shows a series of sharp peaks followed by flat, no voltage readings in between the peaks. If you were using an oscilloscope the plot would produce a much smoother waveform like that shown in Figure 5-15.

Figure 5-15: Oscilloscope Plot of Half Wave Rectified Voltage

What our program has done is to very quickly capture multiple samples of the half wave rectifier voltage data so that it can be displayed much more slowly using StampPlot. Remember we said earlier that StampPlot is not as fast as an oscilloscope. Therefore, in order to make allowances for its lack of display speed, StampPlot displays one sample every 250 milliseconds, the speed of the Plot_It routine. Try adjusting the fan speed to witness what happens to the peak values of the wave and the time between peaks. The slower the fan speed, the lower the voltage peaks and the longer the time between peaks.

Your Turn: Smoothing Things Out

To get closer to the performance of a true linear DC power supply we need to begin to smooth out the half wave rectified peaks. This is done by adding a "smoothing" capacitor to the output of the circuit as shown in Figure 5-16. By adding a 1000 ^F "polarized"

capacitor, the half wave rectified peaks will become much smoother and approach a nearly constant DC level.

Additional Parts Required

(1) 1 kQ resistor (brown black red) (1) 1000 ^F electrolytic capacitor

Warning: This electrolytic capacitor has a positive (+) and a negative (-) terminal. The negative terminal is the lead that comes out of the metal canister closest to the stripe with a negative (-) sign. Always make sure to connect these terminals as shown in the circuit diagrams. Connecting one of these capacitors incorrectly can damage it. In some circuits, connecting this type of capacitor incorrectly and then connecting power can cause it to rupture or even explode.

V Disconnect power to your Board of Education.

V Add the 1000 ^F capacitor to your circuit as shown in the schematic in Figure 5-16 Because the capacitor is polarized, meaning that it has a positive (+) and negative (-) terminal, take care to add the capacitor correctly as illustrated in Figure 5-17.

V Check your wiring before reconnecting power to your circuit.

ADC0834

ADC0834

Figure 5-17: Half Wave Rectifier with Smoothing Capacitor Wiring Diagram
Figure 5-18: StampPlot Plot of Smoothed Half Wave Rectifier Output

Now, if you re-run your program and view the output in StampPlot, you should see something like Figure 5-18. The equivalent oscilloscope plot is in Figure 5-19.

V Re-run Half-FullWaveRectifier.bs2.

V Close the Debug Terminal, and then bring up StampPlot and connect.

Figure 5-19: Oscilloscope Plot of Smoothed Half Wave Rectifier Output

Notice that the waveform peaks and then slowly begins to decay but never goes to zero. The reason for this is explained next. Please refer to Figure 5-20 as a visual aid to understanding the following textual explanation.

1N4148

AC Input

1N4148

AC Input i kn^

AC Output

1000 |JF

Vss Vss

Figure 5-20: Effects of Smoothing Capacitor on Half Wave Rectified Output

When the rectified positive wave forward biases the diode, part of the current flows through the 1 kQ load resistor and the remaining part charges the smoothing capacitor to nearly the peak value of the AC Output between A and B. As the peak of the AC Output decreases to zero, the smoothing capacitor begins to discharge its energy through the 1 kQ load resistor as illustrated between B and C. This accounts for the droop in Vout between B and C. Then the charge-discharge cycle repeats again between C and D keeping Vout from dropping to zero volts.

As you may have already guessed, the discharge rate of Vout is mainly dependent on the values of R and C, in this case the 1 kQ load resistor, R, and the smoothing capacitor, C. If we were to increase the value of the smoothing capacitor, the discharge rate of Vout would not decrease as fast. Correspondingly, if we were to decrease the value of the load resistor, R, the discharge rate between B and C would decrease faster along with the average DC level.

Try it!

V Disconnect power to your board.

V Add another 1 kQ resistor in parallel across the existing 1 kQ resistor. The effective resistance with two 1 kQ resistors is parallel is 500 Q, or one half the original value.

V Reconnect power to your board, and re-run your program.

V Close the Debug Terminal, bring up StampPlot, and connect.

V Now inspect the StampPlot output to verify that Vout decreases faster along with the average DC level.

Solar Panel Basics

Solar Panel Basics

Global warming is a huge problem which will significantly affect every country in the world. Many people all over the world are trying to do whatever they can to help combat the effects of global warming. One of the ways that people can fight global warming is to reduce their dependence on non-renewable energy sources like oil and petroleum based products.

Get My Free Ebook


Post a comment