Activity Programming The Half Wave Rectifier

Once again, we will be building upon our previous program. These additions let us read and compare the voltages generated by the two solar arrays. Remember, if you don't want to modify and update your program as shown here, you may download all of the source code for this text from www.parallax.com.

V In the BASIC Stamp Editor, open DuelingSolarCells.bs2.

V Rename and save the program as Half-FullWaveRectifier.bs2.

V Update the title to read as follows:

Experiments with Renewable Energy v1.0 - Half-FullWaveRectifier.bs2 Takes AC voltage from wind-powered alternator and rectifies it to DC.

V Add the following code to the bottom of the Declarations section.

----- For Experiment 4: Half and Full Wave Rectification ----------------

sampleCount VAR waitCount 'Nib ' Number of A/D samples per period sampleArray VAR Byte(10) ' 10-element array for A/D samples

V Next, in the Main routine, add an apostrophe in front of the first three GOSUB commands as shown below, "commenting out" the previous experiments which would conflict with the Half and Full Wave Rectification experiment.

Main Routine

Main: DO

' GOSUB Exp_1 ' Programmable Battery Charger

' GOSUB Exp_2 ' Dueling Solar Cells

' GOSUB Exp_3 ' Solar Cell Sun Tracker

GOSUB Exp_4 ' Half&Full Wave Rectification

GOSUB Exp_5 ' Three-Phase AC Alternator

GOSUB Plot_It ' Plot Data w/ StampPlot Pro

LOOP

V Then document the Exp_4 subroutine as shown:

Experiment 4: Half and Full Wave Rectification

Set the A/D conterter to convert only on ch3

If sampleCount is not equal to 10 Then plot existing samples Else prepare to plot new samples

To plot new samples first wait for the rectified wave to equal zero Once zero, wait for the beginning of the first peak Then take ten (10) samples as rapidly as possible Zero sampleCount to begin plotting next

Plot each sample in the order taken using Plot_It Increment sampleCount and

Exit

V Then fill in the code between the Exp_4 and Exp_4_End labels as shown:

a2dMuxId = A2dMuxId3 ' Set the A/D to convert Channel 3

GOTO Exp_4_Plot ENDIF

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

Loop until the rectified wave is zero

If the rectified wave stays above zero for 10 counts, assume that a smoothing capacitor is attached

Exp_4_Wait_For_First_Peak: ' Loop until the first peak is detected

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 ' As rapidly as possible take 10

GOSUB A2D ' A/D samples and save them in the sampleArray(sampleCount) = a2dResult ' sampleArray NEXT

sampleCount = 0 ' Re-initialize sampleCount

' for plotting

Exp_4_Plot:

ch3 = sampleArray(sampleCount) sampleCount = sampleCount + 1

Get the next A/D sample into CH3 and increment sampleCount

Exp_4_End: RETURN

V Save your work!

Getting Started With Solar

Getting Started With Solar

Do we really want the one thing that gives us its resources unconditionally to suffer even more than it is suffering now? Nature, is a part of our being from the earliest human days. We respect Nature and it gives us its bounty, but in the recent past greedy money hungry corporations have made us all so destructive, so wasteful.

Get My Free Ebook


Post a comment