Help with message command

kevinplc

Member
Join Date
Feb 2009
Location
toronto
Posts
4
I am making a elevator and have all the code writen for it but i cant seem to get the jsr routine to work. all i want is to jump to the below program from my main routine only once when i plug my micrologix1000 controller in and then complete the subroutine and then jump back. I want everything in the subroutine to happen before i jump back. The subroutine is to position the elevator in a spot that is preselected when the controlled is started/pluged into outlet. I was thinking of using the first scan bit s1/15 to activate the jsr command. All help is much appreciated. Thanks in advance.:site:

 
Kevin,

I see several questions that need answering, and also some future problems.

1. Possibly you are trying to do too much in one subroutine. Perhaps it would work better to first establish which direction the elvator is going to go, then jump to a subroutine that performs either an UP or DOWN, but not both.

2. What is there that says the Subroutine is "Done"? It appears that you are moving EITHER up or down within the SAME subroutine. So are you DONE when the elevator is EITHER all the way up or all the way down? If so, then you can use the Top Sensor I:0/3 to trigger a Return instruction (when elvator is UP). Apparently you do not have a bottom sensor, so have created a counter and bit B3:5 to indicate the Down Position. So use B3:5 to trigger a Return (when elevator is DOWN).

 
| I:0/3 |
| Top Sensor +-RET-----+ |
|--+--| |------+--+ +--|
| | | + Return + |
| | B3:5 | +---------+ |
| | Down Pos. | |
| +--| |------+ |



3. The counter should be used to track the elevator position in BOTH up and down directions. Simply add a rung with a CTD that is activated when the elevator is going up. I would switch your logic, and use Count Up when elevator is going up, and Count Down when elevator is going down. Then when C5:ACC = 0, elevator is all the way down, and when C5:ACC = 5, elevator is all the way up.
 
Perhaps there is also a misunderstaning about what a subroutine and the jsr does.

Remember that a subroutine does not run instead of the main routine, in runs in addition to the main routine. This means that the processor begins with LAD2 rung #0 then at some point within LAD2 it jumps to LAD6. It scans LAD6 one time only and then automatically returns to complete LAD2. The processor does not stay in LAD6 until something completes. As Lancie suggests break your up and down into two logical subroutines and use LAD2 to decide which one (or neither) should run in addition to LAD2.

OG
 
OG, good point.

It would be better to use the "Done" conditions to inhibit or prevent the calling of the Subroutine in the main program (lock out the JSR) until an UP or DOWN movement is again needed.
 

Similar Topics

Thanks for any help! I can usually figure these out, but after an hour of misses I don't have any more tricks up my sleeve. I've read some great...
Replies
1
Views
1,327
Having trouble getting a message working. Searched here but didn't find what I was needing. Locally connected controllers on the same subnet and...
Replies
3
Views
1,962
When you are compiling (translating in Red Lion parlance) user defined programs - what does "Unexpected End-of-Text" error mean? It is at the END...
Replies
3
Views
1,802
I need some help understnading an error message I'm getting when testing an application. data table I1:1-I1:13 in slc at station 1 serial-DF1 is...
Replies
5
Views
3,360
Back
Top Bottom