Difference between revisions of "EGR 103/DAQ 1"

From PrattWiki
Jump to navigation Jump to search
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, 2017.
+
This page contains pictures and graphs related to Data Acquisition Laboratory 1 (DAQ 1) of [[EGR 103]]. It has been updated for Fall, 2017.  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 9: Line 9:
 
* 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 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.
  
Line 63: Line 63:
  
 
== 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
+
% Create a session
delete(daqfind)
+
s = daq.createSession('ni')
  
% Create Digital I/O Object
+
% Add output lines to session
DIO = digitalio('nidaq', 'Dev1')
+
addDigitalChannel(s,'Dev1','Port0/Line0:2','OutputOnly')
 
 
% Add output lines to Digital I/O Object
 
DOutputs = addline(DIO, 0:2, 'out')
 
  
 
% 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>
  

Revision as of 18:48, 2 November 2017

This page contains pictures and graphs related to Data Acquisition Laboratory 1 (DAQ 1) of EGR 103. It has been updated for Fall, 2017. 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

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
addDigitalChannel(s,'Dev1','Port0/Line0:2','OutputOnly')
line.

Equipment Used

National Instruments Data Acquisition Cards

NI PCI 6014e
Same card, after overheating

B209 has machines with two different data acquisition cards. Most of the machines have NI PCI 6014e cards, which will be what is discussed here. The others have a newer NI PCI 6221 cards. The NI PCI 6014e card can read up to 16 single-ended (8 differential) analog voltage measurements, has two analog outputs, and has 8 configurable digital input/output lines. The 6221 cards are more powerful but, generally in EGR 103, we will limit ourselves to the features available on the 6014e cards.

Be careful when making connections; improperly connecting wires can lead to catastrophic damage on the DAQ cards, as is shown on the second picture at right.


CB-68LP

NI CB-68LP

During this lab, you will use the CB-68LP to connect wires to parts of the NI PCI 6014e card. Be sure to use the proper connections - a map is available at the MATLAB:CB-68LP Pinout page.


Radio Shack Experimentor 350

Radio Shack Experimentor 350

The Experimentor 350 is a simple, but useful, prototyping board. It has two distribution strips (rows X and Y) with 20 pins each and 46 groups of 5 pins on its terminal strip. All the pins in row X are connected together, and all the pins in row Y are connected together; note, however, that X is not connected to Y.

For the main part of the board, half-columns are connected together. For example, rows (ABCDE) in column 3 are all connected. Note, however, that ABCDE are not connected to FGHIJ.

Also, there are some helpful index numbers at the top and bottom to help determine which column you are in. For rows X and Y, some indices do not exist. For example, there is no pin at X6, X12, X18, Y6, Y12, or Y18.

Resistors

Three resistors

Resistors take energy out of an electric circuit and convert that energy to heat. In this case, the light emitting diodes cannot handle the amount of current that the DAQ card can produce, so resistors are placed in parallel to reduce that current. You can use the Resistor Color Codes to determine the resistance of the resistors pictures at right; there should be four resistors (at least) in your box.

LEDs

Several Light Emitting Diodes
Closeup of two round LEDs
File:LED, 5mm, green (en).svg
Drawing of LED from Wikipedia Light-emitting_diode page

A diode is an electrical element that generally only allows current to flow in one direction - and only after there is a sufficient voltage difference across the appropriate terminals. LEDs - Light Emitting Diodes - are a special form of diode that emit light when current flows through them.

Because diodes and LEDs are directional, there are visible clues about which side is which. In the first picture at right, the lengths of the leads on the diodes are clearly different - the longer lead should be placed where the higher voltage is expected, as current will be allowed to flow into the longer lead, through the diode, and out through the shorter lead. For the round LEDs, a flat is ground into the collar of the LED on the lower-voltage side - this is shown more clearly in the second picture. Finally, within the diode itself, the larger "flag" of metal inside the diode is on the lower voltage side.

Note that the color of the plastic is not what determines the color of the light - rather the specific semiconductor material and the geometry of the LED do that. The plastic is a convenient way of knowing what color the light will be, however.


Circuit Construction

Circuit built on breadboard
Connections to CB-68LP

The pictures at right show both the breadboard and the CB-68LP once everything has been properly connected. Note especially on the CB-68LP where the wires are - there will be no connections in the first two columns and there is only one connection - the black wire for digital ground - in the fifth column.

Code

The following code listing is for ThreeBits.m

% Clear out workspace
clear

% Create a session
s = daq.createSession('ni')

% Add output lines to session
addDigitalChannel(s,'Dev1','Port0/Line0:2','OutputOnly')

% Writing values to output lines using binary
outputSingleScan(s, [1 1 1]);
fprintf('Press return to continue\n');
pause
outputSingleScan(s, [0 0 0]);

% Writing values to output lines using base 10
MyVal = 0
while 0<=MyVal & MyVal<=7
    MyBinVal = decimalToBinaryVector(MyVal, 3, 'LSBFirst');
    outputSingleScan(s, MyBinVal);
    fprintf('Displaying %d as %d %d %d\n', ... 
        MyVal, MyBinVal(end:-1:1))                   
    MyVal = floor(input('Enter a number between 0 and 7: ')); 
end

% Turn all outputs off
outputSingleScan(s, [0 0 0]);

Other Resources

  • Landing Lights Animation:

LLGifSmall.gif

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

References