It's what he's asking for....
You certainly are doing things the hard way, but I'll try to help you accomplish what you say you are doing, rather than what you should be doing.
A) You are using the LBL-JMP instructions as a Basic/C For-Next loop. You want loop through the Count / Shift code 4 times to get the 10's bits into the 1's place, the 100's into the 10's, etc.
This is a guess, and I shouldn't have to guess. Please try to post a clearer explanation of what you are trying to accomplish.
2) When a CTU (as well as a BSR) instruction have a False-to-True transition, it "does it's thing" (namely incrementing the .ACC value and checking to see if the .DN should be set). But it only does it on the FIRST INSTANCE of the rung being True. For as long as it reamins True, the CTU instruction will "know" that it has "done it's thing", and so won't do it again until the rung first goes to False, and then back to True.
iii) When you loop, you are most likely (since this is the usual beginner's mistake) not providing any way for the rung to go False, therefore the counter won't increment, therefore the counter is never done, therefore you keep looping, until the watchdog timer times out.
Does this describe the problem you are having?
There are several potential solutions:
d) The way that the CTU instruction "knows" that this is the scan that has the False-to-True transition is via the "enable" bit (/EN). It the CTU wasn't previously enabled but the rung condition is True, this must be the time to "do it's thing", and so it increments the .ACC, and sets the /EN bit. If you were to unlatch (OTU) the /EN bit, you effectively make the CTU instruction think that it didn't do anything last scan, when in fact, it did.
V) Another method is to introduce another condition like "Add performed last loop" which would be wind up toggling ON-OFF-ON-OFF each time you went through the loop.
6. Or you could just bag the counter and use the ADD instruction instead. The ADD will increment every scan when the rung is True. But then again, there are better instrucitons for what you are trying to accomplish anyway (such as FRD-DIV-TOD).
Of course, once you get it working, you'll have to make sure that it
doesn't work, otherwise the BCD numbers are just going to scroll right off the display (in about 100 msec). But that's a different issue.
<hr>
To post ladder, first put the vB tags
[LADDER ] and
[/LADDER ], and then draw the rungs in ASCII using dashes, 'pipe' symbols ('|') or whatever. Like this:
2b ?
---+---| |---+------( )
| |
| 2b |
+---|/|---+
.