Sign in to follow this  
Followers 0
pszczepan

CX simulator - problem - CXONE 3.0

6 posts in this topic

Hi No Error during compiling I am working on some FB Structured text and when I start CX simulator it goes to stop/program. When I try to switch to monitor I got "Communiction Error" = no connection with CX simulator and process CxCPUmain makes 100% of CPU. If I cut off some parts of code I can test this FB - is there some problem with CX simulator? Could you check if you have the same?? FB_structured_test.cxp Thanks Pawel

Share this post


Link to post
Share on other sites
OK I got it - it is a problem with WHILE DO statement. If the WHILE condition is not meet CX simulator stop connection. Resolved Edited by pszczepan

Share this post


Link to post
Share on other sites
i guess you tried to use the statement same way you would do in a computer software,continuously checking a logic condition, but the iterative instructions in STL needs to handle directly the condition variables within their cycles, otherwise they will hang PLC and/or simulator. It took me a great deal of attempts and the final help from the forum to get the hang of it, although Omron could have been a little clearer in their documentation.

Share this post


Link to post
Share on other sites
I didn't exactly get what you meant, but now I do After some fooling around with a problematic FOR loop. This works in a PLC, but not in the simulator: Month := WORD_BCD_TO_UINT(AND(RTClock_YYMM,16#00FF)); FOR CalcMonth :=1 TO (Month - 1) BY 1 DO TotalMonths := TotalMonths + 1; END_FOR; This works in a PLC and sometimes in the simulator: Month := WORD_BCD_TO_UINT(AND(RTClock_YYMM,16#00FF)); MonthMinus1 := Month - 1; FOR CalcMonth :=1 TO MonthMinus1 BY 1 DO TotalMonths := TotalMonths + 1; END_FOR; This works in both the PLC and the simulator: Month := WORD_BCD_TO_UINT(AND(RTClock_YYMM,16#00FF)); FOR CalcMonth :=1 TO 12 BY 1 DO IF CalcMonth >= Month THEN EXIT; END_IF; TotalMonths := TotalMonths + 1; END_FOR; In my humble opinion, it's bad coding by Omron. If you can't calculate variables in a FOR / WHILE statement, the compiler should error it [edit] Updated with third example. [/edit] Edited by dweste

Share this post


Link to post
Share on other sites
It is not bad coding, but a necessity from the relatively limited hardware resources which the FB compiler is gonna allocate. The following topic sums the question quite nicely and cleanly: recursive instructions in ST FB problem

Share this post


Link to post
Share on other sites
Nope. It's not the same problem. In my FOR loop, the CalcMonth is updated every cycle, so that's no problem. The code runs in a PLC, only the simulator errors. This problem is recognized by Omron, and the guys in Japan are going to fix it. Edited by dweste

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
Sign in to follow this  
Followers 0