SLC 500 - subroutines and control flow question

hannibalevivo

Member
Join Date
Jan 2008
Location
Salamanca
Posts
15
Hi!

I'm structuring my ladder program in multiple files.
The program "talks" with an IMC 110 motion control module.

For example, I've defined a subroutine to perform the IMC 110 initialization (home operation). If "home operation" bit is true, then I call the subroutine with JSR.

I've thought to make a loop with the instructions JMP and LBL to control the operation in the subroutine until the home position is reached. But I've read It could be dangerous because watchdog timer could time out and fault the controller.

I haven't got much experience with ladder logic, can anyone tell if is possible to perform a control loop into a subroutine?

Thanks in advance.
 
don't do that "loop" idea ... PLCs simply are NOT meant to be programmed that way ...

we can't say for certain without knowing more about your system - but you probably just need to "call" (JSR) ONLY the initialization routine UNTIL the machine is homed ... in other words, try putting everything ELSE into other subroutines and only call them after the "home needed" bit goes off ...

you might also want to look at the TND instruction ... personally I don't like using it to "disable" parts of the program - but some programmers use it for that purpose ... I consider it more of a handy "troubleshooting/debugging" tool than a programming solution - but that's just me ...

best plan of attack: post a rough draft of your program so far ... we'll be glad to take a look at it ...

once again, that "loop" idea is not the way to go ...
 
If you loop & the loop time > than scan time the plc will normally shut down.

The way to do it is set a bit (initialise) that calls the routine, inside the routine have logic that detects home position or whatever & then reset the bit so after finishing the sub the bit will be off.

If you need to stop other areas of code from runnig during this time call them with the not bit.

i.e.

A xxxx (trigger for position or home etc.)

Latch "BIT"

AND "BIT"

JSR My routine

In the routine

Process the logic

.....

.....

A "Home Pos" (

Unlatch "BIT"
 
Thanks a lot for your replies.

I have something like this in the main file (file number 2) for the moment.

IF "home bit enabled" THEN
"start home operation"
DO
"enable jog- bit" with OTL
UNTIL "home position is reached" OR "cancel_op bit is enabled"
"disable jog- bit" with OTU

I do something like this with other kinds of movements.
I'd like to organize the ladder program in multiple files using subroutines.

Thanks in advance.
 
I think you are confusing people with the do until statement.
A do until or "loop" statement suggests you wait until at home position, this would possibly crash the plc on watchdog, I assume you mean every scan you check that at home position & do not process othe routines until home has been acheived.
PLc's do not like loops that could cause the plc to run in a loop as most plc's re;y on updating the I/O images at the begining or end of progam scan, if kept in a loop, the I/O would not update so you would not read the home sensor or turn on (or off) outputs.
I have also come across some really bad code where outputs have been set in routines that stop being processed, this is bad practice as it is difficult to monitor outputs online where they are set in one routine, reset in others but the routines are conditionaly called.
The best solution is to use flags in the routines & drive the outputs in a routine that is scanned constantly.
 
Yes, you're right. I don't wait until home position is reached.
I check current position every scan.

scan i:

rung j:
IF "home op. requested", THEN some operations AND enable B3:1/1
rung j+1:
IF B3:1/1, THEN enable "jog- bit"
rung j+2:
IF B3:1/1 AND ("home position is reached" OR "cancel op. bit is enabled")
THEN disable "jog- bit" AND diable B3:1/1

I've other types of movements and other operations in only one file. I think the number of rungs is excessive. My idea is organize the code using subroutines. For example, one subroutine for each type of movement.

Thanks
 

Similar Topics

I have a program that I've used 100 times. SQO settings: File N7:0, Mask 0FFFFh, Dest B3:1, Control R6:0, Length 8, Pos 2. Length & Position...
Replies
48
Views
957
Everyone, i am in the process of purchasing the Slc 500 version of software to support what we have and i have a question. Several of our...
Replies
9
Views
766
In a slc 500 plc I am trying to move data with out using a lot of moves. I want to move data from n7:1 to n7:2 and data that was in n7:2 to n7:3...
Replies
16
Views
1,355
Customer has a circa 2004 SLC-500 PLC. Fieldbus is a 1747-SDN DeviceNet scanner. Customer has SLC-500 file (.rss) with no comments. Has no *.dnt...
Replies
7
Views
553
After I tried wiring, I used computer program communication to read the PLC N value, but received a NAK signal. And the DL3500 CHA light keeps...
Replies
0
Views
424
Back
Top Bottom