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[0].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:
Finish configuring the “Data Sampling” object and then download the project. You will notice that the data sampling object now records the scaled value:
This is amazing, I will start working on my program changes, I will let you know how it goes after I do the changes and do some testing, if I get stuck on something I will let you know .
Brendon,
I already have have the user defined tags for the value I want to convert I only need to add the subroutine to the conversion/calculation area.
So I have 3 different tags that I want to set 7 as their minimum printed value.
Do I need to create 3 different sub macros for each one of can I use just one for all 3?
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:
I double checked all the data types and even created a new tags and data sampling object, thinking that would fix it.
But no success.
The only way I was able to be able to “fix” the error was when I moved the bottom tag in my DATA window (tag flow ml/m) all the way to the top and I stopped getting that error.
Any ideas what might of caused it or if this might be a bug with easybuilder pro ?
I was not able to replicate a similar issue on my end. When you have time, can you please advise the following information so that I can re-test this issue:
What version of EasyBuilder Pro are you using within your application?
Can you post an image of the configuration of your Modbus tag and subroutine?
My apologies for the delay and thank you for the information! We will investigate this issue and report back with our findings. I will let you know if we require any additional information.