Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 9401, Counter I/O, Digital Output

Hi,

 

I am using the DI/O module NI 9401 with a cDAQ 9178 chassis. I am trying to send a counter-output signal to a bldc motor so that it operates for the entire duration of the experiment (meanwhile allowing the rotational speed to be varied by changing the duty cycle). I am measuring the motor rpm using an optical encoder (counter input). While these two components run without a break, I want to run a stepper motor on-demand (by sending a counter output signal to it, and a digital output signal to fix its direction of rotation. 

 

Problem: whenever I run the program, the motor and the rpm encoder operate as intended; but once I ask the stepper motor to rotate (using a Boolean switch for a case structure), it throws an error - Error Code 201133. On the referenced page, it is recommended that 'all tasks but one must be reserved. Subsequently, the unreserved task must be started first.' This solution works when I use a single while loop and the start task VIs are placed inside a flat sequence. But this means that I can no longer run the sequencing part of my code (that runs the stepper motor only when desired, or as programmed).

 

Question: What do I do to continue having the case structures and still be able to operate the stepper motor on-demand?

 

I have attached an excerpt from my VI. Please let me know if any additional information is required.

 

Thanks

lza

0 Kudos
Message 1 of 2
(125 Views)

By following the guidelines available here, I have reserved the tasks using Control Task VI, and the flat sequence structure ensures the correct sequence. Updated LabVIEW code attached. 

 

The problem now is that the stepper motor does not rotate on the first attempt (by pressing the Boolean switch, 'Rotate',  on the front panel), but runs fine on the second... This happens when I run the code the first time, or once I modify the value of the variable 'Displacement (deg)', and then try to run the motor. What might be causing this?

 

Additionally, I want to be able to change the values for both 'Displacement (deg)' and 'Speed (deg/s)' while the program is running. Right now, the 'Speed (deg/s)'  is not updated on the go.

 

Thanks,

lza

Download All
0 Kudos
Message 2 of 2
(81 Views)