Subroutine

PERSPOLIS

Member
Join Date
Jun 2002
Location
ontario
Posts
295
HI ALLEN NELSON

REGARDS TO SUBROUTINE WHICH WAS POSTED BY METZ DATED NOV 15TH 2002 CAN YOU GIVE ME A SIMPLE EXAMPLE MAY BE A COUPLE OF RUNGS TO UNDERSTAND IT FULLY
MANY THANKS
 
I am not Allen but I have some suggestions, if you want samples, suggestions or advice pertaining to a subject especially one that was a thread here then post a link to that thread.

Allen is one of the best but he is not the only one here that may offer examples if they know what subject you are refering too.

I also suggest you learn where the caps lock key is and turn off the caps. I am probably as close to blind as anyone here can be and the caps PLUS the LONG sentences are bad form.

Just like working with PLC's when writing you must THINK about what you are doing and take your time to properly phrase and use proper form.
 
Thanks for covering for me, Ron. I've been trying to ween myself off this site (someone gave me a LIFE for Christmas, and I've been trying to figure out how to use it).

PERSPOLIS:

I assume that this is the link you are referring to:
http://www.plctalk.net/qanda/showthread.php?s=&postid=9086

First, just to explain a little further for you what Metz's problem was. He had code that looked something like this:

 

If the ANALOG signal is out of Range (1 to 5 V), go to a subroutine (3)

ANALOG 5
---+-----| > |---+-----( SUB 3 )
| |
| ANALOG 1 |
+-----| < |---+


This is subroutine 3

BLINK ACKNOWLEDGED ALARM_LIGHT
----| |------|/|-------+-------( )
|
ACKNOWLEDGED |
-------------| |-------+



.

What would happen is that when the ANALOG was out of range, the light would turn ON (I''ve left off lots of needed code in my example), but if the ANALOG were to come back within range, the subroutine would no longer be called, and the ALARM_LIGHT would stay in it's last scanned condition, leaving it ON, even though the alarm condition (out of range) had cleared.

Metz desired to have the ALARM_LIGHT acknowledge itself (i.e., turn OFF) if the alarm condition cleared.

I suggested three possible solutions. The first was to move the ALARM_LIGHT coil out of the subroutine so that it would always be scanned, and thereby always be under program control (the program can't control a rung that it doesn't scan).

A second solution is to alter the subroutine logic so that is calls the routine on both an out-of-range, OR when the light is on.

  

ANALOG 5
---+-----| > |---+-----( SUB 3 )
| |
| ANALOG 1 |
+-----| < |---+
| |
| ALARM_LIGHT |
+----| |------+



.
Logic would have to be added to the ALARM_LIGHT rung to only have it ON when the ANALOG was out of range.

A third solution is to have a new subroutine (4) which will be called up when the ANALOG is NOT out-of-range. This subroutine would also drive the ALARM_LIGHT coil. This would mean that ALARM_LIGHT would be "double coiled", which some PLCs won't let you do. But from a PLC scan standpoint, only one instance of the ALARM_LIGHT coil. It's not a very good solution to the problem, but it helps illustrate the main point: if a subroutine isn't scanned, the outputs stay in the same state as they were last in, unless controlled by something else.

 
This rung is added to the Main program
If the ANALOG signal is IN Range (1 to 5 V), go to a subroutine (4)

ANALOG 1 ANALOG 5
--------| >= |--------| =< |------( SUB 4 )



This is subroutine 4

ALWAYS_OFF ALWAYS_OFF ALARM_LIGHT
----| |----------|/|-------------( )



.

Does that clear things up?

BTW: Check you Private Messages. There's a reply from me from 2 weeks ago that, according to tracking, you haven't read yet.
 
Last edited:
SUBROUTINE

Hi Allen

Thanks for your detailed description and I also read the unread message .
Much appreciated
perspolis
 
I think you forgot the code and /code thing
Code:
      ANALOG 5 
---+-----| > |---+-----(Out Range)--- 
   |             | 
   |  ANALOG 1   | 
   +-----| < |---+ 


Out Range                     Sub 3 
----| |-+----------------------( )----- 
        | 
        | 
    ACK | 
        | 
----| |-+ 

==================== SUB 3 =============== 

Out Range    Blink            Lite 
----| |---+---| |---+----------( )----- 
          |         | 
          |         | 
          |         | 
          |   ACK   | 
          +---| |---+ 


Out Range    Ack_PB            ACK 
----| |---+---| |---+----------( )----- 
          |         | 
          |         | 
          |         | 
          |   ACK   | 
          +---| |---+ 

==================== SUB 3 ===============
 

Similar Topics

I have a bender table that I am automating. I have added a Kinco HMI and PLC, I am also using an Omron encoder sensing the rotation of the table...
Replies
49
Views
9,297
See image below. Look at line 95. I tested all data type, but none of them works. https://ibb.co/H2Csr15 See this. TEMPDATA2 is used only...
Replies
3
Views
2,705
With RS5000 and a Clogix, I would like to know if i can work with same coils adresse on 2 different subroutine and just call one at the time? I...
Replies
13
Views
3,135
When the subroutine is no longer being called, and then called up again, what happens with one-shots in that subroutine? I have some rungs in...
Replies
12
Views
3,049
Hi Friends How can I create/Call in a subroutine in GXWork3/GXworks2?
Replies
4
Views
1,567
Back
Top Bottom