My question is, is there a way to put a minimum value as a limit, to get printed on the excel document.
Let say my sensor gives me values from 0 to 30, but I want 7 to be my minimum value printed out in the excel files, even if I get a value lower than 7 I need this to be the minimum value printed on the excel file.
Would this need to be done with a macro or is there another way to do so.
This is a great question, I think that in this scenario it would be best to use either a Macro or a Macro subroutine. A subroutine is a special type of Macro that can be applied to a register-based device like a Modbus TCP/IP device during tag creation. Subroutines can convert values that are read or written into an object that utilizes this tag. Here is an example:
Within my project I have a Modbus TCP/IP device: Note: This is considered a “register-based” device because devices that conform to this protocol use addressing in the format of [Some place in memory] - [some number] like 4x-1 and 0x-1. A tag-based device uses symbolic addressing like "Motor.rpm.
To perform the scaling that you described, I’ll create a Macro subroutine. To do this, I’ll select the “Project” tab and click “Macro”:
Configure the scaling logic. The declaration of “short” after the keyword “sub” defines what this function will return. The name of this function is called “Scale” and it has one parameter called “param”:
Configure the name and address and enable “Conversion/calculation”. Within this section ensure that the data type matches what is returned by the subroutine (e.g., short is a signed integer) and then select the “Scale” subroutine from the “Read conversion” list:
My apologies for the delay, the same subroutine can be used for all 3 addresses. Additionally the failure during compilation is likely due to an incorrect data type set within the data sampling object. As an example: