04-26-2018 11:15 AM
Hello Guys,
I am a newbie on labview and I need your help please.
I want to keep the data on XY graph in my state machine named "sinus" . Do you have some ideas for me . I think that my shift register will save the data but nothing .
Thank you guys in advance
Ngoc-Vinh Truong
Solved! Go to Solution.
04-26-2018 12:06 PM
You might want to check out this nugget: Sporadic Waveform Chart
04-26-2018 02:08 PM
Your shift registers in "sinus" do accumulate data while you're executing that state, but you reinitialize them each time you restart the "sinus" state, so anything stored in them gets cleared out. If you don't want to reinitialize them each time, you need to feed the output of the shift registers on the right side of the loop back to the input side, or use a Feedback Node instead of a shift register, and move its initialization terminal out one loop.
04-27-2018 03:33 AM
Thank you for your answer my friends !
I understand why we use the feedback node but I don't know what do you mean for the initialisation.
Where should I put the initialisation ?
04-27-2018 08:17 AM
For a shift register in a loop, each time the loop restarts at iteration zero (e.g. each time you reenter the "sinus" state), the shift register is reinitialized to whatever's wired to the terminal on the left edge of the loop, in your case an empty array. If you only want the initialization to happen when the program first starts and not again each time you reenter the "sinus" state, then you can right-click the shift register and change it to a feedback node, then right-click the feedback node and select "move initializer out one loop". That way the initializer will be moved out to the edge of your main loop, and the feedback node will only be initialized once, when the program first starts.
04-27-2018 08:29 AM
Thank to you my friend that I succeeded ! 🙂
All your advice was very clear ! Have a good day , you make me happy ! 🙂
04-27-2018 10:00 AM
Sorry to bother you again.
Do you know how can I clear the history of the graph?
I try to put the invoke method "reinitialize to defaut" outside the loop with the method of producer and consumer . But I call for this method, it appears that, it clears the graph but when I recall for the case of sinus, It plots the graph with the old graphs .
04-27-2018 10:29 AM - edited 04-27-2018 10:31 AM
The data isn't being stored in the graph, it's being stored in the feedback node, same as it was with the shift register. Whatever you pass into the node gets output again on the next iteration. If you want to clear the data in the feedback node you have to feed it an empty array, and then that's what'll come out of it on the next iteration. For example, your "Clear Graph" button could control a Select node, with the wire for your accumulated data wired to the "false" terminal, an empty array wired to the "true" terminal, and the output of the Selector wired into your feedback node. That way when you set "Clear Graph" to true, it'll feed an empty array into the feedback node instead of your data.
Note that the index integer that you're using to build your X-array is still going through a shift register; I'd suggest handling it the same way as the Y-array data so they don't get separated. The way it's set up now the Y-array data will be initialized each time the program runs, but the X-array will remain in the shift register if you stop and restart the program running.
04-27-2018 11:09 AM
What do you mean because I think that I do like you say but the program does not work now ?
It goes to init-waiting of but-and again
04-27-2018 11:55 AM
I think you don't understand the concept of dataflow properly. With the "Clear Graph" button outside of the main loop like that, it only gets evaluated once at the very start of your program execution and never again, and even then it's just selecting between two identical empty arrays to initialize the upper feedback node with. If you want the "Clear Graph" button to have an effect, it'll need to be located somewhere inside the program where it will be checked during execution. Currently your feedback nodes are contained within the "sinus" case, so you'll only be able to clear the graph while the "sinus" case is executing, since that's the only time you can write your empty array into the feedback node.