EMB-DAQ2 - Tutorial
In this tutorial, we present:
Features of the EMB-DAQ2 and pinout
(updated on 2/26/2026)
General Information ​
The EMB-DAQ2 is based on the National Instruments PCIe-6321 multifunction board. For more information regarding the board, visit the following links from NI's website.
1) Link to PCIe-6321 specifications: https://www.ni.com/docs/en-US/bundle/pcie-6321-specs/page/specs.html
​We have wired the peripherals of the PCIe card with our industrial connectors and EMB-DAQ2 features, such as the user LED, PWR LED, E-STOP button, encoders, and USB port. Inside the EMB-DAQ2, an NI CB-68LPR terminal block is used.​​​
​
We designed the EMB-DAQ2 to be flexible and provide comprehensive capabilities. Our standard configuration comes plug-and-play to support two actuators (one on PORT A and one on PORT B), four encoders (one on each encoder port), E-STOP (included with the DAQ), and additional I/O.
MATLAB® and Simulink® are used to interface with the EMB-DAQ2 via Simulink Desktop Real-Time®. Please visit our Tutorial EMB-DAQ2 Software Installation for details on setting up the software before using the EMB-DAQ2.
​​
Important: Do not short-circuit any power connections from the DAQ as it will likely permanently damage the PCIe card and potentially your computer!
​​


PORT A ​
​
This port is used to connect an actuator via the Maxon ESCON or ESCON2 amplifier (other amplifiers can also be used).
​
-
Pin1: Analog Output signal. It is wired to pin 22 of the PCIe-6321 card (AO 0). In Simulink®, you can use the analog output block. The analog output range is from -10V to +10V.
​
-
Pin 2: Analog Output GND. Wired to pin 55 of the PCIe-6321 (AO GND). Note: do not mix AO GND, AI GND, and Digital GND!
​
-
Pin 3: Enable signal to the amplifier. It is the return of the E-STOP and a Digital Output. The digital output is wired to the pin 17 of PCIe-6321 (Digital Output 1, P0.1). In Simulink®, use the Digital Output block to set the enable high. This pin is also wired PORT B pin 2, and it is pulled-down with a 10K Ohm resistor.​
-
​
-
Pin 4: Digital GND. Wired to pin 17 of the PCIe-6321 (D GND). Note: do not mix AO GND, AI GND, and Digital GND!
​
-
Pin 5: Analog Input GND. Wired to pin 67 of the PCIe-6321 (AI GND). Note: do not mix AO GND, AI GND, and Digital GND!
​
-
Pin 6: Analog Input signal #0. It is wired to pin 68 of the PCIe-6321 card (AI 0). In Simulink®, you can use the analog input block. The analog output range is user-selectable in Simulink®.
​
-
Pin 7: Analog Input signal #1. It is wired to pin 33 of the PCIe-6321 card (AI 1). In Simulink®, you can use the analog input block. The analog output range is user-selectable in Simulink®.
​
-
Pin 8: 5V. To be used as reference voltage and power small loads such as sensors. Do not power motors, H-bridges or any load over 100 mA. Draining a higher current can cause permanent damage to the PCIe card, EMB-DAQ2, and/or computer. Wired to pin 8 of the PCIe-6321.

PORT B ​
​
This port is used to connect an actuator via the Maxon ESCON or ESCON2 amplifier (other amplifiers can also be used).
​
-
Pin1: Analog output signal. It is wired to pin 21 of the PCIe-6321 card (AO1). In Simulink®, you can use the analog output block. The analog output range is from -10V to +10V.
​
-
Pin 2: Analog Output GND. Wired to pin 54 of the PCIe-6321 (AO GND). Note: do not mix AO GND, AI GND, and Digital GND!
​
-
Pin 3: Enable signal to the amplifier. It is the return of the E-STOP and a Digital Output. The digital output is wired to the pin 17 of PCIe-6321 (Digital Output 1, P0.1). In Simulink®, use the Digital Output block to set the enable high. This pin is also wired PORT B pin 2, and it is pulled-down with a 10K Ohm resistor.
​
-
Pin 4: Digital GND. Wired to pin 17 of the PCIe-6321 (D GND). Note: do not mix AO GND, AI GND, and Digital GND!
​
-
Pin 5: Analog Input GND. Wired to pin 64 of the PCIe-6321 (AI GND). Note: do not mix AO GND, AI GND, and Digital GND!
​
-
Pin 6: Analog Input signal #2. It is wired to pin 65 of the PCIe-6321 card (AI 2). In Simulink®, you can use the analog input block. The analog output range is user-selectable in Simulink®.
​
-
Pin 7: Analog Input signal #3. It is wired to pin 30 of the PCIe-6321 card (AI 3). In Simulink®, you can use the analog input block. The analog output range is user-selectable in Simulink®.
​
-
Pin 8: 5V. To be used as reference voltage and power small loads such as sensors. Do not power motors, H-bridges or any load over 100 mA. Draining a higher current can cause permanent damage to the PCIe card, EMB-DAQ2, and/or computer. Wired to pin 8 of the PCIe-6321.

