08-26-2009 04:16 PM
Hello Everybody,
First of all, I would like to apologize for the last time. You asked me to send the C-code of my program and I didn't answer. But in fact, I made a program without any formula node. It works but not totally.
My program begins with a for loop which sweep the entire range of the duty cycle of the signal which commands my MOSFET circuit. I obtain graphs and an excel file of the results, and then my circuit is blocked at the maximum point.
Then there is a second for loop which starts at the half of the power value and permits to obtain a new maximum. But this second for loop starts only is my voltage information (DAQ assistant 7) is less than 3 V or more than 7V. So I used a case structure (False condition). But this second part of the program doesn't work and I don't know why.
What I would like is that when I start my program, the first loop is executed one time only and that the circuit is blocked to the maximum. And then, the second for loop is executed only due to a variation of the voltage information and runs fastly (in 1s).
Besides, by seeing my program, could you give me advices to make my program running faster?
Thank you very much,
Anthony
08-26-2009 06:20 PM
You need to learn about the basics of dataflow.
Your second loop cannot start until the first loop has completed. Maybe the second loop belongs inside the first loop?
To speed up the code, we need to find out what is slowing it down. I cannot test, because I don't have any DAQ.
08-27-2009 12:16 PM
08-31-2009 02:01 PM
Hello,
I have checked the program with the VI metrics and what slows the program is essentially the "Write to Measurement File" and the different DAQ Assistants. Are there possibilities to improve these functions. I have heard that it's better to use the DAQmx instead of the DAQ assistant but I don't know how to use its well.
Thank you,
Anthony
09-01-2009 10:55 AM
Hi Anthony,
It is true that the Express VIs can slow down your code because it will open and close the reference to the hardware/file every time it is called. It is much more efficient to use the lower level VIs if you are looking for faster code, however it requires a bit more programming to do the same task. I would suggest looking at the examples in the NI Example finder (Help >> Find Examples...) on DAQmx (Hardware Input and Output >> DAQmx) and File IO (Fundamentals >> File Input and Output). Be prepared that doing this will probably result in a complete rewrite of your code.
09-01-2009 02:38 PM
Hi David,
Thank you for your help. I have changes my DAQ assistants by DAQmx functions. It's a little bit faster but I still have to change the functions which selects the signals from the DAQ Assitant. And the function which really slows my program is the "write to measurement". Is there an other mean to obtain a table of values?
Thank you,
Anthony
09-02-2009 10:11 AM
Good Morning Anthony,
I have two suggestions to increase the execution speed of your code.
1. Use fewer Express VIs and more low-level VIs. This is especially true of the Write to Measurement File Express VI.
2. Utilize the producer/consumer architecture. There is a Template in LabVIEW for this architecture (File»New, VI»From Template»Frameworks»Producer/Consumer Design Pattern (Data)).
09-02-2009 04:15 PM
Good Afternoon Charlie,
Thank you for your advices. I have changed the DAQ Assistants but I have a problem of dataflow. In fact, my graphs and tables don't give informations. I remember having this problem with the express functions and I had to use the function to select the signals. But here I don't know if it is due to that or just due to samples. That's sure something is wrong cause I don't have blue lines which goes to the graphs and tables
Attached, there is a part of my program.
Thank you,
Anthony
09-03-2009 02:36 AM
Your VI is still a mess. The only DAQ part that should be inside the loop is "read", all the rest belongs outside the loop, because it needs to be done only once. Don't create and later clear new task with each iteration of the loop!
There is no way for me to tell what's wrong, because I don't have any DAQ installed. Can you replace the DAQ parts wit simulated data?
09-03-2009 02:41 PM
Hello,
Thank you for your reply.
My program doesn't work since I have changed the DAQ assistant by the 2 entries DAQmx PV Voltage In and DAQmx PV Current In. The other DAQmx Control Voltage Out work. So I am sure something is wrong in this part of the program. I have just let the DAQ part "read" inside the loop as you explained but I have still nothing in the graphs and tables except the value of the loop index.
I don't think I can simulate my circuit but attached you can find the 2 versions of my program. The "OneForLoop App1" is the first program with express functions which works but is slow and the "OneForLoop App2" is the other version with DAQmx functions. I know it's hard to solve a problem without simulating but maybe you can find what is wrong by making a comparison of the 2 programs.
Thank you very much,
Anthony