Jump to content

Newbie question - Subroutine default return


Recommended Posts

Greeting all,

There is a "default return" placed by the VisiLogic software in every subroutine that cannot be deleted. This return then only allows the sub to run for 1 scan before returning. I need to stay in the sub and wait for an input before returning. I have tried placing a loop ahead of this return but that results in a watchdog error.

I am sure that there is a common method of dealing with this or my thinking is not in line with the way the software is supposed to work. Any advise is greatly appreciated. A screenshot is attached.

Thank you

Link to comment
Share on other sites

  • MVP 2023

A PLC scan can not be stopped by design. That's the reason for the watchdog, and the main difference between a PLC program and a computer program.

Here's how the scan works:

1. Read inputs

2. Solve logic, read/write internal memory as needed

3. Write outputs

4. Service COM port and do general housekeeping

5. Repeat

As you can see, if the input wasn't on when the logic started and you try to use an input to hold the return, the inputs won't be scanned again and your program will barf. Not having seen the program, I don't know what you're trying to do. You may want to put the logic that depends on this input into a subroutine and call that subroutine from the main on a positive transition of the input.

Joe T.

Link to comment
Share on other sites

Thank you for the response Joe,

I was not anticipating stopping the scan but simply only scanning that subroutine until the inputs directed the return out of it. I see that my fundemental thinking is not correct so I need to hit the drawing board with this new knowledge!!

Thank you again Joe for the help

Rich Honchen

A PLC scan can not be stopped by design. That's the reason for the watchdog, and the main difference between a PLC program and a computer program.

Here's how the scan works:

1. Read inputs

2. Solve logic, read/write internal memory as needed

3. Write outputs

4. Service COM port and do general housekeeping

5. Repeat

As you can see, if the input wasn't on when the logic started and you try to use an input to hold the return, the inputs won't be scanned again and your program will barf. Not having seen the program, I don't know what you're trying to do. You may want to put the logic that depends on this input into a subroutine and call that subroutine from the main on a positive transition of the input.

Joe T.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...