Difference between revisions of "EGR 103/DAQ 1"

From PrattWiki
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page contains pictures and graphs related to Data Acquisition Laboratory 1 (DAQ 1) of [[EGR 103]]. It has been updated for Spring, 2016.
+
 
 +
== '''Note:''' For Fall 2019 and after, you will want the [[Python:DAQ_1]] page. ==
 +
<!--
 +
== Introduction ==
 +
This page contains pictures and graphs related to Data Acquisition Laboratory 1 (DAQ 1) of [[EGR 103]]. It has been updated for Spring, 2018.  This page underwent a major revision in Fall of 2017 based on the DAQmx drivers and MATLAB's elimination of legacy toolbox codes.
  
 
== Supporting Pundit Pages ==
 
== Supporting Pundit Pages ==
Line 7: Line 11:
  
 
== Typographical Errors / Clarifications ==
 
== Typographical Errors / Clarifications ==
* If your MATLAB needs an activation license, first make sure you are at a computer that has a DAQ card; if so, contact Dr. G.
 
 
* If the computer says your device is not found, try 'Dev2' instead of 'Dev1' in the  
 
* If the computer says your device is not found, try 'Dev2' instead of 'Dev1' in the  
  DIO = digitalio('nidaq', 'Dev1')
+
  addDigitalChannel(s,'Dev1','Port0/Line0:2','OutputOnly')
 
: line.
 
: line.
 +
* Before running the program, the person at the DAQ machine will need to install the pydaqmx module:
 +
** Go to the Start button, find the Anaconda3 folder, and click the Anaconda prompt
 +
** In the Anaconda terminal that just opened, type
 +
pip install pydaqmx
 +
** One it is done installing (or confirms that it is installed), close the Anaconda terminal
  
 
== Equipment Used ==
 
== Equipment Used ==
Line 63: Line 71:
  
 
== Code ==
 
== Code ==
The following code listing is for <code>BasicDOutput.m</code>
+
The following code listing is for <code>ThreeBits.m</code>
 
<source lang="matlab">
 
<source lang="matlab">
% Prepare workspace
+
% Clear out workspace
clear; format short e
+
clear
 
 
% Clear out DAQ object
 
delete(daqfind)
 
  
% Create Digital I/O Object
+
% Create a session
DIO = digitalio('nidaq', 'Dev1')
+
s = daq.createSession('ni')
  
% Add output lines to Digital I/O Object
+
% Add output lines to session
DOutputs = addline(DIO, 0:2, 'out')
+
addDigitalChannel(s,'Dev1','Port0/Line0:2','OutputOnly')
  
 
% Writing values to output lines using binary
 
% Writing values to output lines using binary
putvalue(DOutputs, [1 1 1]);
+
outputSingleScan(s, [1 1 1]);
 
fprintf('Press return to continue\n');
 
fprintf('Press return to continue\n');
 
pause
 
pause
putvalue(DOutputs, [0 0 0]);
+
outputSingleScan(s, [0 0 0]);
  
 
% Writing values to output lines using base 10
 
% Writing values to output lines using base 10
 
MyVal = 0
 
MyVal = 0
 
while 0<=MyVal & MyVal<=7
 
while 0<=MyVal & MyVal<=7
     putvalue(DOutputs, MyVal)
+
     MyBinVal = decimalToBinaryVector(MyVal, 3, 'LSBFirst');
     fprintf('Displaying %0.0f as %c %c %c\n', ...
+
    outputSingleScan(s, MyBinVal);
         MyVal, dec2bin(MyVal, 3))
+
     fprintf('Displaying %d as %d %d %d\n', ...  
     MyVal = floor(input('Enter a number between 0 and 7: '));
+
         MyVal, MyBinVal(end:-1:1))                  
 +
     MyVal = floor(input('Enter a number between 0 and 7: '));  
 
end
 
end
  
 
% Turn all outputs off
 
% Turn all outputs off
putvalue(DOutputs, [0 0 0])
+
outputSingleScan(s, [0 0 0]);
 
</source>
 
</source>
  
Line 99: Line 105:
 
* Landing Lights Animation:
 
* Landing Lights Animation:
 
[[File:LLGifSmall.gif]]
 
[[File:LLGifSmall.gif]]
<!--
 
* Animation of Landing Lights (slower than usual: [http://pundit.pratt.duke.edu/piki/images/9/90/LandingLightsSlow.flv Link], regular speed: [http://pundit.pratt.duke.edu/piki/images/1/1c/LandingLightsReg.flv Link])
 
-->
 
  
 
== Questions ==
 
== Questions ==
Line 114: Line 117:
  
 
[[Category:EGR 103]]
 
[[Category:EGR 103]]
 +
-->

Latest revision as of 17:13, 7 October 2019

Note: For Fall 2019 and after, you will want the Python:DAQ_1 page.