There are several questions here and allot of "stuff" none of it matters.
Ken M said:
Why is there an issue here?
IEC61131 is utterly clear about the scope and purpose of the datatypes WORD and INTEGER. They are not the same. The only thing they have in common is that they occupy the same amount of memory in a CPU: 16 bits.
So, do we accept that strongly-typed computer languages are a good thing or not? If we do, leave the type-checking switched on and obey the rules. If not, switch it off and now you have to do all the house-keeping and data management yourself. Simple choice, clear consequences, your call.
Ken
In this case Integer is a subset of word. I realise that word is a size of data. I think the software should accept 10 in that word and be able to apply it to an Integer without me having to tell it 10 is an INT. It should be obvious it is not a real, as it is in a word not a Dword. (S7 has no quams about telling you 10 is NOT a real number so what does S7 think 10 is? could be a string I guess.)
So when I define MW45 as "Oil Level" and S7 automaticaly puts the type as "WORD" I question the need to go another step and change the "WORD" type to "INTEGER".
This is just a gotcha in my book. If it is some how critical, as it seems to be, then leave "type" blank and ask for an input and I will evaluate the options and I would then choose INT from the list.
When S7 picks "WORD" as type , it makes it seem non critical or as if "WORD" is the correct choice in this case. ........To the new user.
Of course now that I know this, it is nolonger an issue. None of it is an issue AFTER you find out.
I am not arguing whether it SHOULD be one way or the other, but there should be an indication of what is happening.
Try to define an element in the symbol editor without putting a name in the symbol cell. It wont let you. I wanted to specify a range of memory locations as INTEGER without naming them all, just make them INT and leave the name blank the way it is before............NOPE. And that is completely OK , but why not do the type the same way?
It all boils down to this..........If type is so critical to Siemens and S7 then why does S7 make it soooooooooooooooooo easy to get wrong?
"So, do we accept that strongly-typed
computer languages are a good thing or not? "
AHHHHHHHHH
computer languages............yes, but PLC languages is the issue at hand.
"If we do, leave the type-checking switched on and obey the rules. If not, switch it off and now you have to do all the house-keeping and data management yourself. Simple choice, clear consequences, your call."
Turning type checking off does not remove the problem of missmatched types it just turns off the alarms. I do not think this is good advice to anyone. I want MORE type CHECKING and less NEED for type checking.
And what "house keeping" are you refering to? DAta types match or not, S7 tells you or not.
The choice IS simple, walk through a mine field WITH a map that is right MOST of the time, or just throw away the map and run through. Simple yes. Solution, no.
Why can't I compare an Integer with a Real number?
Real numbers
contain integers.
(Imagine these are in LAD)
10 < 12.62578
there I did it.
10 > 2.67392
What's the big deal? Turn off type checking and this works right? I am asking for clarification. What is so bad about doing this?
I am serious, with all the fuss I feel like I have missed something fundamental.
Ok now 10+22.89...............What about this one?
The ONLY place I see an issue with data type is when comparing Binary HEX and DEC or when doing MUL or DIV with INT.
Even then I would DO the math and round off to the nearest INT.
6/2=3 int
6/5=1 int
125/10=13 int (if 5 rounds up.) No need to convert int to dint, dint to real and then compare and then trunc or round back to an int.
If it is a show stopper ASK the user and accept NO incorrect entry. EVERY variable should be defined before use if it is critical.
The issue is S7 seems to allow more to happen at the point of data entry than it wil allow at the point of data use.
So much of the discussion seems to get personal or defensive, I don't get that bit.
Several times I see S7 guys say "You need to get past the I can't believe S7 wont do this."
I would say to S7 guys, "You should stop thinking everything in S7 makes sense just because you are past the entry point."
Some of us have used several other packages and there are always differences. Noone would argue that. One expects a deviation from manufacturer to manufacturer. Based on past experience that deviation is far greater with S7 than any other.
Not sayin that's a bad thing, maybe it IS way better, maybe everyone else is that far behind.
PLCs were made to replace relays, not PCs.
That is why they are simple, or why they were simple.
Now the difference between PC and PLC is growing so small it is easy to make the arguement to just switch to C or some other PC based language.
It is meant to be easily understood and intuitive to the casual user during moments of high anxiety. When production stops no one cares how clever the PLC programmer was or why this number wont work here but works there, it just needs to work NOW. Call the programmer or someone who can sort this "clever" design costs production.
Of course it also generates more need for the programer until everyone figures out he's part of the problem.
I am mixing a new angle in here, but it all relates. Complex and tricky are rarely a good thing in industrial controls and things are getting progressively complex and tricky.
I have never met the maintenance man in any plant that could use S7.