1. Homepage
  2. Programming
  3. ENGR 131: Elementary Computer Programming - Lab Exercise #7: Dishwashers

ENGR 131: Elementary Computer Programming - Lab Exercise #7: Dishwashers

Engage in a Conversation
USCASECase Western Reserve UniversityENGR 131ENGR131Elementary Computer ProgrammingDishwashers

Lab Exercise #7

INSTRUCTIONS

Complete the exercises below and upload them Canvas as a single MATLAB script file using the naming convention “ENGR131_22F_Lab##_abc123.zip”, replacing abc123 with your Case ID, and ## with the twodigit lab number. For example, if Dr. Williams were submitting Lab 6 it would be ENGR131_22F_Lab07_mrw8.zip For your script, please perform the following: CourseNana.COM

  1. You may use the code and notes from class, the textbook, lecture videos, MATLAB’s documentation, and anything you find using Google to solve these problems.
  2. Use comments as appropriate to indicate your thoughts and how your code works (or is supposed to work). This is 5 points (10%) of your grade.

    QUESTIONS

    Dishwashers are common machines in many households. These appliances control the flow of water, energy (heat) and mechanical operation of their washing mechanism without us thinking about them too often. For this lab, we’re going to model the basic operation of a dishwasher as a GUI. Our model will also collect data for postwash analysis. CourseNana.COM

1. CREATE THE GUI (10 PTS, 1 PT EACH)

Create a two-panel GUI similar to that shown in Figure 1 by dragging and placing items from the Component Library in the Design View of App Designer (left side of environment). Give each item a meaningful name in the Property Inspector (right side of environment). It doesn’t have to be exactly as shown, but it must include the following elements: A. A discrete knob for selecting the wash level. You will have to edit the values to have Light, Medium, and Heavy wash options B. Buttons for running the washer and plotting. These can be any color you choose C. A switch to represent the door D. A text area a. Change the background color to blue and the text to cyan b. Set the default values to those shown in Figure 1. E. Four lamps for Water, Heating, Washing, and Clean indicators F. A gauge to show the wash progress. It can be any type you choose. G. A slider to indicate the number of total washes H. Radio button group to select which type of data to show a. Remove one of the options so you have only two b. Change the button names to those shown in Figure 1. I. A drop down menu with options for Red, Green, and Blue J. A plotting axes CourseNana.COM

Fig 1. An example of the interface for a dishwasher CourseNana.COM

2.CREATE APP PROPERTIES (2 PTS, 0.5 PT EACH)

To share data between callbacks, in the Code View, create app Properties in the Code Browser (left side of environment) using the “+” to add to properties to your app. Give these appropriate names similar to the following: A. WaterLevel. B. WaterTemp C. TotalFillTime D. TotalHeatTime CourseNana.COM

3. CREATE USER DEFINED FUNCTIONS (8 PTS, 4 PTS EACH)

For proper functionality, you will need the following user defined functions: A. A startupFcn. a. With the Code Browser set to Callbacks, press the “+” to bring up the Add Callback Function window. Select startupFcn from the Callback pulldown menu b. Initialize the door switch value to ‘Open’ c. Set the door status in the second line of the status text box by using the line app..Value{2,1} = ‘Door: Open’; where is the name you gave the text area. Keep in mind that this uses cell notation such the first line is {1,1}, the second {2,1} etc. d. Set the background color of the text area to red. B. A function to set the plotting line and color type a. Select Functions in the Code Browser. Pres the “+” to create a function template in your app code. Change the name and add an input argument to pass in the selected color selection. Be sure to keep the (app) input as well. b. Use a selection statement to set the results variable to an appropriate line and color specification (ex. r-- for a red dashed line) based on the color selected by the user. CourseNana.COM

4. CREATE CALLBACKS (25 PTS)