PORT C ​
​
This port is used for extra connections.
​
-
Pin1: 5V for the End of Travel Switch(s), abbreviated as EoTS in our documentation. Refrain from using this pin to drive any other load. Draining a higher current can cause permanent damage to the PCIe card, EMB-DAQ2, and/or computer. Wired to pin 14 of the PCIe-6321.
​
-
Pin 2: Return of EoTS. It is wired to pin 51 of the PCIe-6321 (Digital Input, P0.5). This pin is pulled-down with a 10K Ohm resistor. To read the digital input in Simulink®, use the Digital Input block. The EoTS implementation is done by the user, via software (there's no hardwire connection to the motor amplifier). The use of EoTS is optional, but recommended for additional safety. The switches are connected in series, unplugging or pressing the switch will cause a low state to this pin.
​
-
Pin 3: Digital GND. Wired to pin 15 of the PCIe-6321 (D GND). Note: do not mix AO GND, AI GND, and Digital GND!
​
-
Pin 4: Digital Output signal #3. It is wired to pin 49 of the PCIe-6321 card (P0.2). In Simulink®, you can use the digital output block. This can be configured as a digital input if preferred (software configurable).
For reference, Digital Output 1 and 2 are the LED (front of the EMB-DAQ2) and the enable signal for the motor amplifier(s).
​
-
Pin 5: Digital Output signal #4. It is wired to pin 47 of the PCIe-6321 card (P0.3). In Simulink®, you can use the digital output block. This can be configured as a digital input if preferred (software configurable).
For reference, Digital Output 1 and 2 are the LED (front of the EMB-DAQ2) and the enable signal for the motor amplifier(s).
​
-
Pin 6: Digital Input signal #3. It is wired to pin 16 of the PCIe-6321 card (P0.6). In Simulink®, you can use the digital input block. This can be configured as a digital output if preferred (software configurable).
For reference, Digital Input 1 and 2 are the ESTOP and the EoTS.
​
-
Pin 7: Digital Input signal #4. It is wired to pin 48 of the PCIe-6321 card (P0.7). In Simulink®, you can use the digital input block. This can be configured as a digital output if preferred (software configurable).
For reference, Digital Input 1 and 2 are the ESTOP and the EoTS.
​
-
Pin 8: 5V. To be used as reference voltage and power small loads such as sensors. Do not power motors, H-bridges or any load over 100 mA. Draining a higher current can cause permanent damage to the PCIe card, EMB-DAQ2, and/or computer. Wired to pin 14 of the PCIe-6321.

Encoders ​
​
There are 4 encoder ports on the front of the EMB-DAQ2 that can be used to read rotary and/or linear encoders (EMB-SM1 and/or EMB-LM1). These encoders are wired to the PCIe-6321 card as follows:
​
- Encoder 1 to CTR0: A to PFI8 (CTR Source), B to PFI10 (CTR Aux), Index to PFI9 (CTR Gate)
​
- Encoder 2 to CTR1: A to PFI3 (CTR Source), B to PFI11 (CTR Aux), Index to PFI4 (CTR Gate)
​
- Encoder 3 to CTR2: A to PFI0 (CTR Source), B to PFI2 (CTR Aux), Index to PFI1 (CTR Gate)
​
- Encoder 4 to CTR3: A to PFI5 (CTR Source), B to PFI7 (CTR Aux), Index to PFI6 (CTR Gate)
​​
These are 32-bit resolution counters.
​
To read the encoders in Simulink®, use the Encoder Input block. For resolution, our rotary encoder has 2048 CPR (cycles per revolution) and our linear encoder 2000 LPI (lines per inch).​
​​

E-STOP ​
​
The EMB-DAQ2 comes standard with an E-STOP. It has a dual circuitry.
One circuit (normally connected) wired to 5V and the return Digital Input signal #1 (wired to pin 19 of the PCIe-6321 card (P0.4)).
​
The other circuit (normally connected) is wired to Digital Output signal #2 (pin 17 of the PCIe-6321 card (P0.1) and the return enable pins of PORT A (pin 3) and PORT B (pin 3). It is pulled-down with a 10K Ohm resistor.
​​
With this configuration, we offer multiple levels of safety. If the E-STOP is pressed, both circuits are opened, the enable signals are low (pulled down by the 10K Ohm resistor) disabling the amplifier(s).
The user can also read the status of the E-STOP in Simulink® (digital input), and also disable the amplifier (digital output).
​
Note: without the E-STOP connected, the ESCON/ESCON2 won't be enabled.
​
DAQ PCIe Card ​
This connector interfaces with the PCIe card, but the National Instruments thick cable. Be careful with the connectors as they are fragile and can get damaged if too much torque or force are applied (loading).​
Aux ​
The Aux port is a mechanism to allow the user to pass cables in/out of the enclosure. To make use of this feature, open the enclosure (unscrew side 4 M4 screws, remove top cover), and open the clamp by unscrewing the 2 M4 fasteners, holding the locknuts (wrench not provided). Once the clamp is open, pass the cable, make the necessary electical connections and clamp it. ​
We can provide additional instructions if needed.
LED ​
​
The LED on the front of the EMB-DAQ2 is wired to Digital Output signal #1, pin 52 of the PCIe-6321 card (P0.0).​​
​​
General Simulink® Model (all peripherals in one model)
(updated on 2/26/2026)
General Information ​
​
This model contains most of the functionality of the EMB-DAQ2 in one Simulink® model that runs in real-time, so it serves as a solid starting point. You can "Save As" and adapt to fit your application.
​
You can download the model by clicking here: EMB_DAQ2_NI_GENERAL.ZIP (57KB)​ or from our GitHub. Make sure to always use the latest version and to fully validate that your EMB-DAQ2 and plant are working as expected, especially the safety features.​
​

​​To run the model:
-
In the MATLAB® Command Window, enter the sampling time (T=0.001, for example) and simulation Stop Time (S=10, for example). These variables can be incorporated into a MATLAB® Script (.m file) that runs before the Simulink® model. We recommend using sampling time between 0.001s to 0.010s, depending on your model. Be careful with signal noise due to spatial quantization and excessive phase lag. We find a sampling time of about 0.004s is a good balance for our electro-mechanical plants.
​
​
​
​
​
​
​
​
​
-
In Simulink®, open EMB_DAQ2_NI_GENERAL model, enter the DESKTOP REAL-TIME tab, and click Run in Real-Time. If you run the model from the SIMULATION tab (green Run button), it won't work properly.​​
​
​
​
​
​
​
-
After clicking in Run in Real-Time, many processes take place, including building, code generation, and deployment of code to the target. These processes take between 5s and 20s.
​​​​
-
To stop the model from running, you can click Stop in Simulink®.


Digital Outputs ​
​
Double clicking on the Digital Output block (from the Simulink Desktop Real-Time library), you can configure the output channels. As our standard configuration, we use the first 4 channels of P0 (P0.0, P0.1, P0.2, P0.3) as outputs and the following 4 (P0.4, P0.5, P0.6, P0.7) as inputs. Note that in MATLAB/Simulink, there's no "0 index", where NI's documentation/implementation does, resulting in potential confusion.
​
If you need digital outputs for your experiment, you can use PORT C pins 4 and 5 (P0.2 and P0.3, in MATLAB/Simulink they are channels 3 and 4).
​
Before using Digital Inputs and Outputs, click on "Board setup" in the Data acquisition board (images bellow) and configure the Digital /O output pins accordingly (check 0, 1, 2, 3 and leave 4, 5, 6, 7 blank).
​
More information and specs regarding the implementation of the Digital Output block can be found in the help button of the block parameters pop-up window. For technical details regarding the electrical characteristics, refer to the NI PCIe-6321 manual (or contact us).​
​


Digital Inputs ​
​
Double clicking on the Digital Input block (from the Simulink Desktop Real-Time library), you can configure the input channels. As our standard configuration, we use the last 4 channels of P0 (P0.4, P0.5, P0.6, P0.7) as inputs. Note that in MATLAB/Simulink, there's no "0 index", where NI's documentation/implementation does, resulting in potential confusion.
​
If you need digital inputs for your experiment, you can use PORT C pins 6 and 7 (P0.6 and P0.7, in MATLAB/Simulink they are channels 7 and 8).
​
Before using Digital Inputs and Outputs, click on "Board setup" in the Data acquisition board (images below) and configure the Digital /O output pins accordingly (check 0, 1, 2, 3 and leave 4, 5, 6, 7 blank).
​​​​The E-STOP and EoTS are connected to P0.4 and P0.5. In MATLAB/Simulink they are channels 5 and 6.
​
More information and specs regarding the implementation of the Digital Input block can be found in the help button of the block parameters pop-up window. For technical details regarding the electrical characteristics, refer to the NI PCIe-6321 manual (or contact us).
​


Analog Inputs ​
​
Double clicking on the Analog Input block (from the Simulink Desktop Real-Time library), you can configure the input channels and range. This DAQ has 16 analog input channels with 16-bit resolution.
​
Ensure the A/D connection is set to single ended in the board setup (image below).
​
The EMB-DAQ2 has the first 2 analog inputs (AI0 and AI1) wired to PORT A and the following 2 analog inputs (AI2 and AI3) to PORT B. These are typically used to read signals from the ESCON/ESCON2 controllers.
Our standard ESCON/ESCON2 configuration is set to have voltage output for "current averaged" and "velocity averaged". These signals are connected to PORT A pins 6 and 7 (AI0 and AI1). The user can change these configurations if preferred.
The analog output voltage range of the ESCON/ESCON2 is -4.0V to +4.0V. In Simulink the user can set the voltage input range to -5V and +5V to better fit this measurement.
​​
More information and specs regarding the implementation of the Analog Input block can be found in the help button of the block parameters pop-up window. For technical details regarding the electrical characteristics, refer to the NI PCIe-6321 manual (or contact us).
​


Analog Outputs ​
​
Double clicking on the Analog Output block (from the Simulink Desktop Real-Time library), you can configure the output channels. This DAQ has 2 analog output channels with 16-bit resolution. Voltage range is fixed at -10V to +10V.
​​​
The EMB-DAQ2 has the first analog output (AO0) wired to PORT A and the following analog output (AO1) to PORT B. These are typically used to control the ESCON/ESCON2 controllers.
Our standard ESCON/ESCON2 configuration is set to have voltage input as setpoint for current (+ and - values, full range of -10V to +10V), with a scaling of -10V yields -5A and +10V yields +5A (motor current). The user can change these configurations if preferred. ​​
​
More information and specs regarding the implementation of the Analog output block can be found in the help button of the block parameters pop-up window. For technical details regarding the electrical characteristics, refer to the NI PCIe-6321 manual (or contact us).
​

Encoders (Linear and/or Rotary) ​
​
Four encoders can be read by the EMB-DAQ2 using the Encoder Input block from the Simulink Desktop Real-Time library.
​
Before using the encoder block, click on "Board setup" in the Data acquisition board (images bellow) and configure the counter mode to quadrature encoder, for all counters.
​​
More information and specs regarding the implementation of the encoder block can be found in the help button of the block parameters pop-up window. For technical details regarding the electrical characteristics, refer to the NI PCIe-6321 manual (or contact us).


Simulink® Hardware Settings ​
These settings should come already implemented from the model downloaded above, but for completeness, we'll include more information here.
​​
When running real-time models in Simulink with Simulink Desktop Real-Time, solver choice directly affects timing accuracy and stability.
A fixed-step discrete (no continuous states) solver is the preferred option for most real-time control systems. It provides fully deterministic execution and minimal computational load, making it ideal when the model is entirely discrete (e.g., digital controllers, state machines, logic, and DAQ I/O).
A fixed-step continuous solver (such as ode3 or ode4) should be used when the model contains continuous dynamics (e.g., transfer functions, integrators, physical system models). It maintains deterministic timing but requires more computation per step. This is suitable when real-time simulation of continuous plant dynamics is necessary.
A variable-step solver is generally not recommended for real-time execution because the step size changes during simulation, breaking deterministic timing. It is better suited for offline simulation where accuracy and efficiency are prioritized over real-time constraints.


Example: Blink the user LED
(updated on 2/26/2026)
EXAMPLE: Blink user LED ​
​
This Simulink® model blinks the EMB-DAQ2 user LED.
​
You can download the model by clicking here: EMB_DAQ2__NI_LED.ZIP (52KB)​ or from our GitHub. Make sure to always use the latest version.

​​To run the model:
-
In the MATLAB® Command Window, enter the sampling time (T=0.001, for example) and simulation Stop Time (S=inf, for example).
​​​​​​​​​​
-
In Simulink®, EMB_DAQ2_NI_LED model, enter the DESKTOP REAL-TIME tab, and click Run in Real-Time. If you run the model from the SIMULATION tab (green Run button), it won't work properly.
​
-
After clicking in Run in Real-Time, many processes take place, including building, code generation, and deployment of code to the target. These processes take between 5s and 20s.
​​​
-
To stop the model from running, you can click Stop in Simulink®.
