Does any body use IL ( instruction list )?

Only in very time critical processing. eg a very often called subroutine. In the last 3 years I have not had to use either. Before that IL was in use on a servo system that I had to modify and maintain.

Rockwell - does not have IL on the controllogix
Siemens - German programmers seem to only program in IL
other programming languages (C, VB, pascal, etc try to get away from assembler (IL) as most people cannot program properly in it)

IL - If this was available then it is possible for someone to efficiently process C code on your controller, eg from a externally generated model.

I would have thought that you could use a pre-processor on the ST to convert it into IL that you could then compile. Getting you both for the price of one compiler. Hmm that would still be a lot of work.

I think that just ensuring that you have a interface that accepts matlab models would be useful. ST works for that.


As an aside
I have been investigating the Rockwell ST timing for a:= b + c;
It is shocking - If I had IL then I could make it much better. I had to rewrite it in LD as that was optimized.

Rockwell ST converts a:= b + c; into
z := b+c;
a:= z;

An unnecessary assignment when all are the same data type

I believe the reason this occurs is to make their life simple in compound statements
eg a:= b + c + d + e;
breaks down into
z := b + c;
z:= z + d;
z:= z + e;
a:= z; with any conversion required eg REAL to DINT.
 
Only in very time critical processing.
This statement raises the question, what if ST was just as efficient?

eg a very often called subroutine. In the last 3 years I have not had to use either. Before that IL was in use on a servo system that I had to modify and maintain.
Basically it look like you could live without it if ST were more efficient.

Siemens - German programmers seem to only program in IL
IEC IL and Simens STL are two different things.

IL - If this was available then it is possible for someone to efficiently process C code on your controller, eg from a externally generated model.
I don't understand exactly but...
What if ST is just as efficient.

I would have thought that you could use a pre-processor on the ST to convert it into IL that you could then compile.
Would you really want to do that if you ST generated code just as efficient?

Getting you both for the price of one compiler. Hmm that would still be a lot of work.
This is why I am asking.

I think that just ensuring that you have a interface that accepts matlab models would be useful. ST works for that.
Matlab and ST are very different. I don't understand.

As an aside
I have been investigating the Rockwell ST timing for a:= b + c;
It is shocking - If I had IL then I could make it much better. I had to rewrite it in LD as that was optimized.
Rockwell ST converts a:= b + c; into
z := b+c;
a:= z;

An unnecessary assignment when all are the same data type
I didn't know that. It seems that many big companies say the have ST or auto tuning just so the marketing guys can say they have it.

I believe the reason this occurs is to make their life simple in compound statements
eg a:= b + c + d + e;
breaks down into
z := b + c;
z:= z + d;
z:= z + e;
a:= z; with any conversion required eg REAL to DINT.
Could be. I would never let my compiler writer get away with that. However, my compiler writer decided to get a PhD in Divinity and move to Edinburgh Scottland so now I am the compiler writer. I new replacement newbie compiler writer. This is why I am asking.

How important is it for ST to translate to STL or IL if ST can generate efficient machine code directly? I would prefer to convert ST directly to machine code and skip the IL intermediate step that then must be converted to machine code.

BTW, our compiler currently coverts a:=b+c; to

LDI b
LDI c
ADDI
STI a

I am assuming a,b and c are integers otherwise there are LDF ADDF and STF instructions for floats. The bad part is that then there is an interpreter than then must convert these instructions into machine code. The good part is that if the ST converts to IL then it will work on any CPU, only the IL compiler needs to be written.
 
I see no need for IL in the 21st Century.

I have worked on a few machines that used old moeller controllers and programmed in Germany and all used IL programming. I don't know if that is because that is all they had when the programs were developed or because that is what the programmers liked to use. I'm guessing if you grew up with it as your first PLC language it would be easy for you.

I have never developed in IL myself and would probably find it extremely tedious. It reminds me of an RPN calculator with only a single register stack.

But in the a:= b + c; example I believe the IL looks almost like what your translation to machine code looks like. I have never written a compiler but it appears that writing a compiler for IL would be easier than any of the other languages. And as MichaelG suggest, I'm almost sure the old Moeller Sucosoft pre-processed everything to IL as you could translate any of the other IEC languages to IL (but not always the reverse).

To answer your question, I would think if the ST is just as efficient, there should be no need for IL. This is the 21st century after all.
 
This statement raises the question, what if ST was just as efficient?
Basically it look like you could live without it if ST were more efficient.

That is correct

Matlab and ST are very different. I don't understand.

MatLab has a method where you can export the model into code and import it into your PLC code - this allows state space modeling, neural networks and fuzzy logix to be implemented in a PLC/PAC controller using matlab exported code
Rockwell and Siemens can both do this.
http://www.mathworks.com/products/sl-plc-coder/?s_cid=global_nav

