08-11-2016 10:26 AM - edited 08-11-2016 10:27 AM
OK, so the while loop and shift register can be deleted and we have the following
Does it always start with an input of zero? It is really not a good idea to stall the calling VI for tens of seconds, because it limits user interaction. What is the overall architecture of the caller? Does this run in a parallel loop for the UI code? How do you interrupt the long waits, e.g. if you want to stop the program early?
@GavinSheehan wrote:
If I select a Hold Down test, my code performs the same function but it cuts out the intervals from 0-1 second and jumps straight to 1 second intervals.
So this is only a tiny difference between the two cases, so why would you have all that duplicate code? All shared code belongs outside the case structure.
I'll have a look at this later and maybe make some suggestions.
08-12-2016 01:20 AM - edited 08-12-2016 01:33 AM
GavinSheehan wrote:I'd love to hear ways to improve and alter this because I spent a loooong time trying to figure out a way to do it to suit my needs.
OK, here's a quick draft that should work OK if the input is well formed. See if it can give you some ideas. Please verify correct operation, there could be bugs, of course.
08-12-2016 02:35 AM
Do you have access to LabVIEW online training? You could go through LabVIEW Core 1 and 2 (and 3), to learn clean programming techniques.
08-12-2016 02:53 AM
Yeah I do. I have completed Core 1 and 2 and I'm inthe process of doing 3. I've been using LabVIEW for about 2 years but I'm only now getting into big projects. As I said above, my code is usually very clean but in this case I just wanted it to work to start!
08-12-2016 04:41 AM
I've tested that out and it looks to work very well! Thank you! I'll see if I need to adjust anything to make it work in my code but I don't think I have to!
08-12-2016 09:10 AM - edited 08-12-2016 09:13 AM
@GavinSheehan wrote:Yeah I do. I have completed Core 1 and 2 and I'm inthe process of doing 3. I've been using LabVIEW for about 2 years but I'm only now getting into big projects. As I said above, my code is usually very clean but in this case I just wanted it to work to start!
Your original problem was not really a programming issue, but an algorithmic one. Yes code can get ugly when randomly testing variations to get the correct result, but here it required a fresh approach instead of brute forcing all possible scanrios with pages of code.
If you can explain the task in one sentence and with basically no exceptions, there is enough symmetry that a mathematical solution should exists. You simply need to find it. 😄 I am sure there are further simplifications possible.
Good luck!