10-15-2011 05:18 PM
Thank You Matt. I did what you said, from my understanding I believe I understood you right. I made the Browser code and the motor control code in two separate loops. Here is my code for you to look at. As the Program is still giving me the same issue.
~Andrew
10-15-2011 05:32 PM
Andrew,
Of course the buttons are only read once. LabVIEW is a dataflow language. That means that any node (loop, subVI, function, ...) will only execute when data is present on all its inputs and that its outputs are only available after it has completed execution.
In your program the buttons are read as soon as the program starts running along with the browser reference, and the TCP Open can also run immediately. After the buttons have been read the loop with the selectors and the composite OR gate runs. Then the main loop starts. The buttons will not be read again until the program has ended and been started again.
To see what is going on (and to learn about an important debugging tool) run your program with Highlight Execution (light bulb on block diagram tool bar) turned on.
The loop connected to the buttons is useless. The program will work exactly the same without it.
If you want the buttons to be read multiple times, the terminals must be inside a loop. They could be in the main loop or in a parallel loop with an event structure. With parallel loops you could use a queue to pass the data from one loop to the other without creating a data dependency between the loops.
Lynn
10-15-2011 06:44 PM
10-15-2011 07:03 PM - edited 10-15-2011 07:04 PM
Andrew,
Yes, that is the general idea. I suggest you work through the on-line tutorials. They are a good way to get started and to learn the terminology.
The terminal is the representation on the block diagram of a control or indicator.
Parallel loops are loops which are not connected by wires coming out of one and going into the other. If the loops have a Wait or other delay inside each of them, they can run "simultaneously." LabVIEW's internal scheduler will switch back and forth between the loops without waiting for one to complete before the other starts. On multicore processors they can actually run at the same time. The two inner loops in your main loop are parallel loops.
I suspect that they could be combined into one loop, athough I did not look closely at them.
Look at the Producer/Consumer Design Patterns which come with LV for examples of parallel loops.
Lynn
10-15-2011 07:41 PM
10-27-2011 12:05 AM
Thank You. I reviewed the tutorials and a few other sources and after a few tweaks I have it working as far as I can tell. I still cannot test it on the working application or any other method outside of the program yet, but as far as I can tell I am getting the correct output. Does this look correct to you as far as the program working? I put the programs in parallel loops and put a wait on what is my browser since my control is more important. Although (assuming you agree that it all works correctly) do you have any suggestions on how to combine or simplify the program any. I am sure I can combine the two bottom loops (the ones for the browser, but I am not sure how to go about doing that. Any suggestions or tips?
Thanks Again!
Andrew.
10-27-2011 12:54 PM
Andrew,
The IWebBrowser2 property nodes are broken on my system (something Windows only or requires a toolkit I do not have?), so I cannot run your VI.
Using Stop to end the program is not a good idea. This is the same as using the Abort button on the toolbar. Someone on the Forums suggested that stopping a VI this way is like stopping a car by running into a tree. It will work, but may have undesirable consequences. It is better to send a boolean value to each of the loop termination nodes rather than aborting the program.
You could use the timeout on the Get Menu Selection function for the timing rather than the Wait functions.
Unless you only have the Base version of LV, look at the event structure. It provides a much cleaner way to handle all the buttons and menu selections. With an event structure you would only need two loops, and maybe only one.
Building an array in a loop can lead to memory problems. It is generally better to pre-allocate space for the array by using Initialize Array outside the loop and then use Replace Array Subset inside the loop.
You should consider handling the errors, especially on the WebBrowser property and invoke nodes. If the browser crashes or times out or your internet connection is unavailable, you can detect it and handle it gracefully.
Lynn
11-16-2011 04:22 AM
Okay thank you for those ideas. I'm working on them now, although I'm having quite a major issue with the signal being transmitted. I'm not sure if it's how my loop is set up or how I'm transmitting or what. I am using this program to transmit data wirelessly to an "Xport Pro" which then going to an HCS12 microcontroller. With that information known, my issue is when I run my program the value that is first being sent out at the instant the program is initiated is a "0" which is correct it should be that way. But the issue is after that first inital value is sent all that is sent out is that same value. I can make different value come out by for example using a toggle switch to send out "77" for example. But once that "77" which would be the inital value is sent out no othe data follows it. "77" or what ever the initial valuse being sent out is just continuously comes out of the transmission. In addition to my trouble shooting I took a program that did not include any of my broser program and I had the same issues, so therefore I know that my browser loop isn't causing my problem. Any ideas?
11-16-2011 02:15 PM
Andrew,
The loop with the motor buttons in it has at least one problem. The value of the Stop button is read when the program first starts running (most likely False) and that values is passed to the loop. The conditional terminal is set to Continue if True so the loop will stop after the first iteration. If the motor buttons were all false when the loop starts, then it would write a zero character to the TCP one time. If the Stop button were pressed before the program starts, the loop would run continuously and never stop. In that case the value written depends on the motor buttons. It will repeatedly send the value selected by the button (like 77) until the button is released. You will need to use the Abort button in the toolbar to stop the VI.
Your other loops have the same problem with the Stop button. One way to solve this problem is to put the terminal of the Stop button inside one of the loops where it will be read repeatedly. Then use a Notifier to tell the other loops when to stop.
I am not sure exaclty what you want this part to do. The loop should have some kind of time delay so it does not attempt to iterate millions of times per second. You may want to learn about the event structure to handle the button presses more efficiently.
The two lower loops will run one after the other (assuming you fix the stop problem) because you have the stop boolean wired through the one on the left to the one on the right. Is this what yu want?
Lynn
11-17-2011 04:04 AM
SO are you saying that my "stop" button is the reason that the first interation is all that is being continuously sent out? That's the whole issue? I can correct the stop button, but will that make be able to change my output accordingly? Yes, when my Stop button is pressed I want it to stop everything. Could I take the stop button and move it into the button control loop for ex. and then wire the other loops into that terminal? Yes I tried an event structure, but I couldn't get my buttons to unlatch correctly (I usderstand there is some special way to read them. But I am running short on time so I don't have but another week or two max to get this program up and functional correctly. The event structure seems cleaner, a lot cleaner I jsut dont want to get caught up in that and I can't finish this with my due date. Here's what I had on the Event structure program.