10-03-2023 06:14 PM
Hi all,
I need to create a ramp like function in Formula node which will be repeated every second. This is what I tried:
"
if (t==0)
y=0.1;
else if (t>0 && t<0.3)
y=t+0.1;
else if (t>=0.3 && t<0.4)
y=0.4;
else if (t>=0.4 && t<0.7)
y=-t+0.8;
else if (t>=0.7 && t<=1)
y=0.1;
"
It shows the correct profile for one cycle,. but I need it to be repeated after each second. I belive it should be done in a for loop structure but since I am a NI newbie, not sure how.
Any help is appreacited.
Thanks
Navid
Solved! Go to Solution.
10-03-2023 07:06 PM
No need for any formula node. Just use graphical primitives. 😄
10-03-2023 07:12 PM
Thanks. It is going to have other parts to cycle synchronoise (phase lock) it with other equipment (laser, camera, sensors). The way the code is written so far (for other profiles) is based on Formula node. That is why I need to implement this into formula node.
10-03-2023 08:01 PM
@navidvd wrote:
Thanks. It is going to have other parts to cycle synchronoise (phase lock) it with other equipment (laser, camera, sensors). The way the code is written so far (for other profiles) is based on Formula node. That is why I need to implement this into formula node.
Once you have your function output you have your function output. It doesn't matter how you get it. So, get it the easy way.
Each section you describe is a simple waveform section
if (t==0)
y=0.1;
else if (t>0 && t<0.3)
y=t+0.1;
Ramp pattern start 0.1, end 0.3 samples, TBD you didn't specify a dT
else if (t>=0.3 && t<0.4)
y=0.4;
Initialize Array value 0.4 size TBD you didn't specify a dT
else if (t>=0.4 && t<0.7)
y=-t+0.8;
Ramp Pattern start 1.2 end 1.5 size TBD you didn't specify a dT
else if (t>=0.7 && t<=1)
y=0.1;
Initialize Array Value 0.1 Size TBD. (that dT again)
Concatenate them together in a single Array or better yet use a Waveform Datatype. No ifs no ands no "but if onlys" and you can even test, adjust and add notes for each part.
10-03-2023 08:34 PM
Thansk for your reply. This is how it looks like at the moment:
dt is 10 ms. I need the profile to be repeated after each cycle. But with the way I wrote, it is only one cycle.
Thanks
Navid
10-04-2023 01:12 AM
Hi Navid,
@navidvd wrote:
dt is 10 ms. I need the profile to be repeated after each cycle.
But with the way I wrote, it is only one cycle.
Yes, the way you wrote your code it will execute once. (Atleast what we can see from your images: you know we cannot edit/run/debug images in LabVIEW!?)
You also wrote:
@navidvd wrote:
I need to create a ramp like function in Formula node which will be repeated every second.
Right now your t will go from 0.00 to 24.99: how does it fit to your "repeat every second" requirement???
if (t==0)
y=0.1;
else if (t>0 && t<0.3)
y=t+0.1;
This is Rube-Goldberg: there's no need for the "t==0" case…
10-04-2023 01:47 AM
Hi,
Thanks for your response.
I changed the loop count to 100. Now it looks like it can generate the second cycle immidiately after the first one and so on. Is that correcT? I attached the code as well.
Thanks again,
Navid
10-04-2023 02:15 AM
10-04-2023 02:18 AM
Sure, attached is the 2019 version.
Navid
10-04-2023 02:58 AM - edited 10-04-2023 02:59 AM