代做ELEC4632 Lab 2代写留学生R语言

ELEC4632 Lab 2

Identifying a linear model for a water-tank system via MATLAB® and Simulink Desktop Real-Time® Toolbox

In this lab, you will be running a pre-built Simulink model in MATLAB real-time environment using Simulink Desktop Real-Time® Toolbox to collect input and output data from a Water-Tank (W-T) system. Then, using similar MATLAB code to what you have created for Lab 1, you should apply linear least square method to identify a second order discrete-time model for the experimental setup you are working with.

You must study the Water-Tank  System section of the ELEC4632  Lab  Guide to  familiarize yourself with the experimental W-T setup in this lab.

Experiment description

As we mentioned in the ELEC4632 Lab Guide, the objective is to control the water level in one tank by regulating the pump attached to the same tank, while water can flow to the second tank and exits both tanks. In this case, input signal is the applied voltage to one pump (Pump#1), and output signal is the water level in the same tank (TANK#1). Wire connections should be already configured for TANK#1 and PUMP#1 (refer to Fig. 3 in ELEC4632 Lab Guide). However, in some W-T setups, wires may be connected to TANk#2 and PUMP#2 due to some technical issues on TANK#1 and PUMP#1.

Since  our  goal  is  to  identify  a  linear  model  for  the  W-T  system,  we  must  first  find  a  proper operating range for the system. The W-T system is naturally a nonlinear system, but it can be approximated by a linear model if it is operated within a specified range of input and output. Thus, we  need  to determine a  range  of  input voltage that  creates  a  linear  output,  and this can  be achieved by a trial-and-error approach. In our case, the linear output range can be considered somewhere between 80-110ml as the minimum range and 240-280ml as the maximum range. However, the  input voltage  range  corresponding  to these  levels  are  highly  dependent  on  the valves positions. As mentioned before in the ELEC4632 Lab Guide, there are three valves in the W-T system that can be adjusted, two outflow valves  (VALVE#1 and VALVE#2), and one in- between two tanks (MAIN VALVE) as shown in Fig. 1. Any small change in the position of each valve would dramatically change the dynamics and behavior of the system, and it would require different  input voltage  range to cover the above-mentioned output  range.  Finding  the suitable linear input voltage range without putting some restrictions is very difficult and time consuming. Nevertheless, to facilitate the lab procedure, we limit the upper bound of input voltage range, Vmax to be 3V.

You will need to reduce the input voltage without changing valves positions until the water level goes down to around 80-110ml and stays there. That voltage would be the lower bound of input voltage Vmin. Detailed steps of finding linear input voltage range is given in the following section.

Fig. 1. Three valves setting of a W-T setup.

Lab Exercise and Procedure (2 marks)

To collect input and output data from the W-T setup, a Simulink model has been created which works with the Simulink Desktop Real-Time Toolbox in MATLAB. Follow the steps below to run the system and collect the real-time data for system identification.

Important: After step 4, perform system identification and model verification on the newly collected data using your own MATLAB the same way you did in lab 1.

1. Running the Simulink Model (0.2 marks, checked after 15 minutes)

a.  The Simulink file is available on Moodle named WaterTankSysIden.slx. Download the file from Moodle and save it in the MATLAB default directory (Documents/MATLAB). This Simulink model contains multiple blocks as shown in Fig. 2. The model is configured to run with the sampling time of 0.75 seconds.

Fig. 2. (a) The W-T system model prepared for the purpose of system identification, (a) W-T subsystem.

b.   Run the model by clicking on Run in Real Time button found at the top of the Simulink model below the toolbar after clicking on the tab “DESKTOP REAL-TIME” as shown in Fig. 3.

Fig. 3. Screenshot of Simulink file toolbar showing Run button.

c.   Double  Click on the Scope block to see the signals showing changes in the input pump voltage and output water level. The water level sensor generates a voltage signal ranging from 0-5V corresponding to water levels from 0-300ml. In some W-T setups, they may not be properly calibrated, and you may see a slightly lower range for output measurements.

2. Finding Linear Voltage Range (0.3 marks, checked after 45 minutes)

As you can see in the Simulink model in Fig. 2(a), there are two input signals connected to the W-T system block, and you can switch between them by on the Manual Switch block, even when you are running the model in real-time. The Step block has unit value by default. The Repeating  Sequence  Stair block  can  be  configured  to  generate  a  series  of  pulses  with different amplitudes. The Step block is connected to W-T system with a Gain block in its path that allows you to change values of input voltage signal during real-time operation. Just double click  on Gain block  to  open   its  configuration   page   (you  can  change  the  settings   and parameters of any block in Simulink by double clicking on them). We use Step block to run tests and find linear input voltage range, and Repeating Sequence Stair block to generate input signal for system identification after we find a proper linear input range. Two Saturation blocks are placed at the input of the W-T system block to protect the system from any voltage higher than the maximum nominal voltage of the pumps. Two Gain blocks (i.e. Activation Gain TANK#1 and Activation Gain  TANK#2)  are  used  for  activating either or  both  pumps  (here TANK#2 is not physically wired to the W-T setup). For safety and smooth operation of W-T setup, Saturation blocks are set to 0-3V. Now, make sure the Manual Switch is connected to Step block and follow the procedures given below to find the linear input range.

Usually, the WT valves need to be adjusted to make sure that the water level stays within the desired range. The following steps can be done while the Simulink model is running.

a.   Start by applying Vmax = 3V. To do so, set the Gain block for the step input to 3. Wait till the water level in TANK#1 settles in-between 240-280ml. Then, write down the corresponding water level in the table below.

b.  After finding the water level corresponding to Vmax, you need to find a proper Vmin  which will make the water level come down to the region 80-110ml. Initially, set the Gain block for the step input to 2.2, and observe the corresponding water level. Every time you change the gain value, you need to wait until the water level settles down. Keep reducing the gain by

0.1V until the water level reaches the region 80-110mL. This obtained voltage is the lower bound of input voltage Vmin. Keep a record of the actual water level at Vmin     in-between 80- 110ml.

c.   Once you find suitable input voltage and output ranges, write them down in the table below.

3. Preparation for data collection (0.5 marks, checked after 1 hour 15 minutes)

a.   Find the input voltage offset using the following formula and name it u_offset,

(1)

and use it in the Constant block named u_offset as shown in Fig.2(a). This input voltage offset will bring water level around the middle of the specified linear output range, which would be output offset and you must estimate it after recording the data as you did in Lab

1. The input offset is then added to input pulses coming from Repeating Sequence Stair block, which is considered to be offset-free input signal, to generate actual input voltage to W-T system.

b.  The pulse values in Repeating Sequence Stair block should be chosen based on the linear input voltage that you obtained before. Make sure that offset-free input contains both high and low jumps between two consecutive pulse levels, but it should not exceed linear input voltage range, i.e.,

(2)

where u(k) is offset-free input voltage (from here on, we call u(k) as control input), umin and umax  are the offset-free control input range. If the default values for offset-free input signal in Repeating Sequence Stair block are within your identified range in Eq. (2), you can use them.

c.   The next step is to choose a suitable period for the offset-free input in Repeating Sequence Stair block. Inside the block, you have to set the Sample Time dialog box of the block as the period of the offset-free input signal. The default value is 230×0.75 =  172.5sec. To change this value just change the number 230, since the final value must a multiple of the system sampling time 0.75sec. To find an optimum period for the Repeating Sequence Stair block, run the model and make sure to connect the Step block to the W-T system and set the value of the Gain block to u_offset which you have calculated in the previous steps. Wait until the water gets stable around the middle of the specified linear output range (output offset). Then, raise the input voltage to Vmax   = 3 and wait  until the water reaches its maximum level around 240-280ml.

d.   Once the water level remains steady, stop the model and use the Scope Zoom option or Curser Measurements tool to find the amount of time it took for the water to settle at its maximum level when you have raised the voltage to Vmax  = 3. Divide that time by 0.75 and compare it with the default value of 230 to see whether you need to replace it or not. If it is greater  than  230,  you  have  to  use  your  calculated  period  (i.e.  set  the  period  to your_value×0.75). Make sure not to use a very large number to avoid waiting for a long time when collecting the data. For example, if you get a value greater than 250, use 250 instead (i.e. the period will be 250×0.75).

Note that since we run the W-T system  using low input voltage range (less than 3V), the settling time and time constant of the system are too long. This means that after any change in input voltage level, it would take a while for the water to settle on a specific level. Also, each W-T setup may have completely different characteristics. Thus, the default period of 172.5sec may not be long enough for the water level to settle, and incomplete output data would result in a wrong identified model.

4. Real-time input-output data collection (0.5 marks, checked after 1 hour 45 minutes)

a.   Make  sure all the  proper settings  are  in  place. Switch to Repeating  Sequence  Stair block plus u_offset block by clicking on the Manual Switch block. Run the model, and open the Scope to see real-time signals. Note that the initial voltage being sent to the system will be u_offset since Repeating Sequence Stair block will generate zero value within its first period (Why?). This time should be enough to raise water level to the middle of the linear output range you determined before (output offset).

b.  Wait for at least two full sequences of input pulses to be sent to the system. Then, you can stop the program. You would have some results similar to what is shown in Fig. 4. The recorded data will appear in the Workspace with the name LogData in a Structure format. Moreover,    the     data     is     always     saved     in     the     default     MATLAB     directory (Documents/MATLAB). The name of the data file is SysIdenData. Each time you run and stop the Simulink model, a new data file will be generated with an incremented  index. Thus, you would never lose any of your test results, i.e., for first run, the file name is SysIdenData_0.mat,  second  run   SysIdenData_1.mat,  and  so  on.  The  order  for which the recorded data is saved in LogData is the same as the Lab 1 data that was given to  you   under  the   name   SysIdenData_StudentVersion.mat.  Therefore,  you   can extract the time vector, noise-reduced output, and input data as you did in Lab 1.

Fig. 4. Display of Scope block after running the Simulink model with suitable system settings. You can see the Curser Measurements as well.

5. Identifying  the  linear second-order model (0.5 marks, checked after 2   hour  30 minutes)

Important: Use  your  own  MATLAB code to do system identification and model verification using the newly collected data the same way as you did in lab 1. Note that you will need to do some modifications on your code from lab 1 according to the following steps.

a.   Before you use the raw data in your code from Lab 1, you have to either cut off the initial transient  part  of  the  data  or  the  first  sequence  plus  the  transient  part  in  the  second sequence in order to get a good estimate of the output offset. The transient part is shown in Fig.5(a) with the blue double-sided arrow, the output offset levels are shown in green for three  sequences  (i.e.,  the  response  to  input  voltage  2.5V  in Fig.  5(a)),  and  the  first sequence is shown in Fig.5(b).

If you observe that the output offset level in the first sequence is close to the next two output offsets, you can just cut off the transient part. Sometime, you may observe that the output offset is slightly different in the first sequence after the initial transient part compared to the next two output offsets.  In this case,  it is  better to cut off the first sequence all together in addition to the transient part from the second sequence. An example of cutting off the first sequence is shown in Fig. 6.

Remark

Step (a) is important because sometimes the initial period may not be long enough for the output to reach its offset. That would lead to underestimating the output offset. Also, during the operation, output offset can be different between sequences of the input offset, i.e., applying  the  same  input  at  different  times  and  getting  slightly  different  output  values. Moreover, during the initial sequence (Fig. 5(b)), some unexpected events can happen which make the data to be unreliable for system identification. Therefore, you must analyze data carefully, throw out the unusable part, and only keep the most reliable part of the data for system identification.

Fig. 5. Raw collected data in three repetitions, (a) Output data, (b) Input data.

Fig. 6. Cut-off data, (a) output signal, (b) input signal.

b.  After analyzing your collected data and cutting off the unusable part, use the cut-off data in your code from Lab 1 to identify a second-order discrete-time model for your W-T system.

c.   You must show the lab demonstrator in charge all the figures you were previously asked to plot in Lab 1 using your own collected data to get the mark for this lab.




热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图