FieldPoint Family

cancel
Showing results for 
Search instead for 
Did you mean: 

unseen delay in program

if any one can spare some time and have a look , why this program experiences unseen delay whenever i switch from lets say 'Auto" to "OFF" or "Manual" . it does not stop motors rightaway , it stops after a while , i have only one VI running in real-time mode and priority is normal , is it because there is just one loop and lots to do?  both VI are doing same tasks but with slightly changes . a qucik response will be highly appreciated , Thanks
Fayasoft
 
Download All
0 Kudos
Message 1 of 14
(4,899 Views)

1 - Start by moving all the FieldPoint I/O controls outside the loop & eliminate the duplicated I/O controls.  Remember the program is having to look all those up from the .iak file everytime the loop executes.  That takes time.

2 - Minimize or eliminate the local variables.

3 - Can you combine the "Auto" and "Manual" case statements into one case statement?  Most applications don't allow both to be active at the same time.

4 - Can some of the boolean shared network variables be combined into an array that is passed by a single shared variable.  Shared variables will add to the overhead as well.

0 Kudos
Message 2 of 14
(4,881 Views)

1 - Start by moving all the FieldPoint I/O controls outside the loop & eliminate the duplicated I/O controls.  Remember the program is having to look all those up from the .iak file everytime the loop executes.  That takes time.

Ok , that will be the first thing I will do . actually I already did  but haven’t got chance to try. Other thing I was thinking about to use timed-loop  , 2 or 3 timed-loop and set high priority for fan control loop, what do you think?

2 - Minimize or eliminate the local variables.

Minimizing local variable will be hard but I will try , any suggestions what to use if not local variables, I heard , local variables are  the fastest among global and shared.

3 - Can you combine the "Auto" and "Manual" case statements into one case statement?  Most applications don't allow both to be active at the same time.

You mean put “auto” in true and manual in false?  But there is another case when none of the option is chosen which is OFF condition , but I think I can use more nested-loops and can do that .

4 - Can some of the boolean shared network variables be combined into an array that is passed by a single shared variable.  Shared variables will add to the overhead as well.

Actually in a test program I removed  all shared variables , but still facing delay , I think this delay  is because of the first thing you mentioned above. Other thing with Shared variable , I have to read temperature from field point and also some status (input or output to Field-point) and then I have to  display system temp or different status on another VI which will run from the host PC , remember the program that you looked at is running only on field –point independent of host PC.  also is it possible you can give me tips how to to passed data using single shared varibale after combing in array, i am not very good developer , just learning and this is my first program I am writing .

Anyways thank you very much to take out time and look at the problem , if you have further suggestions for my questions asked in this reply , please  let me know ,  and probably I will try these thing tomorrow morning ,   Thanks once again

Fayasoft

0 Kudos
Message 3 of 14
(4,874 Views)

Fayasoft,

Anytime you can replace a variable with a wire on your block diagram, you should probably do it.  Any variable will add overhead to your program.

One thing you could do to simplify the block diagram is this.  Take the 1D array of data from the cFP I/O and pass it as an array via a single Shared Network Variable to the PC.  Take that same array and convert it to a cluster using the array-to-cluster vi.  Remember to set the size of the cluster.  You can now wire that single cluster to various parts of the block diagram and unbundle as needed.  You could further simplify by building sub vi's for fan control and pump control.

Using timed loops and the priority setting will help.  You might want to look at the RT Project Templates.

One other thing that might be slowing the cFP down.  Create an empty file named "fpremote.ini" and put it in the directory "ni-rt/system" of your target cFP.

0 Kudos
Message 4 of 14
(4,864 Views)

I did some changes according to your last night’s suggestions , I am going to try it now .  please take a look at “Auto” loop   case “2”  when temp is greater than setpoint there will be a delay  using  Wait (msec) function , if operator hits auto and right away changes his mind and turn the switch position from Auto to “OFF” ( means neither MAN no AUTO) or MAN position , then in that situation program will count the delay or quit the loop , I think problem is here .

 

Other thing is that , creating fpremote.ini file  will speed up the hard ware? Do u think there is no file that’s why it is slow ?

Also I am sending you new program , please take a look and suggest according to yesterday suggestions

Many Thanks centrebolt.

Fayasoft

0 Kudos
Message 5 of 14
(4,858 Views)

You are correct about the Wait function.  If you need to be able to interupt during the Wait, you will need to use a timed loop to do the delay function.  Set the loop up to run at perhaps a 100msec rate for as many iterations as you need to get the correct delay.  You could then use a variable to interupt the delay function and cause the timed loop to stop executing.  This would make your process react more quickly to operator input.  I use this technique when I have a process that has large delays but still requires a rapid/emergency shutdown feature.  In my case I wrote a sub vi that uses the time loop with a global variable to shut things down.

Create the fpremote.ini and add to your cFP.  I don't know all the specifics, but I have seen a cFP run slow until it has run through all the I/O the first time.  After that it is ok.   Adding the file prevents the problem.  I have begun adding the file to all my cFP units as a precaution.

0 Kudos
Message 6 of 14
(4,855 Views)

hi centerbolt , just a silly question , .. how to create fpremote.ini ? 

thanks

fayasoft

0 Kudos
Message 7 of 14
(4,854 Views)

Fayasoft,

A .ini file is just a text file.  Open "Windows Notepad", save the blank document as "fpremote.ini" on your PC.  Open Internet Explorer and type in Address ftp://xx.xx.xx.xx where xx.xx.xx.xx is the IP address of you cFP.  Now you can navigate the directories on the cFP.  Navigate to the right directory and drag the .ini file across from your file manager window 

0 Kudos
Message 8 of 14
(4,849 Views)

Hi Centrebolt ,

Could you please take a look and comments on the program specially the way I used time delay functions at several places? And use of timed-loop I  mean do you think my first  loop wich got the top priority and located at the top in the block digram?

Also I used network variables (both single process and net-worked shared… do u think it is alright or busy loop because of  too many shared-var , on  the other hand I can not avoid using that much variables , any suggestion about my current approach?

Thanks

Fayasoft

0 Kudos
Message 9 of 14
(4,801 Views)

Fayasoft,

I can't look at the whole thing because you didn't include the sub vi's.  What I can see is that you are writing to the same I/O  in two different loops.  That is a potential race condition that can have very bad results. 

You still have local variables that you don't need.

You still have too many shared variables.

You really need to start using the error cluster in your vi's.  It will help control order of execution and it will help you debug your code.

You still have not replaced the "Wait mSec" vi with a sub vi that uses a timed loop.

The real question is this, does this run any better than what you started with?

0 Kudos
Message 10 of 14
(4,788 Views)