Sie sind auf Seite 1von 38

DESIGN AND DEVELOPMENT OF A DATA ANALYZING SOFTWARE FOR CITRUS YIELD MONITORING SYSTEM

By:

RAMIN SHAMSHIRI
UF ID #: 90213353

AOM 5435 Final Report Dec 01, 2008 Ramin.sh@ufl.edu

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 1

1- Abstract
GPS systems and load cells are used widely in modern agriculture such as citrus yield monitoring. Traditionally farmers measure crop yield for whole field or for large sections. With the available modern technologies, high tech instrumentation and computer software it is possible to measure yield more specifically. Yield mapping is considered as the first step in precision agriculture and its purpose is to determine variability in the field. A citrus yield monitoring system usually records GPS and load cell data every second or less. This results huge number of data points in a harvesting season. After data are collected, they are sent to laboratories for interpretation in order to be converted to yield table which is then used in GIS software to create yield map. These yield maps reveal the harvested mass per unit area. Yield variability in citrus groves as shown in the yield map depends not only on agricultural and biological variables (such as soil nutrition and property) but also drivers and machines performance. Farm machinery indexes play important roles in agricultural mechanization and technical managements especially during the busy pick periods when timing becomes an issue. Shortening machine operation time while keeping work quality is desired to produce optimum output. This can be done with predicting machine performances. The purpose of this project was to eliminate the procedure of sending raw yield monitoring output data to laboratory by designing a standalone computer application that can be used on the farm and is capable of calculating yield table, field efficiency, machine capacity and field machine index and observing drivers performance using three simple steps.

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 2

2- Significance of the Problem For a GIS software to create a yield map, a yield table which contains yield information should be created first. Citrus yield tables are generated from huge raw GPS and load cell data. Extracting yield table from these raw data require expert persons and goes through a time taking procedure. In addition to that, yield data are also affected by drivers performance and machine efficiency. For example, a reckless driver can spend much of the harvesting time on turnings, or stopped for breaks. Maintaining on a constant speed is sometimes very important for the farm operation which can also affect yield data. It is obvious that not 100% of the spent on field has been used for effective harvesting. Harvesting time or effective time of operation is the total time spent on field minus ineffective time (Turnings Th and stopped time Ta). Th and Ta both refers to two categories of unknown time that machine has spent on the field but no efficient work has been done. Generally this wasted time may include filling sprayer tank, fixing a disk or chisel plow setting, drivers resting time, etc. Since larger theoretical field capacity of machineries leads to smaller effective times (Te), these wasted times become more critical in larger machineries. Machine effective and ineffective times are not fixed and vary from condition to condition (different machineries, different drivers, different field, etc). Precise determination of these wasted times together with the measurements of machine travel speed will provide accurate calculations of drivers performance, field efficiency and machine capacities which leads to a better interpreting of yield map.

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 3

3- Objectives The main objective of this project was to design and develop a standalone computer application to calculate yield, field efficiency, machine capacities and field machine index from raw GPS and load cell output data of a citrus yield monitoring system. Information such as timing, latitude and longitude from standard NMEA ($GPGGA) GPS sentence together with load cell voltage was extracted in order to determine below parameters. Total number of data points Total harvesting time Total stopped time (ineffective harvesting time, area unrelated wasted time) Total turning time (ineffective harvesting time, area related wasted time) Total effective time (effective harvesting time) Total traveled distance Total area covered Average travel speed

These parameters were then used to calculate yield, field efficiency, machine field and material capacity and field machine index. A schematic block diagram of the project is shown in Figure 1.

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 4

Figure 1: Schematic view of the project

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 5

4- Background and literature review 4.1- Machine Capacity Machine field or material capacity is the rate of operating a particular task, (i.e. tillage, planting or harvesting, etc) by a particular machine. Because of the high price of operating hour, agricultural machineries are usually designed for large field efficiency to be economical. Field capacity is the total work done by a machine in one hour and can be expresses as machine field capacity (area/time) or material capacity (mass/time or volume/time). Machine field capacity is determined through eq.1: = . . 10 Eq.1

where Ca is the machine field capacity (ha/h), V is the travel speed (km/h), W is the machine operating width (swath) (m) and is the machine field efficiency (%). When = 1, machine field capacity is presented by Cat and is called theoretical machine field capacity. Machine material capacity is calculated through eq.2: = . . . 10 Eq.2

where Cm is the machine material capacity (Mg/h) and Y is the yield (Mg/h). When = 1, this value is presented by Cmt and is called theoretical machine material capacity. Theoretical field capacity (area or material) is gained when 100% of machine swath is used, but this is almost impossible in reality and there is always some overlapping. For machineries such as windrower, the swath is equal to numbers of rows times the distance between rows and is considered fixed. In other machineries like bailers and choppers which their capacity is expressed in material (either mass or volume), can be assumed one [1]. 4.2- Field efficiency and Field Machine Index Field machine index is the percent of machines efficient working time divided by machine turning time and efficient working time (eq.3). = 100 + Eq.3

where Te is the efficient working time (min or hour) in an operation, Tr is the turning time (min or hour) and FI is the field machine index (%).

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 6

Machines theoretical working time is the theoretical time needed for a machine to perform a task in field and is determined by dividing the working area by theoretical field capacity of that machine (eq.4). = Eq.4

Where Tt is the theoretical time (h) required for a machine to complete a task, Cat is the theoretical machines field capacity (ha/a) and At is the total area (ha) to be worked (theoretical are). Because of overlapping, the actual time for particular operation includes machine turning time and chargingdischarging reservoirs time which makes the field efficiency less than 100%. Field efficiency can be calculated through eq.5. = 100 + + Eq.5

Where is field efficiency (%), Tt is theoretical operation time (h), Ta is work-area related wasted time(h), Th is unrelated work-area wasted time (h), and Te is the effective time (h) which can be also determined through Eq.6 or Eq.7. = Eq.6

Eq.7

