LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter reset to initial count when reaching a number

Solved!
Go to solution

Dear all!

 

 

I have a rotator encoder connected to a NI USB 6001 and I try to reset it to initial count every time it makes a full round. So let's say in my code when the count reaches to '930' it should be reseted to '0' (=initial count). Can anybody provide me some help?

 

 

Your Sincerely,

SzSzilard

Download All
0 Kudos
Message 1 of 5
(3,098 Views)

Hi Sz,

 

use a quotient&remainder function…

 

On your image:

You read some data from a DAQAssistent, buried in a DDT signal wire.

Then you read an array of values from your counter DAQmx task and convert this nice 1D array into an ugly DDT signal wire.

Then you merge both signals into another DDT wire - just to display all those values in a scalar numeric indicator!?

Even though DDT wires allow such silly operations they most often doesn't make sense!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(3,091 Views)

Thank you for your answer. I modified my code as you said, I added some really unusual things earlier. But I still don't get to reset the counter to initial value(0). Any suggestions?

 

 

 

 

Download All
0 Kudos
Message 3 of 5
(3,046 Views)
Solution
Accepted by topic author szszilard

Do not use the DAQ Assistant or Dynamic Data wires. At all. It's an unfortunate trap that NI put in, as they LOOK like they're a super simple way to program, but they're unfortunately way more trouble than they're worth.

 

Go to Help -> Find Examples -> Hardware Input and Output -> DAQmx -> Counter Input -> Counter- Read Encoder (there are a few of them).

 

You can input your rotary encoder's counts per revolution in the DAQmx Create Channel function. The example should run your encoder straight away with zero code modification and you'll have it.

 

For more reading, check out this article:

 

https://www.ni.com/en-us/support/documentation/supplemental/06/learn-10-functions-in-ni-daqmx-and-ha...

 

and you should be WELL on your way to making DAQmx work for you.

Message 4 of 5
(3,042 Views)

Thank you for your response and for your help! I will read Your suggestions!

 

0 Kudos
Message 5 of 5
(3,036 Views)