jthyge

SCL Code not working.

4 posts in this topic

Hello, 

I am new to SCL programming in TIA Portal. 

I have some experience in TwinCat3, but i have  difficulties getting som simpelt code to work in TIA. 

This code works fine in TwinCat, but i does not work in TIA. 

"Timer".TOF(IN:=NOT "Timer".Q, PT:=T#2s); 

"TimerOneShot"(CLK := "Timer".Q);

IF "TimerOneShot".Q THEN
    "Test" := "Test" + 1;
END_IF;

Can anyone help me in the right track.... ?? 

Share this post


Link to post
Share on other sites

Hi jthyge.

Firstly, welcome to the forum.

If you have entered this as an SCL Source, the compiler will tell you where the errors are when you go to compile.

Dont forget that- you need to declare what type of block you are creating (UDT, FB, FC, DB) with the necessary Symbolic Name. This decleration needs to be at the beginning of your source code.

 

Regards

Daniel

Edited by collinsd70

Share this post


Link to post
Share on other sites

Hi collinds70

Thanks for your reply. 

Maybe i did not explain the problem correct. 

The code is working fine, but the function is not working. Maybe the Timer or R_Trig works differently in TIA than TwinCat?

When I test the timer it works, when I test the oneshot i works fine. But they do not work i combination. 
 

I want the "Test" to increase by 1, every 2 second. 

It is a bit frustrating that I can not get simple things like this to work i TIA, when it is no problem i TwinCat... :-)

Share this post


Link to post
Share on other sites

OK

Apparently the timers in TwinCat and Siemens work different. 

In Siemens the timers run in a DB. So if the timer resets itself, the FB code will not catch the output on a scan. 

So if I use the TimerOneShot.Q to reset til timer i will work fine.

Best regards

Jesper  

Edited by jthyge

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