Difference between revisions of "Controls/Lab/Instrumentation"

From PrattWiki
Jump to navigation Jump to search
m
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!-- Spring This page contains information related to Laboratory 3 for [[ECE 382]] and [[ME 125]]. It has been updated for Fall, 2011. -->
+
This page contains information related to the Instrumentation Basics and Simulink Lab for [[Controls]]. It has been updated for Fall of 2016.  
This page contains information related to the Instrumentation Basics and Simulink Lab for [[Controls]]. It has been updated for Spring, 2012.  
 
  
 
== Typographical Errors / Clarifications ==
 
== Typographical Errors / Clarifications ==
* Due to timing issues, you will only actually be able to get through Assignment 2 in the first lab period (Feb 1-2).  Once you are finished with Assignment 2, be sure to transfer the files you need to your OIT account.  You will complete things during Feb 8-9.
+
* No typos yet.
  
* For the initialization of MATLAB, when the first window comes up about platforms, click the "Do Not Ask Again" option and then click the RTI1104 button.  If a window comes up about incompatible settings, select the do not ask again option, then Set Automatically.  This '''should''' take care of the settings in the Simulink configuration for working with the dSPACE cards -- but you should still check the configuration as given on page Lab 3-11.
+
* For the initialization of MATLAB, when the first window comes up about platforms, click the "Do Not Ask Again" option and then click the RTI1104 button.  If a window comes up about incompatible settings, select the do not ask again option, then Set Automatically.  This '''should''' take care of the settings in the Simulink configuration for working with the dSPACE cards -- but you should still check the configuration as given on page Lab 4-11.
  
 
* In ControlDesk, the assumption is that the icon bars look similar to the one here:<br>[[File:ControlDeskIcons.png]]<br>If not, you likely have several tools open that do not need to be.  In the ControlDesk '''View''' menu, select '''Toolbars''' - the image above was obtained with the following toolbars on:<br>  
 
* In ControlDesk, the assumption is that the icon bars look similar to the one here:<br>[[File:ControlDeskIcons.png]]<br>If not, you likely have several tools open that do not need to be.  In the ControlDesk '''View''' menu, select '''Toolbars''' - the image above was obtained with the following toolbars on:<br>  
Line 15: Line 14:
 
** Bus Manager
 
** Bus Manager
 
:and all the other toolbars off.  The toolbar with the edit/test/animation buttons is the Instrumentation toolbar.
 
:and all the other toolbars off.  The toolbar with the edit/test/animation buttons is the Instrumentation toolbar.
 
* To complete Assignment 3 during 2/8-2/9, you will want to log in to a PC, create an InstrumentationLab folder on the desktop of the PC you are on, and have one of the partners use the SSH File Transfer program to bring all the files from last week back onto the PC.  Be sure to start MATLAB and ControlDesk and note that the model for Assignment 3 (a) looks like a combination of the models for Assignments 1 and 2 and (b) is pictured below.  Do not forget to go through the Simulink Configuration Settings for your new model, however!
 
  
 
== Resources ==
 
== Resources ==
Line 22: Line 19:
 
** [[DSPACE|dSPACE]] - which includes link to templates for DAC and ADC
 
** [[DSPACE|dSPACE]] - which includes link to templates for DAC and ADC
 
* Files for the lab:
 
* Files for the lab:
** [http://www.duke.edu/~mrg/Controls/Instrumentation/GetInstrumentData.m GetInstrumentData.m]
+
** [http://classes.pratt.duke.edu/FILES/Controls/Instrumentation/GetInstrumentData.m GetInstrumentData.m]
  
  
Line 45: Line 42:
 
rtwbuild(ModelName)
 
rtwbuild(ModelName)
 
</source>
 
</source>
 +
 
==== MakeInstrument1Handles.m ====
 
==== MakeInstrument1Handles.m ====
 
<source lang="matlab">
 
<source lang="matlab">
Line 51: Line 49:
  
 
%% Define global variables for measurement and output channels
 
%% Define global variables for measurement and output channels
global ADC1 ADC5 DAC1 CONST
+
global ADC1 ADC5 DAC5 CONST
 
global Ts SR
 
global Ts SR
  
Line 57: Line 55:
 
ADC1  = mlib('GetTrcVar', 'Model Root/ADC1/In1');
 
ADC1  = mlib('GetTrcVar', 'Model Root/ADC1/In1');
 
ADC5  = mlib('GetTrcVar', 'Model Root/ADC5/In1');
 
ADC5  = mlib('GetTrcVar', 'Model Root/ADC5/In1');
DAC1   = mlib('GetTrcVar', 'Model Root/DAC1/In1');
+
DAC5   = mlib('GetTrcVar', 'Model Root/DAC5/In1');
CONST  = mlib('GetTrcVar', 'Model Root/C1/Value');
+
CONST  = mlib('GetTrcVar', 'Model Root/C5/Value');
 
</source>
 
</source>
  
Line 87: Line 85:
  
 
=== Assignment 3: Voltage Control ===
 
=== Assignment 3: Voltage Control ===
 +
'''NOTE''' For Fall 2016, we are using DACH5 instead of DACH1, so anything attached to the DAC channel that has a C1 should be C5.  New picture when I get a chance!
 
<gallery>
 
<gallery>
 
File:VoltageControl.png|Simulink Model for Voltage Control
 
File:VoltageControl.png|Simulink Model for Voltage Control
Line 96: Line 95:
  
 
== External Links ==
 
== External Links ==
* [http://www.amtencoder.com/Portals/AMT/Documents/Resources/Technical%20Documents/dip%20switch%20settings_new.pdf AMT 102 & 103 DIP Switch Resolution Settings] from CUI.com via amtencoder.com.
+
* [http://www.cui.com/product/resource/amt10-v.pdf AMT Information] from CUI.com via amtencoder.com; the dip-switch settings are on Page 4.
  
 
== References ==
 
== References ==
Line 103: Line 102:
  
 
[[Category: ECE 382]]
 
[[Category: ECE 382]]
[[Category: ME 125]]
+
[[Category: ME 344]]

Latest revision as of 18:40, 21 September 2016

This page contains information related to the Instrumentation Basics and Simulink Lab for Controls. It has been updated for Fall of 2016.

Typographical Errors / Clarifications

  • No typos yet.
  • For the initialization of MATLAB, when the first window comes up about platforms, click the "Do Not Ask Again" option and then click the RTI1104 button. If a window comes up about incompatible settings, select the do not ask again option, then Set Automatically. This should take care of the settings in the Simulink configuration for working with the dSPACE cards -- but you should still check the configuration as given on page Lab 4-11.
  • In ControlDesk, the assumption is that the icon bars look similar to the one here:
    ControlDeskIcons.png
    If not, you likely have several tools open that do not need to be. In the ControlDesk View menu, select Toolbars - the image above was obtained with the following toolbars on:
    • Controldesk
    • Interpreter
    • Experiment Manager
    • Instrumentation
    • Platform Manager
    • Bus Manager
and all the other toolbars off. The toolbar with the edit/test/animation buttons is the Instrumentation toolbar.

Resources


Codes, Models, and Layout Images

Since you should never copy and paste text from a PDF (the quotes change and extra spaces are added), some of the code for the assignment parts will be included below. Also, there are pictures of the models and layouts that you will be building.

Assignment 1: RC Circuit Analysis

InitInstruments1.m

%% Initialize workspace
clear; format short e;

%% Sets global parameters
global Ts SR

% Defines sampling rate and - more importantly - sample time
SR = 1000;
Ts = 1/SR;

%% Opens and builds Simulink Model on dSPACE
ModelName = 'Instruments1'
open_system(ModelName)
rtwbuild(ModelName)

MakeInstrument1Handles.m

%% Select the board
mlib('SelectBoard', 'ds1104');

%% Define global variables for measurement and output channels
global ADC1 ADC5 DAC5 CONST
global Ts SR

%% Create handles to relevant blocks
ADC1   = mlib('GetTrcVar', 'Model Root/ADC1/In1');
ADC5   = mlib('GetTrcVar', 'Model Root/ADC5/In1');
DAC5   = mlib('GetTrcVar', 'Model Root/DAC5/In1');
CONST  = mlib('GetTrcVar', 'Model Root/C5/Value');

Assignment 2: Angular Measurements

InitAngMeasurement.m

%% Initialize workspace
clear; format short e;

%% Sets global parameters
global Ts SR

% Defines sampling rate and - more importantly - sample time
SR = 10;
Ts = 1/SR;

%% Opens and builds Simulink Model on dSPACE
ModelName = 'AngMeasurement'
open_system(ModelName)
rtwbuild(ModelName)

The following are links to larger images of the Simulink model and ControlDesk layout for Assignment 2 of this lab:


Assignment 3: Voltage Control

NOTE For Fall 2016, we are using DACH5 instead of DACH1, so anything attached to the DAC channel that has a C1 should be C5. New picture when I get a chance!

Questions

Post your questions by editing the discussion page of this article. Edit the page, then scroll to the bottom and add a question by putting in the characters *{{Q}}, followed by your question and finally your signature (with four tildes, i.e. ~~~~). Using the {{Q}} will automatically put the page in the category of pages with questions - other editors hoping to help out can then go to that category page to see where the questions are. See the page for Template:Q for details and examples.

External Links

  • AMT Information from CUI.com via amtencoder.com; the dip-switch settings are on Page 4.

References