Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use counter input to read encoder and counter output to drive the motor at the same time.

Hi there,

 

Currently, I'm utilizing two NI 9401 modules alongside one NI 9403 module with a cRIO 9045.

While I can independently read either the encoder or drive motor with separate code, combining these codes doesn't yield responses from both signals.

 

My objective is to read motor angle using counter input and drive the motor using counter output (frequency output) at the same time. To achieve this, I've configured the output signal and input signal on separate modules (each 9401), with a digital signal for changing the motor's direction set on the 9403 module.

 

If anybody has any ideas as to what could be wrong with my code, I would greatly appreciate it.

0 Kudos
Message 1 of 5
(136 Views)

I guess this is the reason why your PWM is not working. Changing a terminal after a task has started will return an error. 

ZYOng_0-1714049358910.png

You should connect all the error clusters to the stop condition so that your code will stop on error rather than doing nothing.

ZYOng_1-1714050051295.png

 

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 5
(118 Views)

Hello ZY Ong,

 

I did try following your suggestion, but the code still isn't functioning properly.

I have a few questions regarding this issue:

1. Is it possible to use counter input and output simultaneously?
2. Should the while loop be applied separately?
3. How do I set up the task control?

0 Kudos
Message 3 of 5
(84 Views)

You need to do some debugging. Make sure there is no error reported. Use Diagram Disable Structure to comment out part of the code.

You can definitely use both counter input and output at the same time. I never had to work with task control, except with NI-9401, which is slightly more complicated. See Configuring an NI 9401 for Bidirectional DIO By Nibble with DAQmx

I usually put everything inside a single while loop, unless I am using producer/consumer architecture for logging purposes. It is easier for me to handle errors with less loops.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 4 of 5
(76 Views)

Following your advice, I made some modifications to my code and tested it.

As a result, I encountered error code 50103.

I tried modifying all cases as per the link below to resolve it, but the error code persists. Could you advise on how to resolve this?

 

LabVIEW 또는 NI-MAX에서 NI-DAQmx를 사용할 때 오류 -50103 - NI

0 Kudos
Message 5 of 5
(52 Views)