TIA Portal implicit conversions

Puddle

Member
Join Date
Mar 2022
Location
UK - The Norf
Posts
331
Made a rookie mistake with trusting an implicit conversion and thought I'd post it here for google results.

Calculation error.png

I've never had an implicit conversion fail before, but here because the IN1 on the calculation is a UInt data type, the whole thing has defaulted to UInt and I missed it. The other three tags are Real data type which apparently stops this from working.

Changing the data type of the block to Real solves the issue.

If somebody has an explanation as to why this happens it would be greatly appreciated.

EDIT: Also just realised I should add that I need to update the tag names. Speed is not calculated from nameplate speed (1440rpm) but from the theoretical maximum (1500rpm).
 
Last edited:
... thought I'd post it here for google results.
Very thoughtful, thanks!
If somebody has an explanation as to why this happens it would be greatly appreciated.
UINT division: 13094 ÷ 16383; quotient 0; remainder 13094.

The output is assigned the quotient by correctly converting UINT 0 to REAL 0.0. The quotient is discarded with a glad cry.

You are neither the first, nor the last, nor the only. We often forget how incredibly stupid these machines are, to not be able to read our minds. Rejoice that you will probably never do it again, or at least that will recognize it when you see it, and also that you did not do ((IN1*IN2)/IN3), which might have either had some small roundoff errors that you never noticed, or caused an overflow.

The PLC cares not a whit what you want it to do, but it will mercilessly and inexorably do exactly what you tell it to do.
 
Gut feeling since I don't have TIA Portal in front of me, but the first division with the current values gives you 0.79. But if you chose the output to be UINT (or possibly anything but REAL), it rounded straight away and then the multiplication would be zero?

I don't have the help, but it's likely that the data type chosen at the top forces that type on the input values and only then runs the calculation.

I know why this block exists now, but I'm really not a fan of it because of this possibility. Still down to implementer to look after it, but it opens up the chance for this.
 
As mentioned above, when you select the data type for the block, all input/output parameters are converted to that type (hover your mouse over the small box next to the parameter to see the relevant message warning you about the implicit conversion).
 
The PLC cares not a whit what you want it to do, but it will mercilessly and inexorably do exactly what you tell it to do.

One of my favourite quotes from Red Dwarf:
"You tell those Scutters 'watch that lamb' and they do, they sit there for four hours and watch it burn"

As mentioned above, when you select the data type for the block, all input/output parameters are converted to that type (hover your mouse over the small box next to the parameter to see the relevant message warning you about the implicit conversion).

That's the bit of information that I was missing. I didn't realise that it converts all data types to match. Every time I've seen that warning before and haven't been able to sync up my tags it's worked fine.
 
Not sure if you know this or not, but the squares on the IN2 and IN3 are indicating you that you are converting the datatypes.

Calculation error.png
 

Similar Topics

Hi All, Someone at work has put a PLC system on my desk, that's just been taken off an idle production line. He said "It's an S7 PLC. We don't...
Replies
10
Views
247
Hi guys , I'm new with Allen Bradley, but I have experience with Tia portal (s7 1200 ,s7 1500) I want to convert my project from Tia portal to...
Replies
2
Views
203
Hi, I have had problem with upgrading some projects from v16 to v18. I tried it on 3 diffrent computers. I want to post this so that anyone that...
Replies
3
Views
167
Hello gentlemen, Im working on a small project on TIA Portal, about establishing a Modbus TCP connection between my ET200SP plc and a socomec...
Replies
12
Views
310
I am currently am in a PLC class and need urgent help on how the ladder logic would be laid out. I understand how to get the traffic lights to...
Replies
19
Views
446
Back
Top Bottom