ML1000 trying to compress program?

timbo_uk

Member
Join Date
Nov 2005
Location
Bradford, UK
Posts
336
Hi,

Compress is probably the wrong word. But basically my program has only left me with 24 instruction words to play with. I need to add another function, but reckon Ill need double this.

At the moment there is no fancy programming. It is written so any idoit could follow.

One of my sections is ripe for tidying up (attached pdf).

It consists of multiple rungs checking counters against Integer values, and updating integer value if timer or counter is higher than the current value. Probably clearer just looking at the pdf!)

I know I could do it using a counter looping and incrementing the locations; but cannot get my head round how to do it.

I dont want it done for me, but could some of you clever people point me in the right direction?

Heres hoping

(Added RSS after Rons Post Below)
 
Last edited:
your PDF attachment didn't make it ... any chance that you can post the .RSS file instead? ... that's usually a LOT easier for us to work with ... we might be able to recommend some memory-saving techniques ...

edit update: ok ... the PDF just made it ... quick question: why did you SKIP certain timer addresses? ... if those could be made sequential, (specifically, 1-2-3-4-etc.) then we might be able to use the S:24 index register as an "offset" in a looping routine ... don't have time to explain it right now but I'm sure someone else can help you out ...

specific issue: the MicroLogix1000 doesn't support regular Indirect Addressing (with “[]” square brackets) - but using S:24 as the “file offset” (with the “#” symbol) should provide a workaround ...

disclaimer: haven't tried anything like this lately ... but I'd bet (pocket change only) that it could be made to work ... might need a little debugging ... wish I had more time to play ...
incidentally, this will probably NOT be as easy for everyone else to understand ...
 
Last edited:
here's a screen shot that might help ...

offset.JPG
 
In Ladder 10, if you remove all the MOV's for reset timers and use one file fill (FLL) with a length of 10 starting at N7:11, you will have 54 words to play with instead of 24.

If you do the same thing with the MOV's for reset counters, starting at N7:33 length of 10 you'll have 88 words available.

Cleaning up the nested brances in Ladder 7 gives back 5 more words.

See attached.
 
Ken beat me to it.

But in addition to his suggestion, anywhere you are moving a 0 into any word, replace that with a CLR instruction.

Take a look at ladder 6, rung 1. You are using bit T4:22/DN
to set bit B3/80. This is redundant. Replace the XIC B3/80 in rung 3:0000 with XIC T4:22/DN and delete rung 1 from ladder 6. Do the same thing with rungs 4, 7, 10, 13, 16, 19, 22, 25, 28, and 31 from ladder 6 for a gain of 22 words.

Same goes for ladder 9, rung 1.

In ladder 4, instead of brancing the Full_Reset_Pulse bit in with every single alarm, remove all the branches and program a seperate rung where the full reset pulse clears the entire word of alarms...
XIC Full_Reset_Pulse CLR B3:0 or if you don't want to clear the whole word, but just clear bits B3/0 though B3/10 with a bitwise AND
XIC Full_Reset_Pulse AND B3:0 -2048 B3:0
Either way will net you a gain of 6 words.
 
Last edited:
Cheers guys, I will look at this when I get into work this afternoon. Very much appreciated. I bet you can see that I am a beginner in programming form the state of the ladder :)
 
Ken, thats brilliant :geek: , I did not know about the fill command. In ladder 10 I assume the length of 10 will fill N7:11/0 to N7:11/10 even though its 11 long? Is length actually the repeat?

Alaric, just going through your list now. The B3/80 is confusing me though, I cannot find it anywhere!

So go on then, as a relative novice on the programming side, how did the whole program look? BTW this is my first project using an HMI, so I have basically guessed the best way to implement it.

I am now going through the program to take on board Alaric's points.

In fact, anyone using Telemec Vidjeo Designer fancy a chuckle at my Program for the HMI :ROFLMAO:

You guys are the best!
 
The FLL with a length of 10 and starting address of N7:11 would put the source (0) in 10 WORD addresses from N7:11 to N7:20 inclusive. You will want a length of 11 to clear N7:11 through N7:21.

Also, you could do away with the internal copy of the HMI bit (B3:3/1) since the instruction will occur all at once, you don't have to worry about the HMI bit going "off" in the middle of a series of MOV instructions.
 
Last edited:
timbo_uk said:
Alaric, just going through your list now. The B3/80 is confusing me though, I cannot find it anywhere!

B3/80 is short hand for B3:5/0.

See the attached for the changes Ken made plus the changes I recommended. Its up to 154 words of memory left now instead of 24 - more than enough to program several dozen more rungs.

RSLogix has a compare tool under Tools -> Compare that will compare this program with your original in side by side windows so you can easily find the changes and see the difference they make.

