Citect Function

A

Thread Starter

Anonymous

hi guys

I created a new task "TaskNew("Animation", "infeed", 4)", it needs to read the status of an infeed sensor from PLC before starting and it just runs for 5 seconds. If I use "Reread()" to update the input data continually, it takes a long time to complete data refreshing and the animation is therefore not real-time.

Is there any alternative to refresh the input data rather than using Reread()?

Thank you.
 
F

Fredrik Högberg

Hi!

Reread does things as optimally as it can. I see no way for you to improve speed.

When you start a cicode function citect reads all variables that are defined in the function. Use ReRead if you need to update the values while the function is running.

If ReRead takes to long to run your communication is probably slow.

What's your communication?
How do you update the page with info?

Fredrik
 
K

Kelvin Proctor

Can you post us the function so we can see exactly what you are doing?

Additionally, what sort of a device are you talking to? Is it a slow old serial device or something faster over Ethernet?

If your code runs in a loop then it will need to call ReRead() at the top of each loop cycle (or as often as you want the data refreshed). This will take a while as it will cause request(s) to be sent to the I/O Devices and then wait for them to be serviced.

It should also be noted that you don't need to run ReRead the first time you run the loop (put the update at the bottom) as all required variable tags will be read by the CiCode engine before just before it reaches the entry point of your function.

Regards,

Kelvin

Disclaimer: I am an employee of Citect. This is a personal communication and should not be considered an official communication from Citect.
 
<p>hi, Kelvin

<p>Thanks for your reply.

<p>I am trying to create an animation of work pieces moving along a conveyor. Now I use TagRead() instead of ReRead().
<pre>
TaskNew("Animation", "infeed", 4);

FUNCTION
Animation()
INT AN;
INT iStart;
WHILE 1 DO
IF TagRead("infeed") = "1" THEN
AN = DspAnNew (1046,680);
iStart = SysTime();
WHILE (SysTime()-iStart < 5000) DO
DspSymAnm (AN,"wmfpumps.s1","wmfpumps.s2","wmfpumps.s3","wmfpumps.s4","wmfpumps.s5","wmfpumps.s6");
END
DspAnFree(AN);
END
END
END
</pre>
<p>But there is another problem occured. if I put another workpiece on the conveyor when the first one is still moving, that workpiece cannot be animated. so I just can animate one workpiece at each time. How can I modify the code to make two or more animating at the same time? Could you give me some advice?
Thanks a million.

<p>Regards,<br>
Jeff<br>
[email protected]
 
K

Kelvin Proctor

<p>Jeff,

<p>I haven't actually had to use DspSymAnm myself but based on the help files you should not be calling this in a busy loop.

<p>I think you should try the code:
<pre>
TaskNew("Animation", "", 4);

FUNCTION
Animation()
INT AN;

AN = DspAnNew(1046, 680);
DspSymAnm(AN,"wmfpumps.s1",......,"wmfpumps.s6");

WHILE TagRead("infeed") = "1" DO
SleepMS(5000);
END

DspAnFree(AN);

END
</pre>
<p>This will draw your animation at the given point. The animation will change symbol at a rate based on [Page]AnmDelay.

<p>The code then goes into a loop where every five seconds it checks if the animation should still be running. If it decides it should not be running any more then it stops it.

<p>If what you are trying to do is get an animating symbol set to move along a conveyor then I think this should probably be possible by placing a symbol set object on the page and setting its movement, appearance and visibility
properties.

<p>If this does not help I'd need you to give me a better description of what you are actually trying to do. (Graphically what are you trying to achieve).

<p>Cheers,

<p>Kelvin
 
Top