12-26-2014 06:54 AM
Hi ,
I need one guidance from anyone. I have to insert a the new element into the array function. Please find attachments.
Explanations:
1. I have to insert "Auto " element by means of choosing "auto selecting". In this no problem.
2. But in manual, when I am adding the "manual" element into the "stage 2" , it is continuesly add. I want add that element for one time only.
3. For my project outer loop should be in "while".
4. In that file path you can give "input.txt."
I am ready to explain. Please take me into thee next step. . .
12-26-2014 10:57 AM
You should change the mechanical action of your Manual Switch from Switch when Pressed to Latch when Released. Then it will only execute the first time it is pressed then reset itself. You should make it look like a push button rather than a toggle switch. People expect buttons to be reset after being pressed. Toggle switches imply that they will remain in whatever setting you switch them to.
You should maintain your Stage 2 array in a shift register rather than using multiple local variables to read the indicator at the beginning of every loop iteration.
I don't understand what you are trying to do with your For Loop that is set to run only one time. Something looks wrong there.
12-27-2014 01:09 AM
Thank you for ur reply. I dont want to change the mechanical action of the switch. Because it may affect my whole process.
My requirement is, I want to add the manual element for a single time. Not for multiple times. This is reason why I included the for loop. I don't know whether it is corect or not. If it is error is there means kindly help me. . . .
12-27-2014 12:45 PM - edited 12-27-2014 12:56 PM
@azadplc007 wrote:
Hi ,
I need one guidance from anyone. I have to insert a the new element into the array function. Please find attachments.
Explanations:
1. I have to insert "Auto " element by means of choosing "auto selecting". In this no problem.
2. But in manual, when I am adding the "manual" element into the "stage 2" , it is continuesly add. I want add that element for one time only.
3. For my project outer loop should be in "while".
4. In that file path you can give "input.txt."
I am ready to explain. Please take me into thee next step. . .
Why exactly do you need to do this? Your program shows a complete lack of understanding of programming logic in general and you should really spend a few days doing tutorials before even starting to program. Whatever you are trying to do is very simple and the right code would probably fit on a postage stamp. You are doing all this way too complicated and convoluted.
Your program is full of race conditions due to overuse of local variables. For example there is no defined order between the upper and lower part of the code because they are independent. Most likely the local variable is read near the bottom before the terminal has received valid data. same for the "save&send" boolean. You are completely blurring the distinction between control and indicator. For example "Add:auto" and "manual" are indicators that never receive any data. So what's their point. Why are their terminals not intergrated into the code, but far off to the right? How often does the file contents change? Do you really need to read it with every iteration of the loop even if you completely ignore the data? Why do you have a 2D array if the data is really only 1D?
12-27-2014 12:48 PM
Honestly, you WANT to change your whole process.
1) You currently have an infinite while loop. This doesn't make sense outside of embedded applications. Use a stop button to fix this.
2) If you only want the manual to read the value once, what do you want to happen afterwards? There are three options I can think of: go back to automatic, continue reading the same value, or wait for the user to flip the switch but add nothing to the log. The first is achieved by doing as Ravens said. The second you've said you don't want to do. The third requires shift registers and comparisons
3) Break the habit of right to left programming. Data Sheet 2 should be to the far left of your VI. Wires should always go left to right. Wires that go the opposite way make your code hard to read and a mess to debug.
4) A for loop hard wired to run once is rarely the solution. You can easily move that shift register to your while loop and eliminate the for loop without changing any functionality.
5) Data flow. Learn it. There's nothing that guarantees you'll read anything in the order you want it to execute. Save and send, stage 2. These are both in "race conditions." Use wires to control your order of execution.
6) Why wolud you wire your input to a case structure under the case structure? Manual/Auto should be wired in a way that you can see the wire is the input to the case structure's selector.
Stop using the abort button to stop your VI.
12-27-2014 01:11 PM
This isn't the best example. It's meant to show you that you're thinking on entirely the wrong path right now and to get you working towards a more successful path.
12-27-2014 01:16 PM - edited 12-27-2014 01:21 PM
Here are two examples keeping switch action and adding a single manual entry right after automatic is turned off.