LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resetting Addition Feedback

Hello,

I'm working on a checksum validation code which involves some feedback through an addition loop. I get a string of hex numbers in a reply from a piece of hardware and add up the digits it sends me (ignoring the leading $ and ending !). This should add up the the hex checksum truncated to the least significant 2 digits which are placed at the end of the string.

I have this working for the first iteration, but if I try to run it again, the addition loop is not cleared from the previous iteration, and therefore I get twice what I expect (3x for the third iteration, and so on). How do I go about setting the loop back to zero once I check it?
0 Kudos
Message 1 of 14
(3,755 Views)
If you run your code with highlight execution on, you can see that the feedback node does not get reinitialised to 0. The node retians its value from the previous run because the VI is still open in memory. To fix it, wire a zero constant from outside the loop to the init. terminal on the feedback node 🙂

Edit: Aditionally, you do not need to use the sequence structure, as the wires are forcing correct data flow anyway - right click the structure and select 'remove sequence' to remove it easily and cleanly


Message Edited by yenknip on 07-02-2008 05:23 PM
_____________________________
- Cheers, Ed
0 Kudos
Message 2 of 14
(3,747 Views)
You need to initialize your feedback loop. Right click on it and select Move Intializer One Loop Out. that will place it on the while loop edge. Wire a 0 constant to it.
0 Kudos
Message 3 of 14
(3,745 Views)
Or better yet, use a shift register instead of a loopback.  And initialize the shift register with a zero.
 
R
0 Kudos
Message 4 of 14
(3,737 Views)


@Dennis Knutson wrote:
Right click on it and select Move Intializer One Loop Out. that will place it on the while loop edge.


I didn't know you could do that with feedback nodes, I always use shift registers anyway - seeing wires go left to right makes more sense to me
_____________________________
- Cheers, Ed
0 Kudos
Message 5 of 14
(3,729 Views)


@yenknip wrote:
Edit: Aditionally, you do not need to use the sequence structure, as the wires are forcing correct data flow anyway - right click the structure and select 'remove sequence' to remove it easily and cleanly


Ah, I see what you mean. So LabVIEW always automatically recognizes an output wired to an input and uses that as a data flow guideline?

Didn't notice that initialization node, a very simple fix.

What did you mean by using the shift register though? I have no experience using those in labview...
0 Kudos
Message 6 of 14
(3,722 Views)
The Basic paradigm of LabVIEW is the concept of dataflow. A block on the Block Diagram cannot be evaluated until all of its inputs have a defined value. In the example below, addition is evaluated first, then multiplication.



Shift Registers are added to a while loop or a for loop by right clicking the edge and selecting 'add shift register' or you can change a tunnel to a shift register similarly. These pass their exiting value back round to the entrance point of the loop to be used in the next iteration




Message Edited by yenknip on 07-02-2008 06:31 PM
_____________________________
- Cheers, Ed
Download All
0 Kudos
Message 7 of 14
(3,701 Views)
Thank you much, always like learning new things.
0 Kudos
Message 8 of 14
(3,694 Views)


yenknip wrote:
I didn't know you could do that with feedback nodes, I always use shift registers anyway - seeing wires go left to right makes more sense to me

I feel the same way..
 
Shift registers are your friend 😉
0 Kudos
Message 9 of 14
(3,688 Views)
Once upon a time, there was only the shift register. Then, the feedback node was added but they were essentially the same thing. If you right click on a feedback node, you can select Replace with Shift Register and if you right click on a shift register, you can select Replace with Feedback Node. The major difference now is that a shift register requires a loop structure (while/for loop). You do not need a loop for a feedback node.
0 Kudos
Message 10 of 14
(3,686 Views)