HOME ELECTRICITY CONSUMPTION ANALYSIS

16K cassette 24K disk


by Joseph E. Harb Jr.


"Kilowatts" is an ATARI BASIC program that requires 16K RAM with cassette or 24K RAM with disk. It analyzes yearly, monthly, and daily electricity consumption and cost for all-electric homes.

When we moved into our present house several years ago, I planned to make a number of energy conservation modifications. I decided that I would like to use my ATARI 800 to determine what impact those modifications had on our energy consumption and costs. That led to the writing of "Kilowatts," which makes provisions for yearly and monthly temperature fluctuations. Statistics generated by "Kilowatts" can be displayed on the screen or printed on a line printer.

Monthly and yearly temperature variations are taken into consideration by analyzing kilowatt consumption per cooling/heating degree day, as appropriate. A heating degree day is each degree that the average temperature drops below 65 degrees F. on a given day. A cooling degree day is each degree above 65 degrees F. The total number of cooling and heating degree days in each month can be obtained from your local weather bureau (National Oceanic and Atmospheric Administration - NDAA). Our local NDAA office at Baltimore Washington International Airport kindly provided me with several years of monthly degree day information over the telephone.

In a given month, a minimum of 100 cooling degree days is required before the program will calculate cooling degree day consumption for that month. A minimum of 200 heating degree days is required for heating degree day analysis. This was done because in months when the number of heating or cooling days is below the threshold, energy use for heating or cooling is so low that the data becomes heavily biased by other energy use. This bias makes it seem that consumption per degree day is abnormally high. To change the threshold for cooling degree days, change the value of MINCD in line 100. To change the threshold of heating degree days, change the value of MINHD on the same line.

In order to further minimize distortion by electricity consumption for uses other than heating and cooling, the program subtracts 400 kilowatts from each month's total electricity use before computing consumption per degree day. (This subtraction is not performed in computing any other statistics.) The variable used in the subtraction is FCTR, also in lines 100/110. It can be changed if you feel your nonheating/cooling electricity use is higher or lower.

All REM statements can be eliminated without requiring any line number changes. Additionally, if you feel the explanation of DATA statements given in the following paragraph is adequate, you can eliminate the instruction subroutine (line 2050 and 6999-7190). If you do not have a printer, you can also remove the printer subroutines (lines 2040 and 5999-6880).

One DATA line is required for each month of data. DATA lines must be numbered in increments of 1, beginning with line 1000; e.g.,
1000 DATA JAN,79,1329,29,56.10,30,29.88,984,0
1001 DATA FEB,79,1426,28,60.44,32,31.44,1100,0
1002 DATA MAR,79,520,31,50.98,11,20.33,520,15
DATA statements must contain: month (first three letters); year (last two digits); number of kilowatts used; number of days in billing period; cost of electricity (paid on time and including surcharges); heating degree days; and cooling degree days. All of the required information except heating and cooling degree days can be obtained from utility bills. As explained above, the information on heating and cooling degree days can be obtained from your local NOAA. office.

If you have been looking for a relatively quick and easy way of neatly aligning columns of figures, particularly those with decimal fractions, you might want to consider using the technique I employed in this program, for example in lines 3170-3190. It can be done in four easy steps:

  1. Decide the rightmost column for displaying a particular set of figures. Then add 1 to that value. In subroutine 3000, I wanted the last digit of the variable X to be printed in column 11. 1 then added 1 to that number, for a total of 12. If you are aligning figures with decimal fractions, use the column where the decimal point is to be printed, and do not add 1.
  2. Measure the length of the variable by converting it to a string and using the LEN function. In line 3170, LEN(STR$(INT(X))) means calculate the length (LEN) of the variable X after converting it to an integer (INT) and then to a string (STR$). The variable must be converted to a string because the LEN function can only measure the length of string variables. For this measurement, it is important to convert a numeric variable to an integer when the variable includes a decimal fraction. This is necessary because the ATARI eliminates final zeros after the decimal point. Thus, 3.50 is displayed as 3.5. Consequently, if you wished to align the numbers 3.5 and 4.27 and if you measured the whole length of the variable, the columnar alignment of the numbers would be:
    3.5 4.27
  3. Pick a variable name for the column where printing of the display variable is to begin. (I used CL1 in the example.) Then, use the algorithm in this paragraph to calculate the column where printing is to begin. The algorithm subtracts the length of the integer portion of the string from the value calculated in step 1. In other words, the column where printing is to begin equals the length of the integer portion of the variable subtracted from the column where printing is to end. That is expressed in BASIC as CL1=12-LEN(STR$(INT(X))). This means that the first digit of the variable X will be displayed at screen column 12 minus the length of the integer X.
  4. Position the cursor at the column and row where printing is to begin. This is done with the POSITION statement. In line 3180, the cursor is positioned at column CL1,row PEEK(84). PEEK(84) is the memory location of the current cursor row. Finally, use the PRINT statement to display the variable on the screen. Once you get used to this process, it can be done fairly quickly. Of course, it can be further simplified by performing the whole operation at one time: POSITION 12-LEN(STR$(INT(X))),PEEK(84):?X

