Help!!! Need to write a pause cicode function

Zenn

Member
Join Date
Aug 2004
Posts
4
I have a auto-start button with the function with the coding of the following:



FUNCTION
StartAuto()

INT Counter = 0;

WHILE Counter < NumCycles DO

MoveCyl();
ResetAGV();
Toggle(Conveyor);
SleepMS(1000);

Toggle(HW_Valve);
FillMixTank();
Toggle(HW_Valve);
Storage_Tank = 0;

Toggle(Mixer);
MoveAGVTank();
Toggle(Conveyor);

Toggle(Mix_Valve);
FillAGVTank();
Toggle(Mix_Valve);
Mixer = 0;

MoveAGVTank();

Toggle(Extract_Pump);
DrainAGVTank();
Toggle(Extract_Pump);

Counter = Counter + 1;
END

END

How do i construct a function to pause the above function??
 
what do you mean with pause ??

you already used the sleepMs function thats a pause and you have the sleep function to pause for seconds.

you can write a controlling function to start and kill the task when you want.


function controlfn()

int hTsk=-1

while true do

if dotask and (htsk = -1) then
hTsk = tasknew("startauto", "", 8)
end

if not dotask and (hTsk <> -1 then
taskkill(hTsk)
hTsk = -1
end

sleep(1);

end
end

hope this helps

Greetz
 
That's not what i wanted, The pause button should temporily stop the StartAuto() until it was pressed again before the StartAuto() resume.

Sorry. I may sound a bit stressed. Cause i need to hand it as a assignment by tomorrow..
 
Last edited:
it is just a variable that says if the task should run or not. it can be anything. a tag, a function, ...

greetz
 
That's not what i wanted, The pause button should temporily stop the StartAuto() until it was pressed again before the StartAuto() resume.

Sorry. I may sound a bit stressed. Cause i need to hand it as a assignment by tomorrow..
 
look at the tasksuspend and taskresume functions they do exacly what you want.

start the task with tasknew to get the handle or use TaskHnd to retrieve the handle of the task.

greetz
 
I new to this....

But i try...

But what is a handle to a task?
 
Last edited:
hello guys,
i need a timer or counter .of course i made it but didn't work that is:

FUNCTION
counter()
[FONT=Courier New (Arabic)][FONT=Courier New (Arabic)]
[/FONT]
[/FONT]IF V21 = v22 THEN
[FONT=Courier New (Arabic)][FONT=Courier New (Arabic)][/FONT][/FONT]V23 = v23+ 1;
END
END
anybody can help me?
 

Similar Topics

Hi every body. I am new here also very new in PLC coding. I need to write ladder code for the following conditions. 1. When you press the button...
Replies
46
Views
9,978
I need help writing a plc lab ladder diagram for class. Can anyone help? Please!!!!!!!! Its a clamp and grind.
Replies
34
Views
6,481
Hi, every body! I have a small project. I wrote programmer control two pump motors by plc s7-300. Now I want to write programmer connect PLC to PC...
Replies
3
Views
5,399
Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
268
Back
Top Bottom