ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

periodic counting

Solved!
Go to solution

Hello!

This might be so easy to implement but not for me, at least not at the moment. I would like to create a CAD counter that I need to simulate for testing a subsystem I created, for demonstration purpose. The need is to be able to count from -360 to 360 with a resolution of 0.1 ( preferable if it can be adjusted as the need comes) periodically. i.e Once one full cycle is counted [-360,3609], then the count is supposed to start over.  

 

Has anyone implemented this before? I very much appreciate the help I get. 

 

As always thanks for all the helpful guys up here!

 

 

0 Kudos
Message 1 of 22
(4,906 Views)

Hi Henok,

 

sounds like you need a comparison function. Quotient&Remainder might help too...

 

Counting up to a limit and starting over again is a common task. Some pseudo code to get the idea:

ctr := ctr + 1
IF ctr >= upper_limit THEN ctr := lower_limit

 

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 22
(4,898 Views)

Could you be more elaborate please? Like an example?

0 Kudos
Message 3 of 22
(4,887 Views)

2011 compatible vi please

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 4 of 22
(4,883 Views)

Hi Ranjeet,

Here is the 2011 version of what I tried to do 🙂 

0 Kudos
Message 5 of 22
(4,880 Views)

Hi Henok,

 

try this:

check.png

It's just a simple math: use your loop count to calculate your scaled value...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 22
(4,866 Views)

Hi Henok,

                                 I am attaching one VI. Enter 'resolution' &  'Delay between two count in ms' & run the program.

Try resolution as 1 & Delay between two  count in ms as 100 & see.

 

Hope this is what you are looking for. Let me know if you need any explanation.

 

 

Thanks

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 7 of 22
(4,848 Views)

Thanks Ranjeet!

Its very impressive! I just could not know why it doesnt work for different resolution ( I tried 0.1 as it was my target). I tried to tweak the values and see if it works, but once it starts 360 with the current count, it kept counting up instead of starting over from -360. Any idea why?

0 Kudos
Message 8 of 22
(4,839 Views)

Please try this & let me know.

 

Kudos are always welcome.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 9 of 22
(4,835 Views)

Hi Henok,

 

the problem arises from using the "equal?" comparison on floating pouint numbers.

Ranjeet forgot the inaccuracy of such numbers as was explained a lot of times before in the forum...

 

Conclusion: NEVER compare floating point numbers for equality!!!

 

That's the reason why I was using integers for the "counting" part in my example followed by a simple scaling to your desired range...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 22
(4,834 Views)