From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Element resets to zero after sub vi runs

Solved!
Go to solution

Hi all,

 

I want to use the following code to slowly and continuously ramp up laser power. The sub vi called scan does the ramping but after it has ramped all the say up to the set power it resets to zero. I have been working for awhile trying to figure out how to the variable element set to the final desired power after the ramping has finished but I can't figure out a way that works. I'm curious if anyone has any suggestions!

 

Thanks, 

0 Kudos
Message 1 of 5
(2,759 Views)

My eyes hurt... so much purple and red!

 

You have a lot of bad programming practices going on here, which makes it very hard to debug (dataflow going right to left, nothing lined up, no documentation).

The subVIs are also all missing, so I can't run the code. If you can supply everything to run it, it would be much easier to solve the problem. Particularly the subVI "Scan Waveform" might help.

 

It looks like the key is within the Scan VI because the internal While loop will continue to run until the user presses stop. This means whatever value you are outputting from that VI is what's resetting the value.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 5
(2,739 Views)

Hi James,

 

I know the code is kind of a mess right now, I haven't been keeping it very clean while working on this, I've just been trying to get it done. I can post the scan sub vi so you can have a look.

0 Kudos
Message 3 of 5
(2,726 Views)
Solution
Accepted by topic author winterfresh11

Well there's your problem, at least the one causing your drop: your index input will keep going up with each iteration, but your array inside the VI is only so large. Once the index goes above the array size, it tries to index past the end and will therefore output the default value of zero. To fix this, put a Select node that is controlled by your x=y? boolean output. If True, output the "Stop" input value and ignore the indexed value.

 

DISCLAIMER: This should fix your immediate problem that you're asking about, but your code in general will most likely have other issues. There are better ways to ramp a signal.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 4 of 5
(2,719 Views)

Hi James,

 

You're correct that was all it needed and it seems to work pretty well now. There are a few bugs I need to fix but that problem was one I could not figure out

0 Kudos
Message 5 of 5
(2,695 Views)