Where Kw is the actual operation width of the machine that is used, Aa is the actual area (ha) that machine has covered and Ca is the machine field capacity (ha/h),. 4.3- Linear Regression Regression Analysis is a statistical method for analyzing a relationship between two or more variables in such a manner that one variable can be predicted or explained by using information on the others. X: independent variable; is the variable in regression that can be controlled or manipulated. For this project, the independent variable was load cell voltage (v). Y: Dependent variable; is the variable in regression that cannot be controlled or manipulated. For this project, the dependent variable was mass (m). Correlation Coefficient: The correlation coefficient computed from the sample data measures the strength and direction of a linear relationship between two variables. The symbol for the sample correlation coefficient is r and the symbol for the population correlation coefficient is .

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 7

The range of correlation coefficient is from -1 (strong negative linear relationship between the variables,) to +1 (strong positive linear relationship between the variables). Formula for the correlation coefficient r: = ( ) ( )( ) [ 2 ( )2 ][ 2 ( )2 ] Eq.9 Eq.8

The simple linear regression model is of the form: y=0+1x+ This model is often referred to as the regression of y on x. The two parameters, 0 and 1 are called regression coefficients. 1 is the slope of the regression line and 0 is the intercept. The individual values of are assumed to come from a population of random variables having the normal distribution with mean zero and variance 2 . Assumption: The linear model is appropriate The error terms are independent The error terms are (approximately) normally distributed The error terms have a common variance, 2 .

The three criteria for best fits are: Minimizes the sum of the residual
=1

=1(

0 1 )
=1

Minimizes the sum of the absolute values of the residuals: Minimizes the sum of squared residuals.

=1

( 0 1 )

The most popular criterion is minimizing the sum of squared residuals which is called least square criterion and results in an estimated line that minimizes the variance of the residuals. The least squares criterion requires that we choose estimates of 0 and 1 that minimize Eq.10 Eq.11 Eq.12

( y|x )2 = 0 = 1 1 =

( 0 1 )2

( ) = ( )2

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 8

4.4- Citrus yield mapping creation Traditionally farmers measured crop yields for whole fields or for large sections, while modern technological advances permit farmers to measure yield more precisely. The procedure to create yield map in modern agriculture involves recording positions by DGPS, measure yield by measuring flow rate, area and moisture content. There are three different methods to measure crop yields, Collect-and-weigh, batch-type yield monitoring and instantaneous yield monitors (different methods are measuring crop volume and weight the crop). Instantaneous yield monitor system measure and records yield on-the-go. Measuring process is continuous as the grain is being harvested. In this procedure, site-specific yield maps can be generated. For citrus yield mapping, flow rate can be measured using impact cells. Data are then analyzed and displayed as yield map. Instantaneous yield calculation: Yield= Mass/Area = flow rate/(Travel speed*width)=Mass/(Travel distance*width) Flow rate= Mss/time Travel speed=Travel distance/time Width= harvester swath Eq.13

Calibration method: Compare known weights with actual yield monitor estimation Generate calibration curves Need to test over wide range of conditions Need to calibrate moisture sensor

What yield maps can reveal? Yield variation across the field Relationship between yield variations and soil type, fertility, weed, drainage, soil compaction, equipment malfunctions, etc. Effect of hybrids, seeding/fertilizer application rates, pesticide types and rates, etc

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 9

5- Materials and Methods 5.1- Hardware Major hardware component used in this Citrus Yield Mapping included Position sensor (DGPS) Mass flow sensor (Impact force sensor) Ground speed sensor(GPS-based speed measurement) Display/processor console

Using this hardware setup, raw GPS and load cell data was collected by AOM5435 students from University of Florida campus biological field on Nov. 5, 2008 5.2- Software Three major software were used to complete this project (Figure 2,3 and 4). Delphi programming language was used to design and program the standalone application. MATLAB and Excel were used to test the results and plot the data.

Figure 2: Delphi language V7.0

Figure 3: MATLAB software

Figure 4: Microsoft Excel

Raw GPS and load cell data was used as the input of this project. The aim was to automatically create a yield table and calculate field efficiency, machine capacities and field machine index from raw GPS and load cell data using three steps, reading data, extracting data and processing data to. An overview of the project goal is shown in Figure 5.

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 10

Figure 5: Schematic view of the project goal

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 11

5.3- Design procedure 5.3.1- Reading raw data The raw data (Figure 6) was originally mixed with other GPS sentence format and blanked lines. An algorithm was first written to read the original raw GPS data and sort the proper NMEA sentences out of it to create a clean file that only contains $GPGGA sentences as shown in Figure 7.

Figure 6: Original raw GPS data, contains blanked line and $GPVTG sentence

Figure 7: Sorted data as used in the standalone software

5.3.2- Designing user interface A user interface form was designed in Delphi environment and is shown in Figure 8 and 9. Tab-page control was used to ease the accessibility of different sections. In fact, the goal was to make a simple outlook and minimize redundant calculation and buttons. As it can be seen in figure 8, major calculations are done within three easy steps, Open data, extract data and process data. Progress bars were used in the last two steps to show the elapsed time while calculations are in progress.

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 12

Figure 8: Software view, front page. Data are loaded and extracted.

Figure 9: Software view, yield table and output page. Data are processed and results are shown.

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 13

5.3.4. Calculation procedure The application was programmed through several hundred command lines in Delphi environment. It has the ability to calculate yield information in two standard units, US and SI. Main button section is shown in Figure. 10. The Open GPS data button Opens raw GPS data ($GPGGA) as a text file, removes any blanked line between data if there is any and load data into the software memory. The Open Load Cell data button opens raw load cell data (voltage) as a text file and load data into the software memory. At this time, user can view the raw data and check for accuracy or do any modification if necessary. The Calibrate Load cell opens a new form (Figure. 11) which uses linear regression method (minimizing sum of squared residuals) described in literature review to calibrate load cell using data points provided by user. The Extract data buttons reads and extracts information from raw data stored in the temporary memory of the software and store them in a table as shown in Figure. 12. The Process data button first reads the extracted information and load cell data. Using regression model information, load cell data are converted to mass data. Information such as distance between pairs of points, travel speed and area are then determined and mass per unit area (yield) is calculated. This button also determines total field operation time, total effective and total ineffective time (including stopped time and turning time) to calculate field efficiency, machine capacity and field machine index. As a result, the output table shown in Figure. 13 is created which contains all the detailed information.

Figure 10: Main buttons Figure 11: Calibration form

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 14

Figure 12: Extracted information from raw GPS data

