LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to reset a square wave graph?

I am using a PID controller to monitor a setpoint pressure so I want to create a square wave graph that runs for 60 s at a value of 1 and then for 1s it runs at a value of 0.

I have created a formula node with the following code:

 

u1=0;
P1=0;
Reset=0;
 
if {(u1<= 59)
P1==1
}
 
else {
(u1>59)
P1==0
}
for (i=0 ; i<0.5 ; i++) ; //this section just gives a time delay of 0.5 s
reset==1
 
my formula node has an input value of u1 which stands for time and two outputs P1 (pressure) and reset which resets the graph to the above code continuously.
 
Capture.JPG
The image above shows what I have so far where I want to reset the code that is running in my program every time the 60 s interval is done (which should look like the graph below)
 
Capture1.JPG
my amplitude is supposed to be my pressure P1 which runs for 59 s at amplitude of 1, and 1s at an amplitude of 0. I want to get this pattern continuously therefore that is why my code needs to be reset. Anyone know how I can do this?
 

 

0 Kudos
Message 1 of 3
(3,208 Views)

Your formula node do nothing.

---
u1=0;
P1=0;
Reset=0;
--
So, u1 input doesn't matter. u1 =0 any case.

---
if {(u1<= 59)
P1==1
}
-----
and u1<59 averytime
so P1=1
 

---
else {
(u1>59)
P1==0
}
for (i=0 ; i<0.5 ; i++) ; //this section just gives a time delay of 0.5 s
reset==1
----
and this part never work.

But even if u1>59
why you think that
"for (i=0 ; i<0.5 ; i++)  "
give you delay 0.5s?
There are always 1 iteration and stop (i++  = i+1 = 1 > 0.5)

0 Kudos
Message 2 of 3
(3,180 Views)

No formula node needed.  Just set the Elapsed Time VI to reset every 1 second and compare the elapsed time output to 0.5.  Then you know if you should have a high or low.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 3
(3,169 Views)