12-27-2023 11:41 AM
Hello Folks I'm trying make a code to adquire the wave from past to analize the delta t and delta s for create a acceleration ramp in output do you know a way the get the data from past signal?
Solved! Go to Solution.
12-27-2023 11:56 AM
You could store the data by building an array and then access the past by indexing the desired section of the array out of it.
For simple uses, just add a shift register to pass data from one iteration of your loop to the next. If you drag down the shift register icon on the left side it will expand providing access to values from past iterations.
Using Shift Registers in LabVIEW - NI
12-27-2023 12:01 PM
thanks for the tip but how ll know the amount of delay times between values?
12-27-2023 12:49 PM - edited 12-27-2023 12:51 PM
You have nothing to time your loop, so it will run as fast as your CPU can go. If you are using a DAQ card, then it will depend on the card.
For now, just put a delay in the loop to do a simple software-based timing system. Wait(ms).vi and Time Delay.vi (in the Timing palette) are the easiest to start with.
In the future, you can use a waveform (Waveform palette) which is a cluster of start time, delta (time between points) and an array of Y values. It is very useful since there is a whole set of VIs supporting the Waveform datatype. Of course, you can always come up with your own way of storing the data too. Depends on your needs.
EDIT: You DO have a delay in there already. If you turn on the boolean, so the delay runs, you should get 1 second timing.
12-27-2023 12:58 PM
It is pointless to show us a code picture with overlapping elements and a case structure where we cannot see what's in the other case or what the mechanical action of the Boolean is. You can only easily get speed(t) and speed(t-0.1s) if the loop time is 100ms. A feedback node would be easiest. No case structure needed.
12-27-2023 01:00 PM
I would like an example of code which read a value and store this value with a controled time than I can compare the delayed waves
12-27-2023 01:26 PM - edited 12-27-2023 02:05 PM
You are assuming we know what you're trying to do. What signal are you trying to read? You have a scalar variable called speed. Where does it come from??? How does it change?
I work with motion control. I usually read a position signal first, which I can store in an array and integrate take the derivative to turn it into a speed signal, and then integrate "derivatize" that speed array into acceleration if I need it. What are you reading? What do you want to do with that data? What are you trying to accomplish?
EDIT: Mixed up some calc terms. 🙄
12-27-2023 01:50 PM - edited 12-27-2023 01:53 PM
In case you didn't read the link on shift registers, here is a quick example of how they can be used to read values from the past. I just bundled the signals into a chart, but you can add indicators if you want to play with the values.
Play with the speed slider while it's running and you'll get the speed and three history signals.
EDIT: BTW, the feedback node Altenbach mentioned is a shortcut way to use shift registers. I find it confusing to use, but many coders love it. Nice tutorial PDF here: HowtoUsetheFeedbackNodeTutorial.pdf (berkeley.edu)
01-02-2024 12:43 PM
Thank you a lot , now I`m understanded the code and could apply on my aceleration ramp and works , I`m very new on LabView , just used c++ for microcontrollers and ladder for Plcs , I just begining on it in few days ago , and have a Happy new year !
01-02-2024 02:58 PM
Glad you got it working! Keep in mind the use of shift registers is a simple convenience to grab one or two values from past loop iterations. The most general way to do this is to build an array of your data. Then, you can pass the array around, and index sections of it out for post-processing, or showing a time-slice of past data.
Waveforms are also a good way to efficiently store time-based data. Especially useful if you're using DAQ hardware to collect your data.
Good Luck in 2024!