NgoHoang

ST Language (Timer)

8 posts in this topic

Dear all!

I'm is new in PLC Mitsu.

Now I'm working with PLC Q03UDV CPU with 1 module Input and 1 module Output. I use ST Language. 

My program is:

              When I press Start_Button, Timer will count. After 5s, Motor will ON.

             When I release Start_Button, Motor will OFF.

          (*=====Program=========================*)

            IF (Start_Button=1) THEN
                  MY_TON(IN:=TRUE,PT:= t#5s);
                  IF(MY_TON.Q=TRUE) THEN
                        Motor:=TRUE;
                 END_IF;
          ELSE
                   Motor:=FALSE;
          END_IF;

         (*=======End==========================*)

 

My Issue:

 - First time, I press Start_Button ===> Ok, release Start_Button ===> Ok.

 - Next time, When I press Start_Button, Motor will ON immediately.

====> Timer not reset, Please help me fix this issue. Thanks alot.

Note: MY_TON is a Function Block, type TON.

Timer.gxw

Share this post


Link to post
Share on other sites

In addition to Motor:=FALSE; you should set the timer low again by adding the following line above or below:
MY_TON(IN:=FALSE);

In other words:
.....
MY_TON(IN:=FALSE);
Motor:=FALSE;
.....

That way you will also reset the timer.

Share this post


Link to post
Share on other sites

Dear!

Thank for your support!

Now OK. Last time I do MY_TON.IN:=FALSE; ==> Incorrect. I must MY_TON(IN:=FALSE); ==> Ok

 

Thanks

Edited by NgoHoang

Share this post


Link to post
Share on other sites

Dear!

With timer as below:

 IF (Start_Button=1) THEN
                  MY_TON(IN:=TRUE,PT:= t#5s);
                  IF(MY_TON.Q=TRUE) THEN
                        Motor:=TRUE;
                 END_IF;
 ELSE

                 MY_TON(IN:=FALSE)
                  Motor:=FALSE;
 END_IF;

 

Motor will be ON after 5s (PT:=t#5s).Now, I want to set value of timer by D0 device and with Milisecond Unit (not directly t#5s). Can you tell me how to do it? I try some way but GX-Work2 not permit.

 

Any way to do this, please talk to me

Edited by NgoHoang

Share this post


Link to post
Share on other sites

You need to first move a value into e.g. D0, then do a "INT_TO_TIME" conversion (search up the instruction) to convert the value into TIME format. The output of this instruction must be assigned a variablename. Then you use that variablename into the PT input of the TON. You start by converting D0 to a TIME format (which is in ms), and then use this variable in the TON.

Something like this will work (syntax not checked):

.....

timeInMs:=INT_TO_TIME(D0);
MY_TON(IN:=TRUE,PT:=timeInMs);

.....

Share this post


Link to post
Share on other sites
Just now, kaare_t said:

You need to first move a value into e.g. D0, then do a "INT_TO_TIME" conversion (search up the instruction) to convert the value into TIME format. The output of this instruction must be assigned a variablename. Then you use that variablename into the PT input of the TON. You start by converting D0 to a TIME format (which is in ms), and then use this variable in the TON.

Something like this will work (syntax not checked):

.....

timeInMs:=INT_TO_TIME(D0);
MY_TON(IN:=TRUE,PT:=timeInMs);

.....

Thanks alot. That is correct.

Can you tell me how to read the detail of Function Block in the Library of GX-Work2?

I research in the internet but no data for it. If you have the link or any document, please send it to me

Thanks and best regard!

Share this post


Link to post
Share on other sites

No problem :-)

For the Q-series, you can press F1 to open help, and search for function blocks there. Or are you looking for something special?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now