mike_cheesehead

How to do timers in sysmac studio

6 posts in this topic

Hi there, 

because of the delivery problems with Omron CJ series , I am converting programs to the Omron NJ series. But that means going from CX programmer to sysmac studio. I will spare you the cruse words about what i think of studio. Anyway my problem is with timers , under CX programmer you have the TIM(x)  functions I cant find them under sysmac studio . under programmer i could use D words in BCD to write a value to a timer making it flexible. ( The speed of the machine has impact on my set time so that is why the time has to be dynamic)   

Timer functions under Sysmac studio use UINT.  That is not a problem i convert the calculations and changed my varible to UINT. But when i use global varible in the timer fuction, it is not happy. can some one point me the way to make a variable timer in sysmac studio? 

 

Share this post


Link to post
Share on other sites

Assigning a variable (global or local) to the PT input makes the timer variable. I tested local and global variables on all fields of the TIMER function and had no issues. Can you share the compilation error it gives you?

Share this post


Link to post
Share on other sites

thank you for the reply . my error is 

Error    1    The input parameter can not be omitted for an in-out variable.    Program1 film_regeling    Row 1

On the PT poort i have variable D52 . Its a UINT global variable . And on the Q i have a Bool global variable  

I tryed a static number  like the example  UINT#10 for the PT  but it gives the same error so i ecpect im doing something wrong.. i found a work around do using a TON or TOF but 

i cant post screenshots yet. but any way  in STL it reads like this

tmpLintVar:=msIntVar*LINT#1000000;
msTimeVar:=NanoSecToTime9tmpLintVar);
TON_instance(In:Trigger, PT:msTimeVar, Q=>Tout);
 
Basicly a calculation I multiply my variable with nano seconds then a conversion block NanoSecToTime to create a variable i can use as a time 
this variable i can use for the PT  for a Ton/Toff . what a work a round. 

Share this post


Link to post
Share on other sites

Looks like your variable is in ms.

You could save yourself the extra variable and just use one line of code for the TON:

TON_instance(In:=Trigger, PT:=NanoSecToTime(msIntVar * TO_ULINT(EXPT(10,6))), Q=>Tout);

 

Or if you want to use the 100ms timer then you should be able to use:

Timer(In:=Trigger, PT:=msIntVar, TimerDat:=ThisTimer, Q=>Tout);

You would have to create the extra variable ThisTimer  AS _sTimer (system structure).

Share this post


Link to post
Share on other sites

thanks for the reply yes i could it like that.

this also fixed the problem with the timer function why it was spitting errors . Like you said you need to define a local varibale for data. I did not do that because in so many other programs in cx ,  siemens and many other programs . this data is not acceseble and the program does that for you. And i do not know why the F this program doesnt do that for you ... Now i know im using the timer function in my program.

Again thanks for the help 

Share this post


Link to post
Share on other sites
7 hours ago, mike_cheesehead said:

thanks for the reply yes i could it like that.

this also fixed the problem with the timer function why it was spitting errors . Like you said you need to define a local varibale for data. I did not do that because in so many other programs in cx ,  siemens and many other programs . this data is not acceseble and the program does that for you. And i do not know why the F this program doesnt do that for you ... Now i know im using the timer function in my program.

Again thanks for the help 

Defining a variable for an instruction is par for the course on tag-based PLCs. This is not Omron-specific.

1 person likes this

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