First will be on rotating object, what code to use to rotate object in the program.
Second will be after opening door on my program (value to 30) and try to close back the door (change value to 0).
Below is my code for open and close door.
TON1(IN :=train1, PT:=T#18s);OUT1:=TON1.Q;
  IFOUT1ANDdoor1<=30THEN
    door1:=door1+1;
  END_IF
  IFdoor1>=30THEN
    train2:=1;
  END_IFTON2(IN :=train2, PT:=T#5s);
 OUT2:=TON2.Q;
    IFOUT2ANDcounter<=30THEN
    counter:=counter+1;
    END_IF
    IFOUT2ANDdoor1>=0THEN
      door1:=door1+-counter;
    END_IF
Thanks in advance for helping.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm totally new to Codesys and need help for my problems.
Thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-10-19
Originally created by: scott_cunningham
Not sure what you mean by , but looking at your code, I think you are using the timer functions incorrectly. Maybe this information helps you:
The way TON() works, is when setting IN = TRUE, the timer starts and Q will go TRUE after PT is reached. Q stays TRUE until you disable (IN = FALSE) one time for TON().
For example, if you want a every 10 seconds, you would need to do:
TON1(IN:=TRUE, PT:=T#10S);IFTON1.QTHEN
  TON1(IN:=FALSE);
  count :=count+1;END_IF
I often do:
TON1(IN:=NOT(TON1.Q), PT:=T#10S);IFTON1.QTHEN
  count :=count+1;END_IF
NOTE: Even if you have an exact PLC scan, this timer is not exactly 10 seconds - it is a little longer - you loose at least one scan inside the TON() function as it is starting (this means, if you want a tick exactly every 10 seconds, you need to check the realtime clock and work that way).
Hopefully, this helps you work forward.
Also, remember you can set a break and step through your code in a debug way to see what is happening.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
on some objects you can change the angle like a polygone and others, a line and rectangle is not having the angle.
a way to do this by making a subvis from single line.
for the change use a counter for each door apart, and a global pulsemaker.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Expert,
I got some problem on my code.
First will be on rotating object, what code to use to rotate object in the program.
Second will be after opening door on my program (value to 30) and try to close back the door (change value to 0).
Below is my code for open and close door.
Thanks in advance for helping.
Hi, any expert can help me?
I'm totally new to Codesys and need help for my problems.
Thanks in advance.
Originally created by: scott_cunningham
Not sure what you mean by , but looking at your code, I think you are using the timer functions incorrectly. Maybe this information helps you:
The way TON() works, is when setting IN = TRUE, the timer starts and Q will go TRUE after PT is reached. Q stays TRUE until you disable (IN = FALSE) one time for TON().
For example, if you want a every 10 seconds, you would need to do:
I often do:
NOTE: Even if you have an exact PLC scan, this timer is not exactly 10 seconds - it is a little longer - you loose at least one scan inside the TON() function as it is starting (this means, if you want a tick exactly every 10 seconds, you need to check the realtime clock and work that way).
Hopefully, this helps you work forward.
Also, remember you can set a break and step through your code in a debug way to see what is happening.
on some objects you can change the angle like a polygone and others, a line and rectangle is not having the angle.
a way to do this by making a subvis from single line.
for the change use a counter for each door apart, and a global pulsemaker.
Thanks guys for your inputs. I will work on my program and see how it goes.
after 18 seconds the door will close fast, as you count then rapid up.