Now it’s time to set up all the controls and displays our GUI. For each element below, in the Design View, right click on element and select “Callback -> Add callback”. The specific name may be different for each element, but the offered suggestion is the one you want. For most controls, the default callback starts with assigning the value of the control to a default variable. You will use this variable in your callback A. Wash Level Knob (2 pts) a. Change the value of the status textbox (line 1) to indicate the selected wash level by concatenating the text ‘Wash: ‘ and the value of the knob B. Door switch (3 pts) a. Use a selection statement to change the background color of the status text box, blue for closed, red when open. Remember to use the contains command when checking the values of strings b. Change the second line of the status textbox by concatenating the text ‘Door: ‘ and the value of the switch C. Run Button (16 pts) a. Initialize the properties created in Part 2. Set all to 0 except WaterTemp which will start at 120. b. Use a while loop to wait until the door (switch) is closed. i. If it’s open, change the 3rd line of the status textbox to some sort of warning ii. Pause for 0.5 s iii. Once the loop is done, clear the third line of the status textbox c. Simulate filling the water tub i. Set the Water lamp to blue ii. Change the third line of the status textbox to ‘Filling Tub’ or similar iii. Start a timer iv. Use a while loop that runs for 5 s CourseNana.COM

  1. Increment WaterLevel by growing the vector each time through the loop. The value of the added element is the current timer/5
  2. Increment TotalFillTime by growing the vector each time through the loop. The value of the added element is the current timer
  3. Use the drawnow command to instruct Matlab to change the lamp color.
  4. Pause for 0.1 s v. Once the loop is done, change the Water lamp back to black vi. Change the third line of the status textbox to ‘Tub Full’ or similar vii. Pause for 1 s d. Repeat step C.c but for the heater. The main differences are: i. Instead of running for a predetermined amount of time, the while loop should run until the temperature reaches 180 or more ii. Water temperature = round(180 – 60e-0.12C ) where C is the number of times through the loop. iii. Be sure to include the messages to the status text box and the Heating lamp. e. Get the washing time by using selection statements and the value of the WashLevel knob. Times should be 5, 10, and 20 s respectively for Light, Medium, and Heavy choices. f. Repeat step C, but the while loop runs for the amount of time determined in step C.e. i. Within the while loop, set the Wash Progress gauge to (current time/washing time)100 g. Once the wash is complete, increment the slider based on the Wash Level – 0.5 for Light, 1 for Medium, and 2 for Heavy D. Data Plotting (4 pts) a. Get the color and line specification by calling the user defined function 3.B and pass in app and the value from the pull-down menu. b. Use a conditional statement to plot either the water level or the water temperature over time based on the value of the radio buttons (they will be logicals 1, if that button is selected, 0 if not selected). c. Plot the selected data using the color spec from part D.a. d. Change the Titles and axis labels accordingly to the data presented.

Hints:

• As you code this, proceed incrementally. Get one part working at a time to reduce frustration and improve your understanding of the syntax. • You may find it helpful to include outputs to the Command window as you get things working. Using something as simple as disp(‘Filling Tub’) when you start that portion of the code (Part 4.C.c) and disp(‘Tub Full’) when it’s done can let you know what is going on inside the code. • The run button code may seem complicated, but it’s not much more than three while loops in a row. Once you get one working, the other two are very similar. CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
US代写,CASE代写,Case Western Reserve University代写,ENGR 131代写,ENGR131代写,Elementary Computer Programming代写,Dishwashers代写,US代编,CASE代编,Case Western Reserve University代编,ENGR 131代编,ENGR131代编,Elementary Computer Programming代编,Dishwashers代编,US代考,CASE代考,Case Western Reserve University代考,ENGR 131代考,ENGR131代考,Elementary Computer Programming代考,Dishwashers代考,UShelp,CASEhelp,Case Western Reserve Universityhelp,ENGR 131help,ENGR131help,Elementary Computer Programminghelp,Dishwashershelp,US作业代写,CASE作业代写,Case Western Reserve University作业代写,ENGR 131作业代写,ENGR131作业代写,Elementary Computer Programming作业代写,Dishwashers作业代写,US编程代写,CASE编程代写,Case Western Reserve University编程代写,ENGR 131编程代写,ENGR131编程代写,Elementary Computer Programming编程代写,Dishwashers编程代写,USprogramming help,CASEprogramming help,Case Western Reserve Universityprogramming help,ENGR 131programming help,ENGR131programming help,Elementary Computer Programmingprogramming help,Dishwashersprogramming help,USassignment help,CASEassignment help,Case Western Reserve Universityassignment help,ENGR 131assignment help,ENGR131assignment help,Elementary Computer Programmingassignment help,Dishwashersassignment help,USsolution,CASEsolution,Case Western Reserve Universitysolution,ENGR 131solution,ENGR131solution,Elementary Computer Programmingsolution,Dishwasherssolution,