-1

I'm very new to LabVIEW... I need to write a simple program in LabView to update the value of an encoder.

Long story short... In a loop, I need to manipulate variables in this order:

  1. New Value = Old Value + Current Value
  2. Old Value = New Value

How do I prevent accidentally storing the old value before I calculate the new value?

Thanks in advance.

heyjaynell
  • 47
  • 1
  • 10
  • 1
    Are you monitoring whether the value changes? Add one more variable `New Value2`, assign `New Value2 = New Value` before doing `1.New Value = Old Value + Current Value`, then compare `if (New Value != New Value2)`, then do step 2. But I am wondering how could that happen if it is skipping step 1 and jump to step 2 if you are not talking about value changes – LONG Jun 28 '17 at 17:48
  • *face palm* This will probably fix it thank you. It's not skipping step 1, they just both happen at the "same" time, so sometimes its equivalently computing new value = new value + current value. – heyjaynell Jun 28 '17 at 17:52
  • np, give it a try :) – LONG Jun 28 '17 at 17:53
  • Correctly programmed that should not be possible. Can you show your labview code? – D.J. Klomp Jun 28 '17 at 21:22
  • that "EASY!" caught me off guard, I'm lmao right now hahahah. – LucasJ Jun 02 '22 at 20:23

1 Answers1

1

What you want is to pass the old value via a shift register (or feed back node, is the same). Here is the code snippet that shows you how to do it:

enter image description here

You can check that it works by looking at the New and Old values array.

A side note since your new, you can import code snippets directly into labview.

D.J. Klomp
  • 2,429
  • 1
  • 15
  • 30