Figure 13: Program Output1, Output table, included all the detailed information for yield and operation Times.

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 15

6- Results and discussion Data collection was done in a one-second time interval. This is shown in Figure. 14. In the other words, it was found out that there has been no interruption in collecting data.

Figure 14: Data collection time interval. (One-second interval without interruption)

6.1- Yield result: Since no mass was collected during data collection, it can be seen from Figures. 16 that mass has been just oscillating around zero during the operation time. Plots of load cell data vs. time and mass-persecond vs. time are shown in Figure 15 and 16. The oscillation observed is due to the ground surface which has produced vibration on the load cell. As we expected, no increase in the mass vs. time plot is observed.

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 16

Figure 15

Figure 16

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 17

Distance between two points was calculated using an algorithm shown in appendix A. Area was then calculated as harvesting width (assumed 20ft) times distance. Since several people were involved in the data collection procedure, The machine was stopped several times to change the drivers. This can be clearly seen from Figure 17. It is now possible to view performance of each driver individually from Figure 17, through 24. Who has driven faster, who has had less effective time, etc.

Figure 17

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 18

Figure 18

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 19

Figure 19

Figure 20

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 20

Yield table was created according to the load cell voltage and area measurements. Yield vs. Time is shown in Figure. 21. Again, as we expected no increase in yield is observed since no real harvesting was performed. It can be seen that yield has been only oscillating around 0 lb/ft2. Negative values of yield are due to the impact of ground surface to the load cell that has produced negative vibration. Finally yield statistic was calculated as shown in Figure. 22.

Figure 21

Figure 22

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 21

6.2- Field efficiency, machine capacity and field machine index calculation As explained in the literature review, two important parameters to calculate field efficiency is the turning time and stopped time. Once field efficiency is calculated, machine capacities can be calculated easily. Three algorithms were written to determine turning points to extract corresponding turning times. Comparisons of these three algorithms are shown in Figure. 26, 27 and 28. The third algorithm showed better performance and was therefore selected to calculate turning times. Stopped time was considered those points at which traveled distance has been zero. These points were found as shown in Figure 30 and 31. Ineffective time was then calculated as the sum of turning time and stopped time. Once these parameters are determined, the user needs to input standard travel speed and total area to be harvested (farm size) in the software and press on the calculate button to see the field efficiency, machine capacities (theoretical, field and material) and field machine index as shown in Figure 32 and 33.

Figure 23: Original drive path

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 22

Figure 24: Original Drive points

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 23

Figure 25: Determining straight driven points vs. Original driven points.

Figure 26: Turning points vs. original point, Algorithm 1

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 24

Figure 27: Turning points vs. original point, Algorithm 2

Figure 28: Turning points vs. original point, Algorithm 3

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 25

Figure 29: Turning points vs. Straight points

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 26

Figure 30: Stopped points vs. Original driven points

Figure 31: Stopped points vs. moving points (stopped points removed)

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 27

Figure 32: Program Output 2

Figure 33: Application Output 3

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 28

7- Conclusion Available modern technology like GPS can be used in modern agricultural mechanization for precise determination and automatic storing of variables such as time, travel speed, travelled distance, working area, fuel consumption, yield information, etc. Yield information that are calculated using this software can be fed into a GIS software to create yield map. This application was shown to be capable of eliminating time taking procedures of yield data creation and replacing it with a three easy step procedure. For 1540 data points, it only took nearly 10 seconds for this standalone application to calculate yield data table, field efficiency, machine capacities and field machine index. It would be then possible for a farm owner to view performance of a contract based driver on field before getting him paid as well as easily understanding of the potentials to increase efficiency of his harvesting operation. The ultimate goal of this project can be thought of as a standalone platform device capable of creating and updating a particular machine performance data base for a specific region. Statistical analysis and graphical representation of such accurate data over time can be utilized in farm & machinery management, i.e. to make decisions on machine size selection and drivers skill/performance.

Ramin Shamshiri 12 Nov- 1 Dec, 2008

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 29

Reference: 1- American society of agricultural engineering (1995) ASAE Standard, 24th edition 2- John Deere (1975), Fundamental of machine operation. Machinery management. John Deere.

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 30