I also cleaned up the nested branches you had in the first three rungs of ladder 2. Extend branches, don't nest them. To extend a branch right click on the branch leg and select extend up or extend down, or if using the mnemonic editor type in NXB. Nesting branches adds more instructions and takes longer to process than extending branches.

A030408A.JPG


I also changed the way non-retentive timers T4:1, T4:3, T4:5, T4:7, T4:9, T4:11, T4:13, T4:15, T4:17,T4:19 were reset, recovering 21 words.

I noticed you use a lot of JMP instructions. There is nothing wrong with the JMP instruction (I use it frequetly for looping) but I think some of your use of it could be avoided by structuring the program a little differently. Just say "no" to spaghetti code.


All in all though, pat yourself on the back.
 
WOW!

Fantastic information, you never stop learning do you!

I cannot take all the credit for the coding; during the original concept and version without HMI, the other site electrican helped me with some of the fault detection code.

It has developed (and had got messy) since then.

Now Ill see if I can do anything with ladder 8?

👼
 
Last edited:
Ron Beaufort said:
here's a screen shot that might help ...

offset.JPG

I can now see this, so in "Idiot Speak" S:24 is a special address and the # symbol prior to adds the offset to the bit address?

So first scan:

Rung 0000 - S:24 = 0
Rung 0001 - Ignore label, add S:24 to T4:0 to get T4:0 (ditto N7:0). If T4:0.ACC > N7:0 then move to the offset (of 0) adddress.
Rung 0002 - Add 1 to S:24
Rung 0003 - Check S:24 has not reached 21, if not jump to label Q2:0 (This creates a loop 22 times)
Rung 0004 - Continue here after looping 22 times.

Think thats how it works?
Ill play with it asap!

Just adding more jumps! How can I see easily in rs logix 500 what Q's I have used?


*** Update ***

Tried using this in my code, but it cannot work because of my structure (as mentioned earlier)

My timers that are used increment in 2, yet the integer addresses increment in 1's.

Another lesson learnt; if using multiple similar items in ladder, try to keep them sequential so you can use tricks like this :)

Thanks Ron - This thread is now in my favourites, I will use this in future projects.
 
Last edited:
timbo_uk said:
Another lesson learnt; if using multiple similar items in ladder, try to keep them sequential so you can use tricks like this :)

When I have multiple related items I usually create a set of files for each (unless using a PLC that supports UDTs but thats another matter). For example, suppose I have several steps and each step has two timers, an integer, and a counter. I would then create files N11, T12, T13, C14. Then N11:0, T12:0, T13:0, and C14:0 all belong to the first step, N11:1, T12:1, T13:1, and C14:1 all belong to the second step, etc. This way indexed and indirect addressing is easy, but it also improves readability of the code.

Unfortunately in the ML1K you have fixed files and cannot add extras - but its something to keep in mind for the future.
 
I can now see this, so in "Idiot Speak" S:24 is a special address and the # symbol prior to adds the offset to the bit address?

that's not "Idiot Speak" my friend ... that's "Guru" talk instead ... and your play-by-play description is so close to perfect that I'm going to give you FULL credit ...

keep in mind that other "file type" instructions also use the S:24 "index register" ... things like COP (Copy), etc. ... wherever you see the # character ... that's why we want to "CLEAR" the value of S:24 each time before we start the loop ...

as for which Q's (labels and jumps) have been used, keep in mind that the JMP is a "local" jump ... specifically, you can NOT use it to jump from one ladder file over to another ladder file ... it would take a JSR (Jump to Subroutine) instruction to make THAT happen ... it shouldn't be hard to find them all ... just do a "Find All" search for the letter Q ...
 
I know the JSR, its used in ladder 2 :)

just after posting I used the Cross reference list to see all the "Q"'s I was using; easy when you think about it!

I look forward to helping somebody in the future!
 

Similar Topics

Hi all, after much aggravation trying to get my SLC5/04 to talk half duplex to RSlogix so l then would be able to communicate with both RSlogix...
Replies
0
Views
2,239
I have a customer with an existing ML1000 that we installed quite a few years ago. It's function was rather limited but did what we wanted. New...
Replies
5
Views
2,682
I feel really, really dumb asking this, but I shall. I am using a Micrologix 1000 to toggle two outputs. I am using a timer to time and it...
Replies
3
Views
1,496
I have set up two 1761-net-eni modules and have them working on our network. One module will communicate with the ML1000. The other gives 2-3...
Replies
3
Views
1,766
I have a customer that has a ML 1000 we installed years ago. It is limited to the function of Stopping a series of motors when bin limits go HI...
Replies
1
Views
1,706
Back
Top Bottom