Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use MATLAB for writing code Matlab (or any other simulation software) can be used to develop and test an algorithm, which can later be implemented

Use MATLAB for writing code

image text in transcribedimage text in transcribed

Matlab (or any other simulation software) can be used to develop and test an algorithm, which can later be implemented in a real hardware prototype. The algorithm developed and tested in Problem 1 can be useful in a real prototype. If you were to detect the frequency of an actual analog periodic signal, the signal would replace "newValue", and the rest of the algorithm would work fine. For example, if you connected the output of a Waveform Generator (generating a periodic signal) to one of the analog input pins of your Launchpad and measured that voltage at a certain sampling rate, you would periodically obtain the "newValue (e.g. newValue = 3.3/4095 * analogRead(A1); delay (Ts); etc.). You could take the algorithm from Problem 1 and implement it in Energia code; it would give you the frequency of the periodic signal from the Waveform Generator. When performing simulation, you have the opportunity to test how an algorithm would perform under various conditions. However, you need to be able to create an environment that imitates the real-world scenario. In this problem, you will develop a test bench and write a simple algorithm for a Temperature Controlled Fan described below. Assume that an analog temperature sensor's output is connected to one of the analog input pins of your Launchpad (where the temperature sensor's output voltage is linearly related to the temperature). When the temperature is above a certain value Thigh, you want to turn a fan ON. If the fan is ON and the temperature is below Tlow, you want to turn the fan OFF. The fan is controlled by a GPIO pin of the Launchpad, i.e. the fan is either ON or OFF (corresponding to the pin output being HIGH and LOW, respectively). Writing a program in Energia to perform the above task should not be very complex. However, if performing a simulation, you need to generate a random sequence of temperature values, and you need to simulate the effect of the fan on that sequence. In this problem, you will see how this can be done using the simple temperature characteristics stated below. Sample the temperature every 0.1 seconds. Assume that the temperature changes over time as follows: It starts at 20C in the first sampling instance. Thigh is 25C and Tow is 18C. For the subsequent sampling instances, the probability is P that the temperature will change from what it was in the previous sampling instance. For example, if P = 0.3 and the 20th sample is 21C, then there is a 70% probability that the 21 sample will remain 21C, and a 30% probability that it will change (you can use the Matlab command rand). If the temperature is to change, then the amount of change will be a uniformly distributed random variable between M C and N C. When the fan is OFF, M = -0.1, N = +0.2, P = 0.01. When the fan is ON, M = -0.2, N = +0.1, P = 0.02. If you generate this temperature sequence, you will see that it rises over time slowly when the fan is OFF. When the fan turns ON, it will decrease slowly. (a) [35 points] Generate a temperature sequence of a reasonable length using the characteristics stated above, and implement the fan control algorithm. Display a plot showing the temperature as well as the status of the fan. Run the program a few times and include a few plots showing different iterations. (b) (15 points) Find the percentage of time the fan is ON for Part (a). Assume you have an application where the temperature needs to be between 15C and 30C. Try a few different combinations of Thigh and Tlow to see how they affect the percentage of time the fan is ON. Matlab (or any other simulation software) can be used to develop and test an algorithm, which can later be implemented in a real hardware prototype. The algorithm developed and tested in Problem 1 can be useful in a real prototype. If you were to detect the frequency of an actual analog periodic signal, the signal would replace "newValue", and the rest of the algorithm would work fine. For example, if you connected the output of a Waveform Generator (generating a periodic signal) to one of the analog input pins of your Launchpad and measured that voltage at a certain sampling rate, you would periodically obtain the "newValue (e.g. newValue = 3.3/4095 * analogRead(A1); delay (Ts); etc.). You could take the algorithm from Problem 1 and implement it in Energia code; it would give you the frequency of the periodic signal from the Waveform Generator. When performing simulation, you have the opportunity to test how an algorithm would perform under various conditions. However, you need to be able to create an environment that imitates the real-world scenario. In this problem, you will develop a test bench and write a simple algorithm for a Temperature Controlled Fan described below. Assume that an analog temperature sensor's output is connected to one of the analog input pins of your Launchpad (where the temperature sensor's output voltage is linearly related to the temperature). When the temperature is above a certain value Thigh, you want to turn a fan ON. If the fan is ON and the temperature is below Tlow, you want to turn the fan OFF. The fan is controlled by a GPIO pin of the Launchpad, i.e. the fan is either ON or OFF (corresponding to the pin output being HIGH and LOW, respectively). Writing a program in Energia to perform the above task should not be very complex. However, if performing a simulation, you need to generate a random sequence of temperature values, and you need to simulate the effect of the fan on that sequence. In this problem, you will see how this can be done using the simple temperature characteristics stated below. Sample the temperature every 0.1 seconds. Assume that the temperature changes over time as follows: It starts at 20C in the first sampling instance. Thigh is 25C and Tow is 18C. For the subsequent sampling instances, the probability is P that the temperature will change from what it was in the previous sampling instance. For example, if P = 0.3 and the 20th sample is 21C, then there is a 70% probability that the 21 sample will remain 21C, and a 30% probability that it will change (you can use the Matlab command rand). If the temperature is to change, then the amount of change will be a uniformly distributed random variable between M C and N C. When the fan is OFF, M = -0.1, N = +0.2, P = 0.01. When the fan is ON, M = -0.2, N = +0.1, P = 0.02. If you generate this temperature sequence, you will see that it rises over time slowly when the fan is OFF. When the fan turns ON, it will decrease slowly. (a) [35 points] Generate a temperature sequence of a reasonable length using the characteristics stated above, and implement the fan control algorithm. Display a plot showing the temperature as well as the status of the fan. Run the program a few times and include a few plots showing different iterations. (b) (15 points) Find the percentage of time the fan is ON for Part (a). Assume you have an application where the temperature needs to be between 15C and 30C. Try a few different combinations of Thigh and Tlow to see how they affect the percentage of time the fan is ON

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial Accounting And Reporting A Global Perspective

Authors: Herve Stolowy, Yuan Ding, Luc Paugam

6th Edition

147376730X, 9781473767300

More Books

Students also viewed these Accounting questions