CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Mon Jun 26, 2017 1:14 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 
Offline

Joined: Thu May 12, 2011 2:00 pm
Posts: 20
Hi Everybody,
Hi,
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.

calltimer;
inputtime:=calltimer.timeroutput;

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;
END_CASE;


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.

Thanks
Asif


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

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


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

Joined: Thu Jun 14, 2007 9:49 am
Posts: 974
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 www.oscat.de
or have a look in SFC here you can do exactly same, as this chart is designed for this type of statemachines.

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


Top
   
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