CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sun May 19, 2019 7:22 am

All times are UTC+01:00

Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Oct 21, 2011 2:24 pm 

Joined: Thu May 12, 2011 2:00 pm
Posts: 20
Hi Everybody,
I have noticed a very interesting problem in CodeSys 2.3. Actaully I am using CodeSys SP RTE target PCAN PCI. Everything is ok. As I can get all "StatusWORD" signal from my Canopen Node. But problem is like that:

If I have written a very simple program in ST for "CASE... OF" condition , It works only in Simulation mode but when I load it in RTE SP PLC then it build & runs but it does not change the "CASE..OF" State. Case state has no change, it goes only in State 0: as it is first commnad but not State 1 or further. But in simulation , it works fine in all State.


CASE state OF
0: output:=4;
IF inputtime=t#5s THEN state:=State+1; END_IF;
1: output:=5;
IF inputtime=t#10s THEN state:=State+1;END_IF;
2: output:=90;
IF inputtime=t#15s THEN state:=3;END_IF;
3: output:=80;
IF inputtime=t#20s THEN state:=state+1;END_IF;
4: output:=12;
IF inputtime=t#25sTHEN state:=0;END_IF;

But this program is ok in Simulation Mode It change the State from 0 to1, 1 to 2, 2 to 3. 3 to 4.
But when I load this program in CoDesys SP RTE, then It runs but No chage of "state". That means "CASE... of " operation is not working.
I have need suggestion because i have to use this "Case..OF" state ment for CANopen State Machine to take in opeartion.


PostPosted: Tue Oct 25, 2011 4:57 am 
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3283
change the if case to >=...
IF inputtime>=t#5s THEN
then it works

PostPosted: Tue Nov 01, 2011 6:20 pm 
Frequent User
Frequent User

Joined: Thu Jun 14, 2007 9:49 am
Posts: 986
It is because the simulation checks the seconds but if you say time then it is in milliseconds. and as the program takes a few milliseconds to run the time is not exactly same but a little different.
so the solution is good and will work.
same is btw for almost all analog signals you will have to check the bounds.

for this state machine look at
or have a look in SFC here you can do exactly same, as this chart is designed for this type of statemachines.

computer shooter
paul deelen
jacob van wassenaerstraat 29
NL 5224 GG 's-Hertogenbosch
skype shooter paul.deelen
phone +31736139136

Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited