%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX % Date: July-02-2011 % Version: 1.0 %XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX %General Notes: % 1) The Ossila USB test board is powered by a National Instruments USB 6501 OEM. % 2) The NI DAQmx driver must be installed for this program to run. To download this driver visit www.ni.com. % 3) The Matlab Data Acquisition Toolbox is required to run this code % 4) For safety purposes the outputs of the USB 6501 have been inverted. % I.e When pixel 1 is set to 0 it is on % When pixel 1 is set to 0 it is on % This is because when first plugged in all lines are set to high which % could otherwise result in unwanted voltages or currents being applied to % the photodiode, temperature sensor, device under test or all three. %XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX %Firstly clear the matlab environment so we have a known state. close all clear all clear global clc %XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX %If you need to find out about the hardare identification for the nidaq ID %use the command below %daqhwinfo('nidaq') %XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX %create a digitalio object for the USB6501. Note that usually this will be %'Dev1', however if you are unsure then use the daqhwinfo command above to %find out USB6501 = digitalio('nidaq','Dev1'); %The USB6501 controller has three ports each with 8 lines (0 to 7). %We need to add the lines to each port before we can use them %addline(digitalio_object, lines_to_add, port, direction i.e 'out', names); %we also enumerate the port names here to make easier identification %(optional). The names are PXLY where X is the port number and Y is the %line number we can then refere to each line by it's label. addline(USB6501, 0:7, 0, 'out', {'P0L0','P0L1','P0L2','P0L3','P0L4','P0L5','P0L6','P0L7'}); % add 8 lines to port 0 with labels addline(USB6501, 0:7, 1, 'out', {'P1L0','P1L1','P1L2','P1L3','P1L4','P1L5','P1L6','P1L7'}); % add 8 lines to port 1 with labels addline(USB6501, 0:7, 2, 'out', {'P2L0','P2L1','P2L2','P2L3','P2L4','P2L5','P2L6','P2L7'}); % add 8 lines to port 2 with labels %XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX % display index and digital line configurations to show mapping for debug % purposes lineconfig=USB6501.Line %XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX %The USB6501 contoller on the USB test board is now set up and ready to %use with 24 adressable lines. A list of lines is shown below for %reference. %Port Line Enumeration Use %---- ---- ----------- --------------------------------------- %0 0 P0L0 Photodiode %0 1 P0L1 Pixel 1 %0 2 P0L2 Pixel 2 %0 3 P0L3 Pixel 3 %0 4 P0L4 Pixel 4 %0 5 P0L5 Pixel 5 %0 6 P0L6 Pixel 6 %0 7 P0L7 Temperature Sensor %1 0 P1L0 Shutter %1 1 P1L1 Unused, accessable from port 1 header %1 2 P1L2 Unused, accessable from port 1 header %1 3 P1L3 Unused, accessable from port 1 header %1 4 P1L4 Unused, accessable from port 1 header %1 5 P1L5 Unused, accessable from port 1 header %1 6 P1L6 Unused, accessable from port 1 header %1 7 P1L7 Unused, accessable from port 1 header %2 0 P2L0 Unused, accessable from port 1 header %2 1 P2L1 Unused, accessable from port 1 header %2 2 P2L2 Unused, accessable from port 1 header %2 3 P2L3 Unused, accessable from port 1 header %2 4 P2L4 Unused, accessable from port 1 header %2 5 P2L5 Unused, accessable from port 1 header %2 6 P2L6 Unused, accessable from port 1 header %2 7 P2L7 Unused, accessable from port 1 header %We can address these lines in several ways % 1) By using the enumerated line names (eg P0L0) % eg. putvalue(USB6501.P0L0,0) to turn port 0 off and therfore the % line on. % 2) By placing an array of logical values on selected outputs. % eg. putvalue(USB6501.Line(1:8), logical([1 0 0 0 0 0 0 1 ]); % 3) By placing an array of 24 logical values on the whole device % eg outputs_off = logical([1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]); % putvalue(USB6501, outputs_off); %XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX %Example code by using an array of 24 logical pixels %Setup variable for high and low outputs for all 24 I/Os. We can do this %in one big variable rather than for the three ports individually. %Remember that the multiplexer switches are active LOW. This means that a %logic 0 turns a switch ON and a logic 1 turns it OFF. %Also, it is important to remember that the photodiode and pixels should never turned on %at the same time. %Firstly, set up variables that we can put onto the device: %port 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 %line 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 outputs_off = logical([1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]); pixels_on = logical([1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]); pixels_off = logical([1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]); photodiode_on= logical([0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]); photodiode_off= logical([1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]); tempsensor_on = logical([1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]); tempsensor_off = logical([1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]); %Now turn all the pixels on and pause 0.1 putvalue(USB6501,outputs_on); pause(0.1); %Now turn all the pixels off off again putvalue(USB6501,outputs_off); %XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX % Example code to flash on and off pixels 1 to six using enumeration putvalue(USB6501.P0L1,0); pause(0.1); putvalue(USB6501.P0L1,1); putvalue(USB6501.P0L2,0); pause(0.1); putvalue(USB6501.P0L2,1); putvalue(USB6501.P0L3,0); pause(0.1); putvalue(USB6501.P0L3,1); putvalue(USB6501.P0L4,0); pause(0.1); putvalue(USB6501.P0L4,1); putvalue(USB6501.P0L5,0); pause(0.1); putvalue(USB6501.P0L5,1); putvalue(USB6501.P0L6,0); pause(0.1); putvalue(USB6501.P0L6,1); %XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX %Finally, before finishing a program we need to close down the interface %(similar to closing a file). delete(USB6501); clear USB6501;