NI9401 Pulse Generation and Digital Output same time
21 views (last 30 days)
Show older comments
Hey all,
I want to drive a stepper controller (TRINAMICS) using the NI 9401. I know that NI 9401 is capable of generating pulse which can be used for the "CLK" resp. "STEP" signal for the stepper controller. Beside the CLK signal I also have to provide digital signals for "DIR" (direction) and "EN" (enable). Is it possible to generate pulsed signal and "constant" digital output signals same time using the NI 9401 ?
My recent approach is attached below, which is not working.
Thank you !
close all;
clear;
clc;
devID_NI9401="cDAQ1Mod1";
daqObj=daq('ni');
chCLK=addoutput(daqObj,devID_NI9401,"ctr0","PulseGeneration");
chCLK.Frequency = 1000;
chCLK.DutyCycle = 0.5;
chDO=addoutput(daqObj,devID_NI9401,"port0/line2","Digital");
write(daqObj,ones(500,1));
start(daqObj,"continuous")
2 Comments
Pietro Mele
on 5 Jul 2024
Hi @Tugrul Öztürk did you finally solved the problem? I'm currently facing the same issue, emoploying the NI 9401 for controlling a step motor with Simulink. Is it possible to use multiple ports for DO ?
Answers (1)
MULI
on 10 Oct 2024
Hi Tugrul,
I understand that you need to control a stepper motor using a TRINAMICS stepper controller with the NI 9401 module which involves generating a pulse signal for the "CLK" and simultaneously providing constant digital signals for the "DIR" (direction) and "EN" (enable) inputs.
To achieve this, you can use the NI 9401's counter output for pulse generation and its digital I/O lines for setting constant signals.
- Use the counter output for generating a continuous pulse signal which is suitable for the "CLK" signal.
- Use digital output lines for "DIR" and "EN". These should be set to constant high or low levels as needed.
Here's an example of how you can set this up:
close all;
clear;
clc;
devID_NI9401 = "cDAQ1Mod1";
daqObj = daq('ni');
% Configure the pulse generation for the CLK signal
chCLK = addoutput(daqObj, devID_NI9401, "ctr0", "PulseGeneration");
chCLK.Frequency = 1000; % Set the desired frequency
chCLK.DutyCycle = 0.5; % Set the duty cycle
% Configure digital outputs for DIR and EN signals
chDIR = addoutput(daqObj, devID_NI9401, "port0/line0", "Digital");
chEN = addoutput(daqObj, devID_NI9401, "port0/line1", "Digital");
% Set the DIR and EN signals
write(daqObj, [1 1]); % Set DIR and EN to high; adjust as needed
% Start the pulse generation
start(daqObj, "continuous");
For more detailed information, you can refer to the following documentation:
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!