MOSIS Chip Test With NI-6351 Controlled by MATLAB

This post is intended to show the tests of a MOSIS fabricated chip made by the same steps described here. As well as how to perform those tests with the NI-6351 device under MATLAB software.

The MATLAB interfacing became very intuitive compared to the standard NI software. Once the NI-6351 is plugged in your computer, the command “daq.getDevices” returns the data acquisition devices connected:


ans = 

Data acquisition devices:

index Vendor Device ID                 Description                 
----- ------ --------- --------------------------------------------
1     ni     Dev1      National Instruments PCIe-6351
2     ni     Dev2      National Instruments PCIe-6351
3     ni     SimDev1   National Instruments NI Simulated DAQ Device

The device “Dev1” corresponds to the targeted one. After identifying the device, it is possible to observe the I/O specifications:

>>devices = daq.getDevices;

ans = 

ni: National Instruments PCIe-6351 (Device ID: 'Dev1')
 Analog input subsystem supports:
      7 ranges supported
      Rates from 0.1 to 1250000.0 scans/sec
      16 channels ('ai0' - 'ai15')
      'Voltage' measurement type
   Analog output subsystem supports:
      -5.0 to +5.0 Volts,-10 to +10 Volts ranges
      Rates from 0.1 to 2857142.9 scans/sec
      2 channels ('ao0','ao1')
      'Voltage' measurement type
   Digital subsystem supports:
      Rates from 0.1 to 10000000.0 scans/sec
      24 channels ('port0/line0' - 'port2/line7')
      'InputOnly','OutputOnly','Bidirectional' measurement types
   Counter input subsystem supports:
      Rates from 0.1 to 100000000.0 scans/sec
      4 channels ('ctr0','ctr1','ctr2','ctr3')
      'EdgeCount','PulseWidth','Frequency','Position' measurement types
   Counter output subsystem supports:
      Rates from 0.1 to 100000000.0 scans/sec
      4 channels ('ctr0','ctr1','ctr2','ctr3')
      'PulseGeneration' measurement type

The MATLAB shows the device I/O characteristics. For example, 16 analog inputs, which can achieve a speed of 1.25 MHz. The NI SCB-68A shield is coupled with the NI-6351 device to facilitate the work. Its details can be found here. The setup with the shield and chip are shown bellow.


For the batch mode data acquisition, an object needs to be created as:

analyser = daq.createSession('ni');

Then, the I/O is attached to the object by:

addAnalogInputChannel(analyser,'Dev1', 'ai0', 'Voltage');
addDigitalChannel(analyser,'Dev1', 'Port0/Line0:3', 'InputOnly');
addDigitalChannel(analyser,'Dev1', 'Port0/Line4', 'OutputOnly');

In the above example, one analog port, four digital input ports and one digital output port were attached to the object. The insertion of at least one analog port is required in the batch mode (even if it is not used), in order to give a clock reference to the digital I/O. In consequence, the fastest data acquisition is 1.25 MHz in this mode (as specified in the device datasheet). Only the “Port0” class of ports can be used in the batch mode, the other digital ports are directly controlled by code lines. In case of need, one could adapt the analog ports to extend the available ports for the batch mode.

An Configurable Logic Block (CLB) chip was fabricated, and a 4-bit counter was configured in it, with an artificial clock as:

x = zeros(300,1);
x(1:4:300,1) = 1;
x(2:4:300,1) = 1;

Furthermore, the binary object was inserted in the controller object:


Multiple outputs can be programmed in the batch mode, the controller object considers each column separately for each output for a given input matrix, where each line is a definition of the ports state at the same time interval. In the example above, only one column is inserted, since there is only one output port needed.

Next, the data acquisition rate is configured as:

analyser.Rate = 1e6;

In the batch mode, the execution time is defined by the output length times the acquisition rate. For this example, the vector has a size of 300 with an acquisition rate of 1 MHz, leading to 0.3 ms of execution time.

The system is executed by:

[captured_data,time] = analyser.startForeground();

At the end, the data and time relative to the execution are returned. They can be plotted as:

ylim([-0.5 1.5]);
title('Clock de entrada');

ylim([-0.5 1.5]);
title('Saída 0');

ylim([-0.5 1.5])
title('Saída 1');
ylabel('Nivel lógico');

ylim([-0.5 1.5]);
title('Saída 2');

ylim([-0.5 1.5]);
title('Saída 3');
xlabel('Tempo (s)');


There are another two ways of working with the device I/O. The first one is about controlling the ports by the own MATLAB code execution. In this sense, the data acquisition is not well defined. The reading and writing can be performed with the following lines of code:

data = analyser.inputSingleScan()

The last way consists of real time acquisition, where the setup is very similar to the batch mode. To migrate from batch to real time, simply change the line of code “[captured_data,time] = analyser.startForeground();” to:

reader = analyser.addlistener('DataAvailable', @(src,event) plot(event.TimeStamps, event.Data));

The “Background” execution becomes an independent MATLAB thread and its execution time can be indefinite:

analyser.IsContinuous = true;

More functionalities can be coupled to the background mode by adding a listener.

1 thought on “MOSIS Chip Test With NI-6351 Controlled by MATLAB

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s