Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

https://eclass.yorku.ca/eclass/pluginfile.php/3107479/mod_resource/content/1/MinorProject_EECS1011_MainDoc_Nov2021_v2 EECS 1011 Minor Project Info Document (v2) Nov XXXXXXXXXX Copyright James Andrew...

1 answer below »

https:
eclass.yorku.ca/eclass/pluginfile.php/3107479/mod_resource/content/1/MinorProject_EECS1011_MainDoc_Nov2021_v2
EECS 1011 Minor Project Info Document (v2) Nov XXXXXXXXXX
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
Minor Project: Auto Plant Watering with Arduino and Matlab
James Andrew Smith
Assoc. Prof., York University

[update]

This document begins with a discussion of an important software concept for your project: state
machines. It then goes on to describe the components in the project. This is a major revision of
an earlier document and so some elements that describe the project, the reporting and the goals
will be added at a later date.


Introduction to State Machines

State machines are a fundamental concept in developing programs and control systems. They’re
not really “machines” like a car engine, elevator or amusement ride. Instead, think of them as the
core of a program that takes actions based on things that are sensed or measured.

Hunger example

It’s almost lunch time and you’re in a state of hunger. What do you do? You go eat. Once you’re
done eating, you’re in a state of satiation (you’re not hungry). So, you no longer eat.

What I’ve just described is you as a “state machine”: a machine with states (e.g. conditions,
feelings, sensed things). What is sensed drives the state of you or an object. In response to the
sensing and the state it results in, an action is taken. In other words, a state machine produces an
action in response to what it senses or perceives.


Figure 1 A state machine to describe what to do when you're hungry or not.


Reference: Finite State Machines on Wikipedia: https:
en.wikipedia.org/wiki/Finite-state_machine
Watering example

EECS 1011 Minor Project Info Document (v2) Nov XXXXXXXXXX
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
Something similar to the hunger example on the previous page happens in an automated plant
watering system like the one you’ll work on for your minor project.

To control the plant watering in your project you’ll need to organize your Matlab program so that
it is reactive:

1. if the soil is dry, then water it;
2. if the soil is wet, but not too wet, then also water it;
3. if the soil is wet enough, then don’t water it.

In the list above the soil being dry is the first state of your system. The second state is described
y the soil being “wet, but not too wet”. The third state is “wet enough”. Each of these states has
an action associated with it:

1. State: dry à Action: Water
2. State: wet, but not too wet à Action: Water
3. State: wet enough à Action: Don’t Water

What does this maybe look like in a program?1

1. if(readVoltage(myBoard,soilSensor) < reallyDryValue) then writeDigitalPin(myBoard,PumpPin,OnSignal)
2. if(readVoltage(myBoard,soilSensor) < moistureThreshold) then writeDigitalPin(myBoard,PumpPin,OnSignal)
3. if(readVoltage(myBoard,soilSensor) <= saturatedValue) then writeDigitalPin(myBoard,PumpPin,OffSignal)

Of course, the code written isn’t strictly co
ect… it’s close. You’ll have to adapt it to Matlab by:
1. Writing the if-else structure co
ectly
2. Defining the myBoard, soilSensor, reallyDryValue, etc. values.






1 This is pseudo-code. It won’t run without modification.
EECS 1011 Minor Project Info Document (v2) Nov XXXXXXXXXX
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
A Traffic Light State Machine Function in Matlab

Here’s a classic state machine: traffic lights. We use time as the measured input and return two
outputs: a displayed value and a function output.

In the table below, you can see how I call the Matlab function from the command line, providing
the starting time as 0 as the first input parameter and the cu
ent time as the second input parameter.


Example: Green light state Example: Yellow light state Example: Red light state

You can see that the function responds by displaying a message and also by returning a string
(“Green”, “Yellow” or “Red”).

function trafficLightState = ...
whatLightColourIsIt(startTime, cu
entTime)

% define boundary times for light signals XXXXXXXXXX
seconds)
edStart = 0; % Red starts at 0 sec
edEnd = 5; % Red ends at 5 sec
yellowStart = redEnd; % Yellow starts @ Red end
yellowEnd = 7; % Yellow ends at 7 sec
greenStart = yellowEnd; % Green strt @ Yellow end
greenEnd = 12; % Green ends at 12 seconds



% What part of the timed light cycle are we on?
% Use the "modulo" operation to synchronize on 12
% seconds limit (greenEnd)
cyclePart = mod(cu
entTime,greenEnd); % if
cyclePart is 0 we have restarted.

% Begin the "IF", linking cyclePart's time to
the light's state.
if(cyclePart < redEnd) % Red light "state"
XXXXXXXXXXdisp("State: Red Light.");
XXXXXXXXXXtrafficLightState = "Red";
elseif(cyclePart < yellowEnd) %Yellow "state"
XXXXXXXXXXdisp("State: Yellow Light.");
XXXXXXXXXXtrafficLightState = "Yellow";
elseif(cyclePart <= greenEnd) % Green "state"
XXXXXXXXXXdisp("State: Green Light.");
XXXXXXXXXXtrafficLightState = "Green";
else % E
or "state"
XXXXXXXXXXdisp("ERROR: big time e
or!");
XXXXXXXXXXtrafficLightState = "ERROR";
end % end of the if statement


end % end of the function





Source code State machine diagram

The details for creating the function are below, along with a visualization of the flow of the
program. The complete traffic cycle is expected to last 12 seconds in this example. We use the
EECS 1011 Minor Project Info Document (v2) Nov XXXXXXXXXX
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
modulo function to deal with time above 12 seconds as simply a multiple of the same process, so
that 12 to 24 seconds behaves the same as 0 to 12.


EECS 1011 Minor Project Info Document (v2) Nov XXXXXXXXXX
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
The Minor Project

The minor project involves using a Matlab program connected to an Arduino-compatible board
to monitor and maintain plant soil moisture.

Objective and Execution

You should create a program in Matlab that allows long-term monitoring of the plant soil to
ensure that the plant receives water as it needs it. That means measuring the soil moisture using
a soil moisture sensor attached to your Arduino or Grove board. When the soil is dry, have a
MOSFET or Relay board turn a water pump on to deliver water to the soil, turning off the pump
when there is enough water in the soil. Then wait until the soil is dry again and start the process
over again.

While you should be able to connect your computer to your Arduino or Grove board for days at a
time to let the dry-wet-dry-wet cycle occur over and over, you can also unplug the board and
estart the program if need be.

The core of your Matlab program should resemble a state machine, as shown in the previous
pages. However, instead of controlling traffic lights, your state machine should be controlling
water flow.

Submission for Final Report and Video

All students are to submit

1. A three page report describing their project
2. A one minute video describing their project
3. The Matlab source code for their project


EECS 1011 Minor Project Info Document (v2) Nov XXXXXXXXXX
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
The report

The report must

1. Include a cover page with
a. Your name and student ID
. The class name
c. The date
d. An abstract
i. An example abstract is given to the right
ii. Include all of the bolded headings
iii. One paragr
2. Show your plant and your hardware setup
a. Label the different parts, in a similar fashion to
how I have with my plant watering setup.
3. Include an illustration of the flow of your Matlab
program. This is commonly known as a flow-chart.
a. What is a flowchart? Read this page: https:
en.wikipedia.org/wiki/Flowchart
. You can draw the flowchart by hand or with the help of a computer program
(even Powerpoint can do it!)
c. Make sure that components like loops and conditional statements are clearly
illustrated
Answered Same Day Nov 30, 2021

Solution

Sathishkumar answered on Dec 01 2021
116 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here