Help!!! Need to write a pause cicode function

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..
 
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
 
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...
46
Replies
13,783
Views
I need help writing a plc lab ladder diagram for class. Can anyone help? Please!!!!!!!! Its a clamp and grind.
34
Replies
9,002
Views
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...
3
Replies
6,274
Views
Good day, experts! I am a fresh grad service engineer and I encounter a problem while uploading an existing program, it says I need...
0
Replies
128
Views
Hi everyone, I have an old Modicon PLC program saved as an .FMD file, which was created using FasTrak PLC WorkShop for Modicon. I can open the...
1
Replies
188
Views
Top