Using LREAL in expression in Rockwell structured text

attologix

Member
Join Date
Feb 2019
Location
Grand Rapids, Michigan
Posts
4
I'm writing some structured text that's handling a data structure that comes from a PC. The PC structure is in the "new" LREAL 64-bit floating point format (new to Rockwell as of V32 from 2019, new to computing as of the Intel 8087 math coprocessor from 1985...). But I digress.

Most operations are working fine:

Code:
// Can assign one LREAL to another
Current_CY := Centroids[0].Y;
// Can assign a literal to an LREAL
Previous_Left := 10.0;
// Can perform and assign an ADD/SUB/MUL/DIV equivalent
Panos[i].Width := FarRight[i].Y - NearLeft[i].Y;

But I can't write more complicated CPT expressions:

Code:
Panos[i].Width := (Centroids[i].Y - Previous_Left) * 2.0;


because it complains:

Error: (Pend), Line ##: Extended datatypes (USINT, UINT, UDINT, LINT, ULINT, LREAL) are not supported in expression.


Is there a workaround for this limitation? I'm familiar with the 16# and 0b prefixes for hex and binary numeric literals, is there one (eg. the C language 'f' or 'l' for 32- or 64-bit float or long types) that says "treat the 2 as an LREAL"?

Edit: On further testing, it's not the 2.0, it's the combination of subtraction and multiplication on one line. You can combine addition and subtraction, or multiplication and division, but with or without parentheses Rockwell can't add and multiply in a single expression. I can work around it by breaking it to two lines:

Code:
Panos[i].Width := (Centroids[i].Y - Previous_Left);
Panos[i].Width := Panos[i].Width * 2;


but this gets really tedious for longer expressions.
 
Code:
Lreal2 := 2.0;
 Panos[i].Width := (Centroids[i].Y - Previous_Left) * Lreal2;


?


not much better, but at least the actual calc is one line.
 
Rockwell has a collection of AOIs for performing long math. It is included in their process library that can be downloaded from the download center. At this time, that is the best way to handle this (and a terrible solution by Rockwell).

I have been implementing my own AOIs and the ones Rockwell provides are simply terrible, but they should work for what you are doing.
 

Similar Topics

Hello, We are now working on a software to collet the configuration of different PLC brands ,using a third software to backup all the simens...
Replies
1
Views
69
Hi, I wrote a sequence loop using EQU and MOV instructions and would like to validate that i'm doing this properly. i attached a picture of the...
Replies
5
Views
141
Hi I'm very new to PLC programming and I'm trying to find out if this library (Tc2_NcFifoAxes) is necessary for our task In our case we need to...
Replies
0
Views
50
I have a project to automate four generator sets. The system will monitor and store the load demand of the factory. Once there's Power outage, the...
Replies
0
Views
95
Adding ethernet equipment to an existing panel that has none. We have some solid ethernet cables coming from other remote cabinets that I plan to...
Replies
3
Views
151
Back
Top Bottom