Appendix A- Calculating distance. Algorithm was changed into Delphi programming codes to calculate distance.
% calculating distance between two decimal GPS coordinates vectors. The model used in this calculation utilizes Carlson (1999) model. Author: Ramin Shamshiri , Graduate Student, University of Florida, 11 November 2008, Contact info: ramin.sh@ufl.edu, www.Raminworld.com % Clean command window clc; % Switch to long format decimal display format long % Number of rows rows=361; % "361": number of rows in AOM5435 Lab#8 data % Initialize vectors and set all cells to zeros angle1 = zeros(361,1); angle2 = zeros(361,1); r1 = zeros(rows,1); r2 = zeros(rows,1); xy1= zeros(rows,1); xy2= zeros(rows,1); xy3= zeros(rows,1); xy4= zeros(rows,1); X= zeros(rows,1); Y= zeros(rows,1); distance_m=zeros(rows,1); distance_ft=zeros(rows,1); % Point 1 coordinate (Decimal format) %Lat1 vector single column defined manually by the user % example: lat1=[29.640516;29.640515;29.640513] %Long1 vector single column defined manually by the use % example: long1=[-82.36212;-82.362093;-82.362064] % Point 2 coordinate (Decimal format) %Lat2 vector single column defined manually by the use %Long2 vector single column defined manually by the use %Major axis constant maj_const=6378137; %Minor axis constant min_const=6356752.3142; %Elevation h=334.9; for i=1:361 % True angle determination (atan=ArcTan) angle1(i,1)=(atan((min_const^2)/(maj_const^2)*tan(lat1(i,1)*pi()/180)))*180/pi(); angle2(i,1)=(atan((min_const^2)/(maj_const^2)*tan(lat2(i,1)*pi()/180)))*180/pi(); % Radius calculation for the two points r1(i,1)=(1/((cos(angle1(i,1)*pi()/180))^2/maj_const^2+(sin(angle1(i,1)*pi()/180))^2/min_const^2))^0.5+h; r2(i,1)=(1/((cos(angle2(i,1)*pi()/180))^2/maj_const^2+(sin(angle2(i,1)*pi()/180))^2/min_const^2))^0.5+h; % X-Y earth coordinates xy1(i,1)=r1(i,1)*cos(angle1(i,1)*pi()/180); xy2(i,1)=r2(i,1)*cos(angle2(i,1)*pi()/180); xy3(i,1)=r1(i,1)*sin(angle1(i,1)*pi()/180); xy4(i,1)=r2(i,1)*sin(angle2(i,1)*pi()/180); % X coordinate X(i,1)=((xy1(i,1)-xy2(i,1))^2+(xy3(i,1)-xy4(i,1))^2)^0.5; % Y coordinate Y(i,1)=2*pi()*((((xy1(i,1)+xy2(i,1))/2))/360)*(long1(i,1)-long2(i,1)); % Switch to short format decimal display format short % Distance Meter distance_m(i,1)=((X(i,1))^2+(Y(i,1))^2)^0.5; % Distance feet distance_ft(i,1)= distance_m(i,1)*3.28084; end

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 31

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Menus, Grids, ComCtrls, StdActns, ActnList, Spin, XPMan; type TForm1 = class(TForm) MainMenu1: TMainMenu; File1: TMenuItem; New1: TMenuItem; Open1: TMenuItem; Save1: TMenuItem; N1: TMenuItem; Exit1: TMenuItem; ActionList1: TActionList; FileOpen1: TFileOpen; PageControl1: TPageControl; TabSheet1: TTabSheet; GroupBox1: TGroupBox; Memo1: TMemo; ProgressBar1: TProgressBar; GroupBox2: TGroupBox; StringGrid1: TStringGrid; TabSheet2: TTabSheet; GroupBox4: TGroupBox; Label4: TLabel; StringGrid2: TStringGrid; ProgressBar2: TProgressBar; FileSaveAs1: TFileSaveAs; GroupBox7: TGroupBox; FileOpen2: TFileOpen; Memo2: TMemo; StatusBar1: TStatusBar; GroupBox3: TGroupBox; Label5: TLabel; Label6: TLabel; Button2: TButton; Button1: TButton; Button3: TButton; Button4: TButton; SpinEdit1: TSpinEdit; RadioButton1: TRadioButton; RadioButton2: TRadioButton; Button6: TButton; Button9: TButton; Label1: TLabel; Edit1: TEdit; Label2: TLabel; Label3: TLabel; Label7: TLabel; Edit2: TEdit; Label8: TLabel; Edit3: TEdit; Label9: TLabel; Edit4: TEdit; GroupBox5: TGroupBox; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; Label15: TLabel; Label16: TLabel; Label19: TLabel; Label20: TLabel; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; Button5: TButton; Button7: TButton; Edit5: TEdit; Edit6: TEdit; Edit7: TEdit; Edit8: TEdit; Edit9: TEdit; Edit10: TEdit; Edit11: TEdit; Edit12: TEdit; Edit13: TEdit; Edit14: TEdit; Edit16: TEdit; Edit17: TEdit; Label17: TLabel; Edit18: TEdit; Label14: TLabel; Edit15: TEdit; Label18: TLabel; Edit19: TEdit; TabSheet3: TTabSheet; GroupBox6: TGroupBox; Memo3: TMemo; procedure Button1Click(Sender: TObject); procedure FileOpen1Accept(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FileSaveAs1Accept(Sender: TObject); procedure RadioButton2Click(Sender: TObject); procedure RadioButton1Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure FileOpen2Accept(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button9Click(Sender: TObject); procedure Button5Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; i,l,capacity,gaprows,gaprows2:integer; rows,cols: integer; Yield,Mass,Volt,sumx2,sumy,sumx,sumxy,a,b,AveYield:real; implementation uses Unit2; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); label 00,0,1,16; var temp:string; begin // Cleaning table for rows:=1 to stringgrid1.RowCount do begin for cols:=0 to stringgrid1.ColCount do begin StringGrid1.Cells[cols,rows]:=''; end; end; // Labling Column

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 32

stringgrid1.Cells[0,0]:='No'; stringgrid1.Cells[1,0]:='GGA'; stringgrid1.Cells[2,0]:='Time'; stringgrid1.Cells[3,0]:='Lat'; stringgrid1.Cells[4,0]:='N/S'; stringgrid1.Cells[5,0]:='Long'; stringgrid1.Cells[6,0]:='W/E'; stringgrid1.Cells[7,0]:='Quality'; stringgrid1.Cells[8,0]:='No of Sat'; stringgrid1.Cells[9,0]:='HDOP'; stringgrid1.Cells[10,0]:='Altitude'; stringgrid1.Cells[11,0]:='M'; stringgrid1.Cells[12,0]:='H of Geoid'; stringgrid1.Cells[13,0]:='Last Update'; stringgrid1.Cells[14,0]:='Station ID'; stringgrid1.Cells[15,0]:='checksum data'; //***Main Program**// capacity:=memo1.Lines.Capacity; //initialization Memo and Table rows rows:=0; gaprows:=0; // initialization progress bar progressbar1.StepBy(1-capacity); progressbar1.Min:=1; progressbar1.MAX:=capacity; progressbar1.Step:=1;

while rows<capacity do begin progressbar1.StepBy(1); i:=0; cols:=1; rows:=rows+1; 00: temp:=memo1.Lines.Strings[rows-1]; if temp='' then begin rows:=rows+1; if rows=capacity then begin goto 16 end else begin gaprows:=gaprows+1; goto 00; end; end else begin StringGrid1.RowCount:=rows-gaprows+2; StringGrid1.Cells[0,rows-gaprows]:=inttostr(rows-gaprows); 1: i:=i+1; if copy(temp,i,1)<>',' then begin if copy(temp,i,1)<>'' then begin stringgrid1.Cells[cols,rows-gaprows]:=concat(stringgrid1.Cells[cols,rows-gaprows],copy(temp,i,1)); goto 1; end else begin temp:='.'; goto 16; end; end else begin cols:=cols+1; goto 1; end; end; 16:progressbar1.Position:=progressbar1.Position+gaprows; end; //***End of Main Program// end;

procedure TForm1.FileOpen1Accept(Sender: TObject); begin Memo1.Lines.LoadFromFile(fileopen1.Dialog.FileName);

end; procedure TForm1.Button4Click(Sender: TObject); var decLat,degLat,minLat,secLat,decLong,degLong,minLong,secLong ,t1,t2,deltat,time,dt,Lat1,Lat2,Long1,Long2,dist,speed,sumdist,avespeed:real; begin

// Labling Column// stringgrid2.Cells[0,0]:='Wpt'; stringgrid2.Cells[1,0]:='Time'; stringgrid2.Cells[2,0]:='dt'; stringgrid2.Cells[3,0]:='Lat'; stringgrid2.Cells[4,0]:='Long'; stringgrid2.Cells[5,0]:='Distance'; stringgrid2.Cells[6,0]:='Speed'; stringgrid2.Cells[7,0]:='Area'; stringgrid2.Cells[8,0]:='Voltage'; stringgrid2.Cells[9,0]:='Mass'; stringgrid2.Cells[10,0]:='Mass/Sec'; stringgrid2.Cells[11,0]:='Yield'; stringgrid2.Cells[12,0]:='StoppedLat'; stringgrid2.Cells[13,0]:='StoppedLong'; stringgrid2.Cells[14,0]:='TurningLat'; stringgrid2.Cells[15,0]:='TurningLong'; stringgrid2.Cells[16,0]:='StraightLat'; stringgrid2.Cells[17,0]:='StraightLong'; stringgrid2.Cells[18,0]:='MovingLat'; stringgrid2.Cells[19,0]:='MovingLong'; // End of Labling Column

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 33

//Show Next Tab pagecontrol1.ActivePageIndex:=1; // Cleaning table 2 //// for rows:=1 to stringgrid2.RowCount do begin for cols:=0 to stringgrid2.ColCount do begin StringGrid2.Cells[cols,rows]:=''; end; end; // End of Cleaning table 2 ////

// initialization progress bar 2 progressbar2.Min:=1; progressbar2.MAX:=stringgrid1.RowCount; progressbar2.Step:=1; // End of initialization progress bar 2

// Setting numbers of rows for stringgrid 2 stringgrid2.RowCount:=stringgrid1.RowCount; //setting t2 (next time after last row) equal to a value so that it does not mess calculations stringgrid1.Cells[2,stringgrid1.RowCount-1]:=floattostr(1+strtofloat(stringgrid1.Cells[2,stringgrid1.rowcount-2]));

// ** Main program** // // Reading table (StringGrid1)// for rows:=2 to stringgrid1.RowCount-1 do begin progressbar2.StepBy(1); // reading Lat & Long decLat:=strtofloat(stringgrid1.Cells[3,rows-1]); decLong:=strtofloat(stringgrid1.Cells[5,rows-1]); t1:=strtofloat(stringgrid1.Cells[2,rows-1]); t2:=strtofloat(stringgrid1.Cells[2,rows]); deltat:=t2-t1; if deltat=41 then deltat:=1; time:=time+deltat; if stringgrid1.Cells[6,rows-1]='W' then decLong:=(-1)*decLong; //Converting Lat degLat:=trunc(decLat/100); minLat:=(trunc(frac(decLat/100)*1000)/10)/60; secLat:=((frac((frac(decLat))*10))/10)/60; //Converting Long degLong:=trunc(decLong/100); minLong:=(trunc(frac(decLong/100)*1000)/10)/60; secLong:=((frac((frac(decLong))*10))/10)/60; //Printing Output stringgrid2.Cells[0,rows-1]:=('Wpt'+inttostr(rows-1)); //Printing Wpt point stringgrid2.Cells[1,rows-1]:= floattostr(Time); //Printing Time point edit1.Text:=floattostr(0.001*trunc((Time/60)*1000)); //Printing Time (minute) in Edit1 stringgrid2.Cells[3,rows-1]:=floattostr(degLat+minLat+secLat); //Printing Lat stringgrid2.Cells[4,rows-1]:=floattostr(degLong+minLong+secLong); //Printing Long end;

// set last rows of stringgrid2 to make distance and speed calculation valid //lat1-lat2 and long1-long2, (therefore lat2 & long2 will be zero) rows:=0; stringgrid2.Cells[1,stringgrid2.RowCount-2]:=floattostr(abs(time)); //Time column stringgrid2.Cells[3,stringgrid2.RowCount-1]:='0'; //Lat Column stringgrid2.Cells[4,stringgrid2.RowCount-1]:='0'; //Long Column label2.Caption:=inttostr(stringgrid2.RowCount-2); //Printing total Nummber of data points

stringgrid2.Cells[1,stringgrid2.RowCount-1]:='0'; //Time clumn //calculating distance, travel Speed and area for rows:=2 to stringgrid2.RowCount-1 do begin Lat1:=strtofloat(stringgrid2.Cells[3,rows-1]); Long1:=strtofloat(stringgrid2.Cells[4,rows-1]); Lat2:=strtofloat(stringgrid2.Cells[3,rows]); Long2:=strtofloat(stringgrid2.Cells[4,rows]); dist:=365222*SQRT(((Lat1-Lat2)*(Lat1-Lat2))+ ((Long1-Long2)*(Long1-Long2))); dt:=(strtofloat(stringgrid2.Cells[1,rows]))-(strtofloat(stringgrid2.Cells[1,rows-1])); stringgrid2.Cells[2,rows-1]:=floattostr(dt); //Printing delta t speed:=dist/dt;

//Conversion of Unit if radiobutton2.Checked then begin stringgrid2.Cells[5,rows-1]:=floattostr(0.3048*dist); stringgrid2.Cells[6,rows-1]:=floattostr(0.3048*speed); end; if radiobutton1.Checked then begin stringgrid2.Cells[5,rows-1]:=floattostr(dist); stringgrid2.Cells[6,rows-1]:=floattostr(speed); end; //End of Conversion of Unit

//Printing Distance in SI unit //Printing Speed in SI unit

//Printing Distance in US unit //Printing Speed in US unit

stringgrid2.Cells[7,rows-1]:=floattostr(spinedit1.Value*(strtofloat(stringgrid2.Cells[5,rows-1]))); end; //End of calculating distance, travel Speed and area

//Caclulate & Printing Area

//cleaning last rows, stringgrid2.Cells[1,stringgrid2.RowCount-1]:=''; stringgrid2.Cells[2,stringgrid2.RowCount-1]:=''; stringgrid2.Cells[2,stringgrid2.RowCount-2]:='0'; stringgrid2.Cells[3,stringgrid2.RowCount-1]:=''; stringgrid2.Cells[4,stringgrid2.RowCount-1]:='';

//Time Column //Delta Time Column //Delta Time Column //Lat Column //Long Column

//Make Cell(4,lastrow) and (1,lastrow) look zero {stringgrid2.Cells[1,stringgrid2.RowCount-2]:='0'; //Time Column} stringgrid2.Cells[5,stringgrid2.RowCount-2]:='0'; stringgrid2.Cells[6,stringgrid2.RowCount-2]:='0'; stringgrid2.Cells[7,stringgrid2.RowCount-2]:='0';

//End of Reading table, Main program ///

{ //For mess GPS data, AOM Homework raw data // Reading table for rows:=5 to stringgrid1.RowCount do

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 34

begin //Reading table sorted stringgrid2.Cells[0,rows-1]:=stringgrid1.Cells[1,rows+l]; stringgrid2.Cells[1,rows-1]:=stringgrid1.Cells[2,rows+l]; stringgrid2.Cells[2,rows-1]:=stringgrid1.Cells[3,rows+l]; stringgrid2.Cells[3,rows-1]:=stringgrid1.Cells[4,rows+l]; stringgrid2.Cells[4,rows-1]:=stringgrid1.Cells[5,rows+l]; stringgrid2.Cells[5,rows-1]:=stringgrid1.Cells[6,rows+l]; stringgrid2.Cells[6,rows-1]:=stringgrid1.Cells[7,rows+l]; stringgrid2.Cells[7,rows-1]:=stringgrid1.Cells[8,rows+l]; stringgrid2.Cells[8,rows-1]:=stringgrid1.Cells[9,rows+l]; stringgrid2.Cells[9,rows-1]:=stringgrid1.Cells[10,rows+l]; stringgrid2.Cells[10,rows-1]:=stringgrid1.Cells[11,rows+l]; stringgrid2.Cells[11,rows-1]:=stringgrid1.Cells[12,rows+l]; stringgrid2.Cells[12,rows-1]:=stringgrid1.Cells[13,rows+l]; stringgrid2.Cells[13,rows-1]:=stringgrid1.Cells[14,rows+l]; stringgrid2.Cells[14,rows-1]:=stringgrid1.Cells[15,rows+l]; stringgrid2.Cells[15,rows-1]:=stringgrid1.Cells[16,rows+l]; l:=l+3; end; //End of AOM Homework calculation }

/////////////////////Convert to Mass////////////////// //initialization Memo and Table rows rows:=0; stringgrid2.RowCount:=memo2.Lines.Capacity+2; for rows:=0 to memo2.Lines.Capacity-1 do begin volt:=strtofloat(memo2.Lines.Strings[rows]); Mass:=(b*volt+a); stringgrid2.Cells[8,rows+1]:=floattostr(Volt); if radiobutton1.Checked then stringgrid2.Cells[9,rows+1]:=floattostr(Mass); if radiobutton2.Checked then stringgrid2.Cells[9,rows+1]:=floattostr(0.45359237*Mass); end; //Calculating Mass per Second rows:=0; stringgrid2.Cells[9,stringgrid2.RowCount-1]:='0'; for rows:=1 to stringgrid2.RowCount-2 do begin stringgrid2.Cells[10,rows]:=floattostr((((strtofloat(stringgrid2.Cells[9,rows+1]))-(strtofloat(stringgrid2.Cells[9,rows]))))); //Cacclulating Abs value of Mass {stringgrid2.Cells[8,rows]:=floattostr(abs(((strtofloat(stringgrid2.Cells[7,rows+1]))-(strtofloat(stringgrid2.Cells[7,rows]))))); } end; //Make Cell(10,lastrow) and (9,lastrow) look zero and null stringgrid2.Cells[10,stringgrid2.RowCount-2]:='0'; stringgrid2.Cells[9,stringgrid2.RowCount-1]:=''; /////////////////////Convert to Mass//////////////////

//////Yield Calculation //////////////// rows:=0; yield:=0; edit8.Text:='0'; edit9.Text:='0'; for rows:=1 to stringgrid2.RowCount-2 do begin yield:=(strtofloat(stringgrid2.Cells[10,rows]))/(strtofloat(stringgrid2.Cells[7,2])); stringgrid2.Cells[11,rows]:=floattostr(yield); if yield>strtofloat(edit8.Text) then edit8.Text:=floattostr(0.001*trunc(1000*yield)); if yield<strtofloat(edit9.Text) then edit9.Text:=floattostr(0.001*trunc(1000*yield)); end; ////End of Yield Calculation

///Calculating total distance, total Area, Average Speed, Average Yield//////////// rows:=0; sumdist:=0; AveSpeed:=0; AveYield:=0; for rows:=1 to stringgrid2.RowCount-2 do begin sumdist:=sumdist+strtofloat(stringgrid2.Cells[5,rows]); AveSpeed:=avespeed+ strtofloat(stringgrid2.Cells[6,rows]); AveYield:=AveYield+ strtofloat(stringgrid2.Cells[11,rows]); end; edit10.Text:=floattostr(0.001*trunc(1000*AveYield/(strtoint(label2.Caption)))); //Printing Average Yield (lb/ ft2)

if radiobutton2.Checked then begin edit5.Text:=floattostr(0.0001*trunc(10*sumdist)); //Converting Total distance to km and Printing it edit6.Text:=floattostr(0.001*trunc(100*(spinedit1.Value*(strtofloat(edit5.Text))))); //Calculating Total area in Hectare edit7.Text:=floattostr(0.001*trunc(3600*(AveSpeed/(strtoint(label2.Caption))))); // Calculating average speed in km/Hour end; if radiobutton1.Checked then begin edit5.Text:=floattostr(0.001*trunc(0.189393939*sumdist)); //Converting Total Distance to Mile and Pringting it edit6.Text:=floattostr(0.001*trunc(121.212*(spinedit1.Value*(strtofloat(edit5.Text))))); //Calculating Total area in acre edit7.Text:=floattostr(0.001*trunc(681.818182*(AveSpeed/(strtoint(label2.Caption))))); // Calculating average speed in Mile/Hour end; edit19.Text:=floattostr(0.001*trunc(1000*AveYield/(strtofloat(edit6.text)))); //Printing Average Yield (lb/acre)

///End of Calculating total distance, total Area, Average Speed, Average Yield(lb/ft2) and Average Yield (lb/acre)/////////// /////

//Calculating turning time//// rows:=0; gaprows:=0; gaprows2:=0; for rows:=2 to stringgrid2.RowCount-4 do begin if abs(strtofloat(stringgrid2.Cells[3,rows-1])-strtofloat(stringgrid2.Cells[3,rows+2]))>0.000005 then begin stringgrid2.Cells[14,(rows-1)-gaprows]:=stringgrid2.Cells[3,rows+1]; stringgrid2.Cells[15,(rows-1)-gaprows]:=stringgrid2.Cells[4,rows+1]; gaprows2:=gaprows2+1; end else begin gaprows:=gaprows+1; stringgrid2.Cells[16,(rows-1)-gaprows2]:=stringgrid2.Cells[3,rows-1]; stringgrid2.Cells[16,rows-gaprows2]:=stringgrid2.Cells[3,rows+2]; stringgrid2.Cells[17,(rows-1)-gaprows2]:=stringgrid2.Cells[4,rows-1]; stringgrid2.Cells[17,(rows)-gaprows2]:=stringgrid2.Cells[4,rows+2]; end; end; //End of Turning tima Calculation////

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 35

edit3.Text:= floattostr(0.001*trunc(1000*((strtoint(label2.Caption))-(gaprows))/60));

//Caclulating stop time//// rows:=0; gaprows:=0; gaprows2:=0; for rows:=2 to stringgrid2.RowCount-1 do begin if strtofloat(stringgrid2.Cells[5,rows-1])<0.5 then begin stringgrid2.Cells[12,(rows-1)-gaprows]:=stringgrid2.Cells[3,rows-1]; stringgrid2.Cells[13,(rows-1)-gaprows]:=stringgrid2.Cells[4,rows-1]; gaprows2:=gaprows2+1; end else begin gaprows:=gaprows+1; stringgrid2.Cells[18,(rows-1)-gaprows2]:=stringgrid2.Cells[3,rows-1]; stringgrid2.Cells[19,(rows-1)-gaprows2]:=stringgrid2.Cells[4,rows-1]; end; end; //End of stop time calculation// edit2.Text:= floattostr(0.001*trunc(1000*((strtoint(label2.Caption))-(gaprows))/60)); edit4.Text:=floattostr((strtofloat(edit1.Text))-((strtofloat(edit2.Text))+(strtofloat(edit3.Text))));

edit15.Text:=floattostr(0.01*trunc(10000*(((strtofloat(edit4.Text))/((strtofloat(edit4.Text))+(strtofloat(edit3.Text))))))); //Calculating and printing Field Machine Index

progressbar2.Position:=progressbar2.Position+2; end; procedure TForm1.Button2Click(Sender: TObject); begin // Clearing Memo memo1.Text:='Cleared'; // Clearing table for rows:=1 to stringgrid1.RowCount do begin for cols:=0 to stringgrid1.ColCount do begin StringGrid1.Cells[cols,rows]:=''; end; end;

end; procedure TForm1.FileSaveAs1Accept(Sender: TObject); var templine : string; begin memo3.Clear; //show output tab pagecontrol1.ActivePageIndex:=2; // Reading table for rows:=0 to stringgrid2.RowCount-2 do begin for cols:=0 to 19 do begin templine:=templine + StringGrid2.Cells[cols,rows]+','; end; memo3.Lines.Add(templine); templine:=''; end; memo3.Lines.SaveToFile(filesaveas1.Dialog.FileName);

end; procedure TForm1.RadioButton2Click(Sender: TObject); begin if radiobutton2.Checked then begin label5.Caption:='Swath (m)'; label7.Caption:='Total distance traveled (km)'; label8.Caption:='Total Area covered (hec)'; label9.Caption:='Average Travel speed (km/h)'; label22.Caption:='Maximum Yield (Kg/m2)'; label23.Caption:='Minimum Yield (Kg/m2)'; label24.Caption:='Average Yield (Kg/m2)'; end; end; procedure TForm1.RadioButton1Click(Sender: TObject); begin if radiobutton1.Checked then begin label5.Caption:='Swath (ft)'; label7.Caption:='Total distance traveled (mil)'; label8.Caption:='Total Area covered (acre)'; label9.Caption:='Average Travel speed (Mil/h)'; label22.Caption:='Maximum Yield (lb/ft2)'; label23.Caption:='Minimum Yield (lb/ft2)'; label24.Caption:='Average Yield (lb/ft2)'; end; end; procedure TForm1.FormShow(Sender: TObject); begin spinedit1.text:='20'; memo1.Font.Size:=6; memo2.Font.Size:=6; if radiobutton2.Checked then begin label5.Caption:='Swath (m)'; label7.Caption:='Total distance traveled (km)'; label8.Caption:='Total Area covered (hec)'; label9.Caption:='Average Travel speed (km/h)'; label22.Caption:='Maximum Yield (Kg/m2)'; label23.Caption:='Minimum Yield (Kg/m2)'; label24.Caption:='Average Yield (Kg/m2)'; end; if radiobutton1.Checked then begin label5.Caption:='Swath (ft)'; label7.Caption:='Total distance traveled (mil)'; label8.Caption:='Total Area covered (acre)';

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 36

label9.Caption:='Average Travel speed (Mil/h)'; label22.Caption:='Maximum Yield (lb/ft2)'; label23.Caption:='Minimum Yield (lb/ft2)'; label24.Caption:='Average Yield (lb/ft2)'; end;

end; procedure TForm1.FileOpen2Accept(Sender: TObject); begin Memo2.Lines.LoadFromFile(fileopen2.Dialog.FileName); end; procedure TForm1.Button7Click(Sender: TObject); begin { //initialization Memo and Table rows rows:=0; stringgrid2.RowCount:=memo2.Lines.Capacity+2; for rows:=0 to memo2.Lines.Capacity-1 do begin volt:=strtofloat(memo2.Lines.Strings[rows]); Mass:=(b*volt+a); stringgrid2.Cells[6,rows+1]:=floattostr(Volt); stringgrid2.Cells[7,rows+1]:=floattostr(Mass); end; rows:=0; stringgrid2.Cells[7,stringgrid2.RowCount-1]:='0'; for rows:=1 to stringgrid2.RowCount-2 do begin stringgrid2.Cells[8,rows]:=floattostr((((strtofloat(stringgrid2.Cells[7,rows+1]))-(strtofloat(stringgrid2.Cells[7,rows]))))); //stringgrid2.Cells[8,rows]:=floattostr(abs(((strtofloat(stringgrid2.Cells[7,rows+1]))-(strtofloat(stringgrid2.Cells[7,rows]))))); end; //Make Cell(8,lastrow) and (7,lastrow) look zero and null stringgrid2.Cells[8,stringgrid2.RowCount-2]:='0'; stringgrid2.Cells[7,stringgrid2.RowCount-1]:=''; }

end; procedure TForm1.Button9Click(Sender: TObject); begin form2.Show; form2.StringGrid3.Cells[0,0]:='Voltage'; form2.StringGrid3.Cells[1,0]:='Mass'; end; procedure TForm1.Button5Click(Sender: TObject); begin

//Calculating Theoretical harvesting time (min) based on US units if radiobutton1.Checked then begin edit13.Text:=floattostr(0.01*trunc(49500*(strtofloat(edit12.Text))/((strtofloat(edit11.Text))*(spinedit1.Value)))); end;

//Calculating Theoretical harvesting time (min) based on SI units if radiobutton2.Checked then begin edit13.Text:=floattostr(0.01*trunc(60000*(strtofloat(edit12.Text))/((strtofloat(edit11.Text))*(spinedit1.Value)))); end; //Calculating field efficiency (etta f) edit14.Text:=floattostr(0.01*trunc(10000*((strtofloat(edit13.Text))/((strtofloat(edit4.Text))+(strtofloat(edit3.Text))+(strtofloat(edit2.Text))))));

//US Unit, Calculating and printing Theoretical and Actual Machine field capacity (acre/hour) [Ca and Cat] if radiobutton1.Checked then begin edit18.Text:=floattostr(0.01*trunc(12.121212*(strtofloat(edit11.Text))*(spinedit1.Value))); //Theoretical Machine field capacity edit16.Text:=floattostr(0.01*trunc(strtofloat(edit18.Text)*(strtofloat(edit14.Text)))); //Actual Machine field capacity end; //SI Unit ; //Calculating and printing Machine field capacity (hectar/hour) if radiobutton2.Checked then begin edit18.Text:=floattostr(0.01*trunc(0.1*(strtofloat(edit11.Text))*(spinedit1.Value))); edit16.Text:=floattostr(0.01*trunc(strtofloat(edit18.Text)*(strtofloat(edit14.Text)))); end; //Machine material capacity (lb/hour) edit17.Text:=floattostr(0.01*trunc(100*strtofloat(edit16.Text)*(strtofloat(edit19.Text))));

//Theoretical Machine field capacity //Actual Machine field capacity

end; end. unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls, ComCtrls, Spin; type TForm2 = class(TForm) GroupBox6: TGroupBox; Label11: TLabel; Label10: TLabel; SpinEdit2: TSpinEdit; StringGrid3: TStringGrid; Button5: TButton; procedure Button5Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure SpinEdit2Change(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation uses Unit1; {$R *.dfm} procedure TForm2.Button5Click(Sender: TObject); var regrow:integer; begin

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 37

//Initialization, set variabeles to zero sumx2:=0; sumy:=0; sumx:=0; sumxy:=0; a:=0; b:=0; for regrow:=1 to stringgrid3.RowCount-1 do begin sumx2:=sumx2+(strtofloat(stringgrid3.Cells[0,regrow])*strtofloat(stringgrid3.Cells[0,regrow])); sumy:=sumy+strtofloat(stringgrid3.Cells[1,regrow]); sumx:=sumx+strtofloat(stringgrid3.Cells[0,regrow]); sumxy:=sumxy+(strtofloat(stringgrid3.Cells[0,regrow])*strtofloat(stringgrid3.Cells[1,regrow])); end; { label12.Caption:=label12.Caption+floattostr(sumx2); label13.Caption:=label13.Caption+floattostr(sumy); label14.Caption:=label14.Caption+floattostr(sumx); label15.Caption:=label15.Caption+floattostr(sumxy); label16.Caption:=label16.Caption+floattostr(sumx*sumx); } a:=(((sumx2)*(sumy))-((sumx)*(sumxy)))/(((stringgrid3.RowCount-1)*sumx2)-(sumx*sumx)); b:=(((stringgrid3.RowCount-1)*sumxy)-((sumx)*(sumy)))/(((stringgrid3.RowCount-1)*sumx2)-(sumx*sumx)); label10.Caption:='Mass= '+ floattostr((trunc(b*100))/100) +'(V)' + floattostr((trunc(a*100))/100); end; procedure TForm2.FormShow(Sender: TObject); begin spinedit2.text:='7'; stringgrid3.Cells[0,1]:='0.082285'; stringgrid3.Cells[0,2]:='0.342275'; stringgrid3.Cells[0,3]:='0.607187'; stringgrid3.Cells[0,4]:='0.869751'; stringgrid3.Cells[0,5]:='1.132676'; stringgrid3.Cells[0,6]:='1.393628'; stringgrid3.Cells[1,1]:='0'; stringgrid3.Cells[1,2]:='52'; stringgrid3.Cells[1,3]:='104.5'; stringgrid3.Cells[1,4]:='155.5'; stringgrid3.Cells[1,5]:='207'; stringgrid3.Cells[1,6]:='259'; end; procedure TForm2.SpinEdit2Change(Sender: TObject); begin stringgrid3.RowCount:=spinedit2.Value; end; end.

Ramin Shamshiri

AOM5435 Final Project, Dec.01.2008

Page 38

Das könnte Ihnen auch gefallen