Example Program Plot Itbs

V In your BASIC Stamp Editor, open Template2.5.bs2, if it is not already open.

V Select File, then Save As. Rename the file PlotIt.bs2.

V Update the comments at the beginning of the program to read:

' Experiments with Renewable Energy v1.0 - PlotIt.bs2 ' Transmits acquired data to StampPlot software for plotting.

V Next, enter the variables that will be needed by the Plot_It subroutine into the Declarations section so it reads like this:

!__________________________________________________________________________

' Declarations

For Plot It Subroutine

ch0

VAR

Byte

'Voltage reading from A/D CH0

ch1

VAR

Byte

'Voltage reading from A/D CH1

ch2

VAR

Byte

'Voltage reading from A/D CH2

ch3

VAR

Byte

'Voltage reading from A/D CH3

checksum

VAR

Byte

'Sum of all of above readings

The ch0, ch1, ch2 and ch3 variables (which stand for Channel 0 through Channel 3) will be storing 8-bit A/D converted voltage values gathered from the experiments. That's why we specified a byte (8 bits) for variable storage. As a double check against the other four values, the StampPlot software uses the checkSum variable, which is also a byte.

V Now add the Plot_It subroutine code under the appropriate heading of the Subroutines section, so it reads as follows:

Plot Acquired Data Using StampPlot Software

Plot_It:

checkSum = ch0 + ch1 + ch2 + ch3 DEBUG ch0, ch1, ch2, ch3, checkSum PAUSE 250

Compute checksum for StampPlot Transmit data to StampPlot Give StampPlot time to plot data ch0 = 0 ch1 = 0 ch2 = 0 ch3 = 0 checkSum = 0

Plot_It_End: RETURN

Reset voltages and checkSum

V From the menu bar, choose File and then Save to preserve your work.

V Load the file into the BASIC Stamp module by clicking on the Run icon in the BASIC Stamp Editor, or by pressing Ctrl-R.

Notice that the Debug Terminal pops up, and that its green RX LED flashes four times a second, or once every 250 ms, as programmed. The flashing RX LED shows you that the program is loaded and that your BASIC Stamp module is communicating with your PC.

Solar Power

Solar Power

Start Saving On Your Electricity Bills Using The Power of the Sun And Other Natural Resources!

Get My Free Ebook


Post a comment