You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old February 5th, 2018, 03:04 PM   #1
ce_ht
Member
United Kingdom

ce_ht is offline
 
Join Date: Nov 2017
Location: Derby
Posts: 6
PC Worx Express - While/Repeat Loops

Hi, I am currently programming a Phoenix Contact PLC using PC Worx Express. The software and PLC programming in general are still fairly new to me.

I have got the PLC doing what I want it to do by using mainly IF statements but I am having some trouble with loops. I keep getting watchdog errors even when running simple loops, for example I am trying to run the following;

WHILE Global_Reset = FALSE DO
Red_Lamp :=TRUE;
END_WHILE;

I have a number of outputs and counters I want to reset using the global reset input but even with the simple function above I am having no luck.
Thanks for any help
  Reply With Quote
Old February 5th, 2018, 03:18 PM   #2
Engineer_MG
Member
United States

Engineer_MG is offline
 
Engineer_MG's Avatar
 
Join Date: Mar 2012
Location: USA
Posts: 74
Hi,

The code should be
IF Global_Reset = FALSE THEN
RED_Lamp := TRUE;
ELSE
RED_Lamp := FALSE;
END_IF

You would use WHILE/FOR loops specifically for repeating a piece code for n no. of times and then EXIT. Your code is stuck in the WHILE loop infinitely and hence you get a watchdog. (You could put an EXIT after RED_Lamp := TRUE and then it would work) but again use a Loop when you really need to. For your specific code above IF THEN ELSE is sufficient.

Hope this helps.
Thanks.
__________________
Ms. Engineer_MG
Senior Application Design Engineer
Schneider Electric , USA

Last edited by Engineer_MG; February 5th, 2018 at 03:20 PM.
  Reply With Quote
Old February 5th, 2018, 04:35 PM   #3
ce_ht
Member
United Kingdom

ce_ht is offline
 
Join Date: Nov 2017
Location: Derby
Posts: 6
Thanks for clearing that up, much appreciated!
  Reply With Quote
Old February 6th, 2018, 12:51 PM   #4
Mara
Member
Finland

Mara is offline
 
Join Date: Jan 2017
Location: Finland
Posts: 55
Or you can do it more simple:

RED_Lamp:= NOT Global_Reset ;

There's no need to use IF instruction at all
  Reply With Quote
Old February 8th, 2018, 10:43 AM   #5
Engineer_MG
Member
United States

Engineer_MG is offline
 
Engineer_MG's Avatar
 
Join Date: Mar 2012
Location: USA
Posts: 74
Agreed for simple boolean logic.
__________________
Ms. Engineer_MG
Senior Application Design Engineer
Schneider Electric , USA
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Using Siemens CP1613 in a common PC Anie LIVE PLC Questions And Answers 6 April 21st, 2015 07:30 AM
Desktop pc to AB industrial pc with RSLogix? NLittler LIVE PLC Questions And Answers 7 April 5th, 2006 09:42 AM
RSLogix 5 Trend Problem, can't see trend on another PC harryting LIVE PLC Questions And Answers 1 December 17th, 2005 12:41 AM
Setting up CP 343-1 card (siemens) Johnny T LIVE PLC Questions And Answers 35 August 19th, 2005 07:58 AM
migration to new PC paulB LIVE PLC Questions And Answers 2 September 26th, 2003 12:58 PM


All times are GMT -5. The time now is 05:04 PM.


.