Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
I have a problem with programming in the attached file. I created this file in Prime 2 back in May 2013, and have been using it ever since to determine component values. In December, I also installed Prime 3. The programming loop of the file computes the period / frequency at which the output voltage equals a certain value Vgassing. I start the programming loop with the frequency 1Hz above resonance which will give me a huge output voltage. I then increment the frequency 0.1Hz until the output voltage drops to equal Vgassing. When I open the file in Prime 2, the file computes the period / frequency perfectly. If you change the input voltage Vac at the top of the page from 435V to 450V, you will see the frequency rise at the bottom of the page. When I open the file in Prime 3, it does not give me a value from the programming loop. If you change the input voltage Vac from 435V to 450V at the top of the page, the program just gives me a value of 0 for Ts. What do I have to do different for Prime 3 than I do for Prime 2 to make this programming loop work? Thanks.
Wow, this looks like a bug! I'm forwarding to R&D.
Roger Yeh wrote:
Wow, this looks like a bug! I'm forwarding to R&D.
Yes, it look s like at least two worksheet variables (see my other post) are not recognized as existing worksheet variables and so are treated as local variables which default to zero.
Here is the problem boiled down to a simple example. Point is that variable "a" is made a local variable in the loop but for the condition of the while-loop the first time the worksheet variable "a" should be used which is not done in Prime3. Here "a" is treated as a local variable from the very beginning and as a local variable defaults to zero the while loop is never entered.
The problem only occurs with the while-loop. If the loop is replaced by an if-statement, it works in Prime 3, too.
Prime 2:
Prime 3:
Werner, you are (as usual) correct. There's an e-mail thread bouncing back and forth about this. I'll post a response here as soon as we decide how it will be handled. My guess is that we will be release a article* on this shortly and have a fix on the next release.
* It will basically say what you have already suggested as a work-around, i.e. to initialize variables at the beginning of the program.
Thats strange - I would call it a Prime3 bug and you should open a call and report it to PTC.
The file you sent is in Prime 2 format and so I was able confirm what you have reported - it works in P2 and fails in P3.
In P3 at least two variables are treated as being zero inside the program block - therfore the wrong result 0. I am not sure what the problem is - labelling or the units.
But if you redifine these two variable at the top of the program P3 yields the same results as P2. I must confess that I don't really know why this trick works and it should not be necessary. Its also unclear why its not necessary for the other global worksheet variables used in your program. The attached file is in P3 format.
A huge thanks for the help.