LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need some help with VI

Good morning,

 

Hopefully someone can help me as I am quite new to LabVIEW and trying to navigate my way around making my first VI.

 

A little description of the VI:

- Every time encoder is over reference mark I want to record position off the master encoder.

- I measure the position of the reference mark in the forwards and backwards direction

- I am using the incremental signal from the encoder as the timing to ensure I capture the RM position as accurately as possible 

 

The issue:

1) It looks to be working as intended and its recording the position of the RM within a few um, but sometimes when I run my VI it decides there is a 0.6mm difference in position, sometimes it detects the RM being in the exact same location going forwards and back. (seems to change each time)

2) Stop button doesn't work quickly as while loop is going through the data in the buffer. 

 

I intend to remake my code into simple state and learn about how that all works but I need to get the VI working quite quickly in the short term and that is an extra activity I will do to tidy up my code long run, I know this will fix the stop button (issue 2) long run but looking for a short term fix also.

 

See attached screenshots for different data examples from running my VI.

 

Appreciate any other constructive feedback also as I understand I may not of done things in the best practise.

 

Many thanks everyone

 

Rupert

 

 

0 Kudos
Message 1 of 5
(2,040 Views)

I'm not sure if it's the problem, but in general, you don't want to compare floats for equality.

 

In stead, subtract the (current and previous) values, that the absolute, and check if it's smaller than some barrier.

 

Floats can be considered 'equal' for your application, but differ ever so slightly due to rounding. 

Message 2 of 5
(2,016 Views)

Thank you for the tip. Unfortunately with this corrected though it hasn't made a difference, as you mention I think my application avoided the rounding errors anyway but its a good approach to take encase there was any rounding errors in there.

0 Kudos
Message 3 of 5
(2,010 Views)

@Rupert2021 wrote:

Thank you for the tip. Unfortunately with this corrected though it hasn't made a difference, as you mention I think my application avoided the rounding errors anyway but its a good approach to take encase there was any rounding errors in there.


I though so.

 

Your floating point values come from an ADC, so they are somewhat 'discreet'.

0 Kudos
Message 4 of 5
(2,000 Views)

In almost every conceivable scenario, your error wires should be on shift registers when going in and out of loops.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 5 of 5
(1,990 Views)