01-12-2009 04:39 PM
Hello, I am a novice Labview progammer who has done little programming in the last 5 years. I am having problems with a Pacific Power Source generator controller vi, (ppsimple.vi) that I created about 5 years ago. It communicates with the instrument through the GPIB Interface. The intruments are either a Pacific Power Source 125AMX, or a 140AMX AC Power Generators, both using a UPC-12 Prgammable Controller. We have Labview 7 now and I want to correct the bugs and redo it. It was written in LV 6i, and here is a desciption of what it is supposed to do:
The Test- Overnight Normal Temperature test for equipment with an input rated 100 to 240 Volts AC, 50 ro 60 Hz. Typical setup- (started when the Technician is ready to go home) 90 V/ 50 Hz for 4 hours, 90 V/60 Hz for 4 hours, 256 V/ 50 Hz for 4 hours, 256 V/ 60 Hz until Technician returns to work and terminates the test. This save testing time by running temperature tests overnight (which don't normally need much human involvement) and doing the manual tests the following day.
The Problem- Occasionally the Software will start Test 1 correctly, but after 4 hours (or however long the Technician set it for) it fails to change the Generator to its Test 2 values, and when the Technician returns the next morning, it is still at Test 1 values. When asked how often this occurs, the anwer was ' It works more often than not'. I have found that if short Time spans are set (less than an hour) it will work every time, the problem only occurs for Time spans longer that 2 hours and it is ittermittent at that. If you look at the block diagram you will see that it is a very basic program, just a few While loops, and a Flat Sequence, using a few drivers provided by PPS, and some Labview 6i components. It writes a few commands to the PPS, then starts the timer, after the timer is finished it writes the next values, etc. There is no real error control, and the GPIB Interface does nothing for the 4 hours or so of the test period. I suspect that when the vi suddenly writes the new values to the PPS at the start of Test 2, it doesn't make it through. Can anyone suggest improvements or even a totally new approach to this controller? Let me know if I didn't provide enogh info or if it is confusing. Thanks for any help!
P.S. I didn't attach the PPS drivers, let me know if I should...
01-13-2009 12:10 AM
01-13-2009 06:22 AM
Some Points to make:
1) You have a number of instances of While loops with the conditional terminal set to "continue if true" and a NOT gate in front of them - remove the NOT gate and change the condition to "Stop if true (red dot in the middle - right mouse click will do this).
2) If you take the Quit Button and wire it to the conditional terminal of the outer while loop, from state 10 of the test program and move the Quit LabVIEW function into a case structure wired onto the end of the While loop; You don't need to have the main program sequence structure. This leaves you with fewer case structures and while loops nested inside each other and will make debugging easier.
3) As already mentioned if you link up the Error clusters, you can control the program flow and handle errors.
4) If you are really keen to clean up the code I would suggest doing the steps above, then changing the stacked sequence structure for a Case structure with an enumerated control. this creates a state machine architecture. (you could replace the while loop with a For loop and have an array of the Enumerated control to define your test sequence if you wanted. - The State Machine allows error handling better than your current architecture and can be created in a day or less (I've done it myself on some code very similar when I was starting LabVIEW) - see the Examples in the Example finder if you need more help.
01-13-2009 06:46 AM
I have done some changes. The get time /date function was in your software called very often, since the you had no wait function in your loops. Perhaps this is the source of your problem. Now it called every 500ms. It may help, perhaps you wear the get time function out:manhappy: (joke)
01-13-2009 07:48 AM
I have updated the changed VI with the changes I suggested.
Unfortunately I was not able to do a save for LabVIEW 7.0 as I don't have that installed. I have done a save for 8.0 in the hope that someone will be kind enough to download it and save it as 7.0 to allow you to get the full benefit from it.
Debugging with all of these changes should be a lot easier now.
I did wonder if the fact the VISA session wasn't wired through was throwing up the error, so I've wired that though and removed the required constants.
I would suggest making some of the Timing states into SubVIs as they are pretty much all the same code and it would tidy it up a lot more. (code reuse minimises areas where errors can be introduced.)
01-13-2009 11:22 AM
Thanks, I hope someone can save it in LV7 as I can't open it yet, thats what you get for running 'Lagging Edge ' Software!
Speaking of timers, I have been playing with the Time Delay and Elapsed time Express Vi's in available in LV 7 under the Execution Control, do you think these would be a better solution for the timer portion of the program rather than making these old school ones into sub vi's? I am not sure if you have the same ones in LV 8, so I'll attach a sample vi using the Elapsed time Express Vi.
01-14-2009 03:22 AM
Hi Doug,
Express VIs were introduced in LabVIEW 7 to speed development. They tend to not be as memory efficient or as fast to execute over long periods as writing the specific code yourself (which you had already done.) If you want to use the Express VIs, by all means do, but they are not necessarily the best choice. (You can also hide the options you don't use by dragging the box up, reorder the input/output with a roght mouse click, or view the express VI as an Icon.)
The use of Express VIs is a matter of choice. I tend to use them for fast development, then replace them with more efficient code that does the same job but is specific to my application, not generic and so doesn't have the overhead associted with an Express VI.
I would recommend you contact your local NI representative (call the helpline) and ask an NI tech support engineer if they can save you the code in the old version for you. It may be the fastest way of seeing what we have done.
Good Luck
James
01-14-2009 03:55 AM
I agree with James. I consider most of the express VIs to be flimflams. If you open the time elapsed VI and look at the code you find, a lot of unnecessary code plus the code you already have made.
I also looked at your most recently posted VI. I will strongly recommend you to put in some of the Wait (ms) then your code is doing nothing but waiting ( for input, or time to elapse). Everybody in this forum will agree in that this is a good programming practice
01-14-2009 10:42 AM
Hello Doug,
I have saved the modified version of the VI that James made to LabVIEW 7.0. I hope this helps!
01-14-2009 11:22 AM