TIA Portal implicit conversions

Puddle

Member
Join Date
Mar 2022
Location
UK - The Norf
Posts
333
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 PLC people, think about this scenario: The PLC is somehow connected to the same network with the facilities` network. Then someone connects to...
Replies
2
Views
124
Hello, good morning, I have been having two problems with the Tia Portal software. The first is that I have installed it on my computer and...
Replies
5
Views
210
Hello all! So I have one project with a S7-1214 and a MTP1500 "Project1" and one project with another S7-1214 "Project2". Both of these PLC:s need...
Replies
6
Views
138
Hello, i am using profibus as communication between plc and fanuc arm. I can easily send inputs from plc to arm, but i can't monitor any outputs...
Replies
0
Views
61
Hello, I need to write the following program in Ladder language, but I could not integrate the Fibonacci sequence into the ladder. Can you help...
Replies
22
Views
511
Back
Top Bottom