During operation of "Kilowatts" do not depress the return key at any time when responding to a screen prompt. Simply type the letter(s) or numbers desired for input. The GET statement will determine which key(s) you depressed.


VARIABLES USED IN "KILOWATTS"

A: Used with GET to determine last key depressed on keyboard.

ANET: Used to represent electricity cost (NET) whenever single subroutine must calculate either gas or electricity statistics.

AVG: Per kilowatt cost.

B: Used with A when more than one key input from keyboard is required.

C: Used with A & B when three-key input required from keyboard.

CAVG: Average monthly consumption of kilowatts per degree day.

CD: Cooling degree days in a given month.

CDAVG: Average annual consumption of kilowatts per cooling degree day.

CDDIV: Total number of kilowatts used when computing annual average consumption of kilowatts per cooling degree day.

CDTOT: Total number of cooling degree days per annum.

CL1: (Column 1); Column where printing of specified data begins. Used to right justify screen display.

CL2: (Column 2); Used with CL1 when more than 1 column cannot be right justified in some other way.

CL3: (Column 3); Used with CL1 & CL2 when more than two columns cannot be right justified in some other way.

CL4: (Column 4); Used with CL1, CL2, & CL3 when more than three columns cannot be right justified in some other way.

COST: Total annual cost of electricity.

DAYS: Number of days during billing period.

DD: Used to represent either cooling or heating degree days in subroutines where either can be used.

DDAVG: Average annual use of kilowatts per cooling or heating degree day.

DDN$: Used in subroutines 3000, 5000, & 6000 to represent words "HEAT" or "COOL" in column headings, depending on whether user has requested cooling or heating degree day information.

DDT: Total number of heating/cooling degree days in a given year.

DIV: Total number of energy units used when computing annual average consumption per degree day.

FCTR: Estimated minimum amount of electricity used monthly for uses other than heating or cooling. Subtracted from UNITS before computing consumption per degree day. Can be raised or lowered if estimated minimum is different.

HAVG: Average monthly consumption of kilowatts per heating degree day.

HD: Number of heating degree days in a given month.

HDAVG: Average annual consumption of kilowatts per heating degree day.

HDDIV: Total number of kilowatts used when computing average annual consumption of kilowatts per heating degree day.

HDTOT: Total number of heating degree days per annum.

HIYR: High year in data base.

HL: Nr. of lines to be printed on each page.

K$: Month for which data requested in menu options A, B, E, & F.

KPD: Average number of kilowatts per degree day.

KPD$: Used to represent either variable KPD or letters "N/A" when printing out results of kilowatts per degree day computation.

LINE: Last line of DATA.

LOYR: Lowest year of data in data base.

M$: Month of data contained in DATA line.

MINCD: Minimum number of cooling degree days necessary for computing electricity consumption per cooling degree day.

MINHD: Minimum number of heating degree days necessary for computing electricity consumption per degree day.

NET: Cost of electricity without late charge.

NR: Used to calculate number of months in data base.

PRNT$: One PRNT$ string is created for each line of data to be printed with the line printer in subroutine 6000. Allows data to be aligned easily in columns without using TAB functions which vary from printer to printer.

R$: Represents month in subroutine 6460/6570 to compare same month of different years.

SET: Sets flag when high line of page print reached during loop.

T: A flag set at beginning of subroutines 3000 and 5000 to identify whether user has requested information on consumption per cooling or heating degree day.

TIME: Last line printed on printer.

UNITS: Kilowatts used during billing period.

UP: Average daily kilowatt consumption.

USE: Total annual consumption of electricity.

Y: Year of data on DATA line.

YR: Year of data being processed.

Z: Index variable for loops, i.e., keeps track of nr. of times loop has occurred.