I didn't know that. It seems that many big companies say the have ST or auto tuning just so the marketing guys can say they have it.

Yes when I found it i was very disappointed - I also had a hard look at Rockwell FBD and found the same inefficiencies, on the Rockwell platform LD is by far the fastest code

I would prefer to convert ST directly to machine code and skip the IL intermediate step that then must be converted to machine code.
I think that it depends on where you are taking your product - Full IEC 61131 - 3 using LD, ST, IL, and FBD, Probably not. Having LD and ST very likely, remembering that your product is for engineers not bubba.


LDI b
LDI c
ADDI
STI a

What do you do with b Dint c real and a Dint
LDI B
Convert stack into a real
LDF C
ADDF
convert stack to DINT
STI a

Or are the conversions looked after when the machine code is generated
The good part is that if the ST converts to IL then it will work on any CPU, only the IL compiler needs to be written.

Seriously using IL the lowest common language then the other languages (LD, FBD, ST) can be efficiently converted into IL. Then for one IL compiler you can get all of the other languages with additional lexical precompilers. Debugging the other languages is easier as you can see the intermediate IL code.

If you provide ST as the lowest language then FBD and LD can still be easily converted into ST.

I would expect that most of your clients would use ST, as US based and Rockwell users. Possibly most European users who are very familiar with Siemens are more likely to use IL but would accept ST.
 
If you dont expose more lower level access, that would enable one to optimise some code, then i dont see any reason for it over just ST.
 
In ST you do not know the timing in IL you do, as the instructions are machinecode and you can calculate how many cycles are needed.
However with nowadays fast machines you will never use it, BTW these interupts are killing all these fast IL routnes.
 
In ST you do not know the timing in IL you do
, as the instructions are machinecode and you can calculate how many cycles are needed.
We don't compile down to a IL but it is something close. Our 'IL' is more stack like. Memory is only accessed using load and store instructions. Other operations use the data on the top of the stack. This way we avoid have many different types of ADD instruction. Some CPU have 8 addressing mores or more for each basic instruction and we wanted to avoid that.
http://deltamotion.com/peter/Videos/UserProgramScanTime.mp4
You can see count the micro seconds.

The part of the compiler can count microseconds for each bit of code the compiler emits. One of the last steps of the compiler is to emit code. Basically there is a switch or case statement that has a case for each basic operation like load, store, add, subtract, multiply and divide.

@MichaelG, we have a I2F and F2I instruction to convert data types.

BTW, we have improved the code generated by the compiler since the video has been made. The divide by 2 is now replaced by a multiply by a (1/2) or 0.5. Divides are much slower than multiplies. Multiplies usually happen in 1 clock cycle whereas a divide can take 35 clock cycles. Integer divide by powers of two are converted to shifts. x**y doesn't use the exp(y*ln(x) that most compilers do when y is an integer. If y is a integer value either like 3 or 3.0 , which is the case most of the time, we convert x**3.0 to

LDF X // X
DUP // X X
DUP // X X X - 3 copies of x on the stack
MULF // X*X X - x**2 and x
MULF // X*X*X - x**3

We handle all combinations of x**Y like this where y is an integer value from 0 to 7 or 8.

This way a customer can write:
y=a+b*x+c*x**2+d*x**3+e*x**4+f*x**5
Without invoking the exp() or Ln() functions that require using a Taylor series and results in rounding or truncation errors. The difference in execution speed is great.

The point is that ST can be optimized. I have never seen any assembler optimize assembler code.
 
Peter Nachtwey said:
I have never seen any assembler optimize assembler code.
That is the point of assembler, at least as I learned it in college on IBM mainframe. 1 assembly instruction = 1 machine instruction. The program does "exactly" what the programmer tells it to do.

I have heard the term macro assembler but I believe it has mre to do with repeated assembly code that the programmer has written.
 

Similar Topics

I am trying to connect with a Schneider plc which has a firmware version only available in Somachine v4.2. In Machine expert After taking upload...
Replies
0
Views
112
I have submitted this tread to a magazine and it got rejected by the editor that obviously has never done motion or used cam tables.
Replies
6
Views
2,115
Does any kind person out there have a copy of DecoderProsave they could let me have Thanks Andy
Replies
0
Views
1,414
The health-care and the machine automation worlds hardly ever cross-over. We don't hear of PLCs (or anything programmable) being used in medical...
Replies
9
Views
2,824
Have a customer with a single axis CNC machine. It's fairly simple. The system is a SLC 5/03 with a Panelview 550, an Ultra200 servo drive. The...
Replies
6
Views
4,969
Back
Top Bottom