TwinCAT Programming

Manoj M

Member
Join Date
Feb 2014
Location
London
Posts
59
Hello Experts
I am trying for a program which increase/decrease value in steps of 1. If the push button is pressed there for less than 1 second the value will be adjusted by a value of 1. if push button is pressed more than 1 second the value will be adjusted by a value of 1 every 0.06 second. if the push button is pressed for more than 4 seconds the value will be adjusted by a value of 1 every 0.015 second.
Any help please

Regards
 
Let me give it a try but as with everything there are a lot of solutions.
This one is in ST and I am refering to normal IEC 61131 blocknames.
Be sure your cycletime is Ok.
This example does not evaluate and correct the value after the press.
So you will always get +1 at click/first second and after that +1 each 60ms between 1s to 4s and after 4s +1 each 15ms.

tTimer(IN:= xTimer,PT:=666s); (* TON *)

ton1(IN:= NOT tof1.Q, PT:=60ms);
tof1(IN:= ton1.q, PT:= 1ms);

ton2(IN:= NOT tof2.Q, PT:=15ms);
tof2(IN:= ton2.Q, PT:=1ms);

R_TRIG(IN:=myButton);
F_TRIG(IN:= myButton);

IF R_TRIG.Q THEN
iCase := 1;
myValue := Myvalue+1;
xTimer := TRUE;
END_IF

IF F_TRIG.Q THEN
iCase := 99;
xTimer := FALSE;
END_IF

CASE iCase Of
1:
IF tTimer.ET >= 1s THEN
iCase := 2;
END_IF

2:
R_TRIG2(IN:=ton1.Q);

IF R_TRIG2.Q THEN myValue := myValue+1; END_IF

IF tTimer.ET >= 4s THEN
iCase := 3;
END_IF

3:
R_TRIG3(IN:=ton2.Q);

IF R_TRIG3.Q THEN myValue := myValue+1; END_IF

END_CASE
 
mr manoj what did you do in the meantime, as we will not make your homework, only correct it and give advice.

if button is pressed you make a rising trigger (in util.lib).
the output will increase a counter with one. (use SEL to switch between 0 and 1)
it will also start 2 timers (TON)
timer1 is set for 1 second
When timer1 is on and timer2 is off, get pulses from puls1 (set to 0.03 seconds
puls1 is a PULS timer also in util.lib (this will run always)
if timer1 is on and timer2 is on then puls2 (another pulstimer set at(ha calculate this yourself)
when you give us an zipped export file of what you made we will answer it.
 
Thanks a lot Mr. Shooter,
But luckily I have made this program before you had posted this post. It is more or less same with some add on features in it. I have a range of 0 to 325 (value), which will change by pressing the push button as I said in my first post. I have added some limiter function so that the value should not jump from the range.
Anyway thanks for your kind help.

Regards
Manoj
 

Similar Topics

Hello everyone: I have been able to read and write data via canopen interface through ADS read and write functional blocks in Twincat PLC...
Replies
9
Views
4,264
Dear Members: I am new at Twincat PLC System. I am working on a project. I have connected CX9020 with a PSI-9750 high voltage power supply via...
Replies
2
Views
1,799
Hello everyone, Lately, I started working around with Beckhoff hardware (CX1010 CPU and a few I/O modules) and got pretty familiar with...
Replies
10
Views
4,511
Hello Experts, It may look very simple to all you experts but for me it is a big hurdle to cross. I have Twincat 2 and Vacon drives which are...
Replies
10
Views
2,887
Hello Experts, I have simple query regarding defining memory bits in Global Variables. In my system I have two drives and CX2020 (Beckhoff). The...
Replies
5
Views
2,020
Back
Top Bottom