That won't fix the fundamental problem with the code: race conditions. Multiple ones. Caused by: excessive use of local variables. You are trying to read the values of indicators before they've been updated. You need to establish an order of execution. The way it is now, it's anyone's guess when something runs.
There are also a number of other issues, and since it's clear you're a beginner, you should spend some time going through some programming fundamentals. Some pointers:
- In your main loop you're doing this:
which doesn't make much sense. The ON/OFF will always be on as long as i is not zero. The same thing can be accompished by this:
- You Int2Bit can be simplified by resizing the Index Array rather than having individual Index Array functions. Also, the input datatype should be set to an I32:
- Your Bit2Int VI is performing unnecessary actions in taking the numbers (which should be integer datatypes), converting each to a Boolean array, taking the first element, and then taking each first element into a Build Array. Just take the numbers and feed them to the Build Array directly.
- You use of the subVIs assumes that "DB0" is updated when you call the "Square Gen" VI. This is true, but it doesn't do it the way you think it does. Inside that subVI you have a sequence frame that updates the subVI's "Signal Out Ind" with the value that you want to write. The value that the main VI gets is the value once the subVI finishes. Thus, it will never toggle. This is by design of calling a function, and is not specific to LabVIEW, as it is fundamental to programming.
Bottom line: You need to spend some time learning about local variables and the proper way to use them, as well as how subVIs work. I would suggest going through the LabVIEW tutorials as well as seeing what's available on the NI Developer Zone's Learning Center. There are also a number of books available.
Message Edited by smercurio_fc on 09-17-2007 10:03 AM