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

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
64
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
124
I'm trying to control a device via MODBUS RTU and the ModbusRtuMasterV2_PcCOM in Twincat 3. I've configured a device with the right com port and...
Replies
7
Views
222
Hi, I'm trying to use the IO Device Library (Product Versions) which is configured to work with the 1756-EN4TR & 1756-EN2TR but my system uses...
Replies
0
Views
60
Hello, As part of our project, we are using an M241 controller. This controller interfaces with an industrial computer and a router via a switch...
Replies
2
Views
111
Back
Top Bottom