5 Sprayer Function

By Piyush Patel

5.1 Project Functionality

Sprayer function uses the analog knobs to change the pressure and cycle speed of the tractor sprayer and displays the fluid left, the pressure, and the cycle speed on the LCD screen. For creativity, the pattern of the sprayer and fluid level is viewed on the LED Bargraphs.


pict


Sprayer function is called using the smart farming menu through Q-Term. Q-Term LCD will display how much fluid is in the tank, the pressure, and the cycle speed of the sprayer. LED Bargraph 1 will show the pattern that is used to spray the fluid. 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 getting close to being empty. The main functionality of the sprayer function is the analog knobs. Analog knob 0 is used to change the pressure of the sprayer and analog knob 1 is used to change the cycle speed of the sprayer. Increasing the analog knob 0 will increase the pressure, therefore the sprayer will use slightly more fluid than before. Similarly, increasing analog knob 1 will increase the speed of how fast the sprayer sprays. This will use even more fluid because the sprayer will spray faster. Due to that, LED Bargraph 1 will display the pattern faster and the fluid level will go down faster on LED Bargraph 2. To manually exit the sprayer function, turn on bit 0 of DIP Switch 1. Otherwise the function will automatically exit when the fluid left reaches 0.

5.2 Project Design

Sprayer function is completely programmed in C with a variety of new features added to Lab 5. The main part of the function is the while loop where all the user controlled features are handled. Depending on the value passed in for iCurrentSeedType, a particular pattern function is called to print the pattern on LED Bargraph 1. To print on the LED Bargraphs, a variable is declared to hold the value to be printed, and then accordingly a bargraph function is called with the variable as the parameter to print. ”msleep(1000-AV1*30)” is an algorithm used to increase or decrease how fast the pattern is printed on bargraph depending on the value of AV1, which is the value read in from analog knob 1 and converted so it is between 0-100. I used one more random algorithm to decrease the fluid depending on input from analog knob 0 and analog knob 1. All of the LED Bargraphs are reset before exiting. If the fluid goes down to 0 at the end, a message will be displayed on the LCD screen to inform the user.