08-09-2020 05:01 PM
This is a vi that controls a valve to have a certain on/off time (set by vlv1lowsec and vlv1onsec). I'd like to edit this vi so that I could have the valve on/off time change while the script is running- ie., have one on/off time (e.g. 800ms/1200 ms) for 60 s, then change to a new on/off time (e.g. 2000 ms / 4000 ms) at 100 s. Is this possible..?
08-10-2020 12:56 AM
@labviewnoob81 wrote:
This is a vi that
No, this is just a partial picture of a block diagram. Quite useless for anyone trying to help.
08-10-2020 05:24 AM
You need to use the Elapsed time as an input to the formula node and in that check which output should be sent as OnTime
08-10-2020 11:17 AM
@Yamaeda wrote:
You need to use the Elapsed time as an input to the formula node and in that check which output should be sent as OnTime
There is really no way to give advice if we can't even see where the wires go (so many wires hidden under structures and going in all directions!). Shouldn't the elapse time express VI at least be inside the loop? (Or is there an outer loop that is not shown?)
08-10-2020 12:25 PM
I attached the rest of the block diagram below. The vi ws too large to screenshot in one screen, so I uploaded two images. The rest of the vi has to do with data collection and is mostly unrelated with the valve control part of the vi...
08-10-2020 12:27 PM
Yes, I had Elapsed Time as an input to the formula node, and I've put it in the loop now. I don't really understand how Time Elapsed worked, I thought that it would start counting as soon as the vi was run? Or is there something else I can use to that effect?
08-10-2020 12:42 PM
@labviewnoob81 wrote:
I attached the rest of the block diagram below.
Again, you are attaching pictures instead of the actual VI. There are till plenty of hidden wires where there is no way to tell the dataflow.
08-10-2020 12:47 PM
ah, didn't realize i could attach the actual, vi, here it is
08-10-2020 02:01 PM - edited 08-10-2020 02:03 PM
Hi noob,
on your VI:
By deleting that 2nd graph, which shows the very same data as the first one, your VI uses only half the memory and also its filesize cuts down to ~5MB!
You really should cleanup that VI and create subVIs for certain parts. I would put all the DAQmx task initialization into subVIs, and also that filepath creation (which can be simplified by using FormatIntoString). This way the block diagram size will be reduced drastically and you gain more overview (aka code readability)!
This formula node can be replaced by some simple math nodes. I would replace the ClusterToArray by simple UnbundleByName nodes…
And yes, using ElapsedTime (or simply subtracting two timestamps…) helps you to get the elapsed time to decide on the change of the valve timing: but again I recommend to first clean up this huge VI before starting to add even more functionality!
08-10-2020 06:11 PM
@GerdW wrote:
(or simply subtracting two timestamps…)
... or subtracting two high resolution relative seconds as shown here.