Jump to content

Recommended Posts

Good day, please i have been having problem with a program am writing just because i believe it too long so i split it into subroutine but still not working. i checked and followed examples on the program but trying to use it on mine but still not working. Please i need someone to enlighten me on this subroutine, making call and returning to the initial program.

Thanks

Share this post


Link to post
Share on other sites
3 hours ago, alagbawale said:

still not working.

This doesn't actually describe the problem.  Your post reads as if the program didn't work, so you split it up and it still doesn't work. We need to know what is not working in order to offer advice. 

cheers, Aus

Share this post


Link to post
Share on other sites

1) If you want "main display" at startup, rename the default "Start-Up Display" to "main display" and use that. Don't use SB 2 for your start-up display.
2) Do NOT have conditional subroutine calls. It is poor programming practice and will likely cause logic issues because coils will be left in limbo.
3) Do not place coils in the same ladder rung after a subroutine call. Place the coil at the end of the subroutine itself.
4) You're using MLs for numbers that shouldn't exceed 1000 (percentages). Not harmful, but why?
5) Do NOT do conditional returns in a subroutine! That is asking for a Watchdog Timer error.
6) Avoid using GoTos. This is poor programming practice in nearly all programming languages, but especially so in PLC Ladder Logic.

These are just the immediate problems I see. I haven't attempted to evaluate the logic.

  • Upvote 1

Share this post


Link to post
Share on other sites

Truly all said is write and its what is giving me challenges.

what is the way out?

how is it meant to be arranged?

what is the basics behind this?

for the MLs, what is advisable to be used?

Share this post


Link to post
Share on other sites

Get some training. Unitronics has an entire Youtube channel. There are numerous example projects that came with your VisiLogic installation. Study them. Read the Help file that came with VisiLogic.

Think of ladder logic as one continuous series of instructions executed from top to bottom and endlessly repeating. Ladder Logic is not like regular computer programming where you are executing some instructions and go off to do a subroutine from time-to-time when conditions present themselves. Subroutines in Ladder Logic are to break up the code into manageable chunks for easy readability, but all of them should be executed on every scan. The Main Routine should merely be all the Power-Up conditions and then each subroutine is called in the order you want to execute them. Nothing else there.

Regarding the MLs. An ML is a 32-bit signed integer. The range of values is −2,147,483,648 to 2,147,483,647. An MI is a 16-bit signed integer. Its range of values is -32768 to 32767. Like I said it's okay to use an ML when only an MI is needed - I just wondered why.

One technique to help avoid the need for conditional subroutines is called the "State Machine". Our resident super genius, Joe Tauser has kindly written an example for us to learn from:

 

Share this post


Link to post
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...