6 Add Fluid

By Ankur Tandon

6.1 Project Functionality

AddFluid function, as the name suggests, adds life (fluid) to the Smart Tractor. With the use of analog knobs, the speed of refuelling can be adjusted at any time. The percentage of the tank filled is displayed on the LCD screen. The features that make this function and the tractor overall ’smart’ is the pattern displayed on the LED Bargraphs outputting the level of fluid in the tank and the handy feature that allows the smart farmer to exit refuelling any time.


pict

Figure 3: Smart Farming Layout


With the right selection from the smart farming command options on the Q-Term, AddFluid function can be called by the farmer any time he wants to add more life for better performance of his tractor. Q-Term LCD displays how much fluid is in the tank. LED Bargraph 2 shows the fluid level; if bits 0-7 are lit up, then it means the fluid tank is full or almost full and if only bit 0 is lit up, it means the fluid tank is close to being empty. The refill speed, another important aspect of refuelling the tank, can be adjusted by using the analog knobs. Increasing the analog knob 0 will increase the refill speed, thereby filling the tank at a faster rate than before. In order to make the tractor smart, Bit 0 of Dip Switch 1 has been left so at his/her discretion, the farmer can manually exit the refuelling process. Turning on bit 0 stops the refuelling process and returns the exact amount of fluid to the main function. Thus a farmer can fill the tank any time according to his own interest.

6.2 Project Design

AddFluid function is completely programmed in C. A variety of features were added to Lab 5 to make this function more farmer-friendly. The main part of the program is the recursive while loop which continually checks for the farmer’s need through out the function. Depending on the fluid level passed from the main function, AddFluid adds more to it continuously regulating the speed as desired by the smart farmer. Continuous level increase inside the tank is displayed on the LED Bargraph 2. To print on the LED Bargraphs, a variable is declared to hold the value to be printed, and then a bargraph function is called with the variable as the parameter to print. All of the LED Bargraphs are reset before exiting. If at any time the user sets bit 0 of Dip Switch 1, the current value of fluid level is returned to the main function. As a courtesy, it informs the user of the exact value of fluid level before exiting the loop.