Having Subroutine Problems

briceveinot

Member
Join Date
Mar 2004
Location
Nova Scotia
Posts
2
i am having a problem with a question i was given to to. i have to have a subroutine that it will loop itself 5 times and then stop. i had it working with a SQO, TON and CTU but i was told that either my TON or CTU has to be in the main ladder file. so i tried and tried and tried again, adding XIC's and XIO's and haven't been able to figure out how to get them to make the SQO continue through for the 5 times. if you could let me know how to make it work, by putting what where and which bits to use, it would be greatly appreciated.

Brice Veinot
Technology Services
 
Have you tried using the NC CTU done bit in the rung that the SQO is located in? I would then have some bit located with in the subroutine increment the CTU. When the Done Bit goes on the NC contact will open up and stop the SUbroutine from running again until you reset the CTU.
 
Brice,

I’m not exactly sure that I know what you mean when you say that you want a “subroutine that will loop itself 5 times and then stop.” ... take a look at this:

recent post on recursive loops

if this doesn’t answer all of your questions, please post again and give us some more details on exactly what you’re trying to get accomplished ... and please tell us what type of processor you’re working with ... I’m assuming it’s an Allen-Bradley ... PLC-5/40? ... SLC-5/04? ... MicroLogix 1200? ... etc. ... etc. ...

if this doesn’t do it, don’t give up ... I’m sure we can come up with something that will ... but I’m afraid we’re going to need some more details to work with ...
 
More Details

ok, i am working with an Allen-Bradley PLC-5/15 and i am running it with RSLogix in windows. they need me to re-program the emergency lighting and fire alarm system to that it goes through 5 times and then shuts off and then keeps them on constant. i have the constant worked out, that was easy but i can't get it to sequence the way i want. i have a TON and the SBR in the main ladder and in the subroutine i have the CTU and SQO. i need to figure out which bits i need where to make the TON time and then increment the CTU and then each time the CTU counts up i need it to trip the SQO. If this information has helped please reply quickly as i need to have the system running and tested my the weekend.

Thank You,

Brice Veinot
Technology Services
 
I am not sure if this will work. I don't have a PLC5/15

Try 5 JSR instructions in main ladder calling the same subroutine one after the other

Mickey
 
This sounds like a straightforward counter application to me. I'm not sure why you're trying to make it a subroutine issue. Set up a counter with a preset of 5. If the counter's DN bit is false, take one course of action; if the DN bit is TRUE take the other course of action.
 
Brice sent me a PM

Just got this PM.

i have to use a subroutine, just due to the fact it makes it easier to control the lights and alarm systems all through out the building.

By all means, use a subroutine. Just make the subroutine call unconditional. Then your counter can be in the subroutine or external to it. Think of the subroutine as more of a bookkeeping tool.

When you start to talk about “subroutine that will loop itself 5 times and then stop.”, it's a tipoff that you're trying to make the PLC ladder logic program behave like a C or VB program. That's usually a prescription for frustration.
 
i have to use a subroutine, just due to the fact it makes it easier to control the lights and alarm systems all through out the building.

Brice,

the attached program should do what you’ve been describing ... basically if you push the start button you’ll get five passes (scans) through the subroutine ... release the button and then press it again and you’ll get another five passes ...

suggestion: watch the value in F8:0 every time you press the start button ... it will advance by five each time ...

sorry I’m short on time ... I’ll post more later if work allows ...

PS edit ... I just took a quick look at what Operaghost posted ... I've got a hunch that his answer is a lot closer to what you NEED ... even though mine is closer to what you ASKED FOR ... the problem with what you're asking for is that the five passes through the subroutine are going to happen VERY fast ... in other words, the "alarms" you're trying to sequence are going to go by so quickly that no one will be able to see them ...

if you still need help, here's a suggestion: instead of telling us how you HAVE to write the program, just tell us what the program is supposed to do ... describe the inputs ... describe the outputs ... tell us what the outputs have to do in order to satisfy your bosses requirements ... if you'll put enough detail into your description, then I just know in my heart of hearts that we can come up with something to make it work ... once you've got it working and the boss is off your back, then you COULD always go back later and change it to whatever programming method you desire ... (but I'm betting that you won't want to change it) ...
 
Last edited:

Similar Topics

I have an Allen Bradley temperature switch that I am trying to use in studio 5000. I am getting the message "Unable to interpret the IODD file"...
Replies
0
Views
62
I copied a panel in factory talk HMI for an identical system. The label names are still the same as the original panel but I am trying to change...
Replies
1
Views
129
Hi All, Firstly… Merry Christmas to all of you! Secondly, as some of you may have noticed I made some modifications to our backend to address...
Replies
29
Views
7,078
Hi Everyone, I am supporting a system which runs on a SLC 500 (1747-L532). A fault has developed whereby the output state of some digital outputs...
Replies
10
Views
996
EDIT: I suppose i should mention, RSLogix 500 V8.40, SLC 5/04 (1747-L542C) Is there is a way to use the FFL instruction in a way that doesn't...
Replies
4
Views
864
Back
Top Bottom