08-19-2019 01:42 PM
@sandy1234 wrote:
Again my question is how to pull a range of holding register from 40001-40050.By creating a single variable with the range?
The above solutions will create a single array output. If this is not what you want, define what you mean by "a single variable" and "range". These terms are very ambiguous.
08-19-2019 04:03 PM
Yes. Take your array of 50 U16 integers, and type cast that to an array fo SGL floating points.
You may run into endian problems. If the above functions don't give you the numbers you want, then, you could decimate the array into two 25 element arrays, and do a join and typecast inside of a loop. there are probably a few other ways that you could use to get the final results. The "Swap Words" function might come in handy in some of them.
08-19-2019 04:08 PM
Hi,
Thanks guys I will try this in a couple of days and update here the result...Cheers
Sandy
08-19-2019 04:34 PM - edited 08-19-2019 04:37 PM
@sandy1234 wrote:
Again my question is how to pull a range of holding register from 40001-40050.By creating a single variable with the range?
Sandy
Is it correct that an array will be what you call a single variable? If so, yes a "single variable" (array) can contain the whole range.
If i understood you correctly in an earlier post you have managed to read two registers, combine them and cast them to a SGL. Then you know how to read a register.
I suggest creating a for-loop for reading 50 registers and collect the values on the output of the for loop with an indexing output. You will automatically get an indexing output on a for loop if you connect a wire from the inside to the frame. I do not know how you read one register, but i assume you need to create a way of automatically calculate the register number inside the for loop based on adding the indexing variable to first register address.
Out of the for-loop you now have an array with 50 INT16. Use my earlier solution or cbutcher's solution to convert the 50 INT16 to 25 SGL.
08-19-2019 11:35 PM
@sandy1234 wrote:
Hi,
Thanks guys I will try this in a couple of days and update here the result...Cheers
Sandy
If you have problems, then sharing the code you're currently using to read the first two registers will make it easier to give you advice on how to do the same for a larger number of registers (or really, to give an example, since there are already numerous pieces of advice that describe possible solutions).
08-20-2019 02:12 AM
Hi,
Attached the code which I tried by creating just two 16bit registers ie 40005 and 40006 and it was working (My laptop LV2014 is having some problem while deploying so tried in another PC).
Regards
Sandy
08-20-2019 03:50 AM
I am a little bit more outdated than you, sandy1234. Could you save it for LabVIEW 2012?
08-20-2019 04:07 AM
The saved VI shows the use of Shared Variables to access the registers.
This method is I think what is described here: Connect LabVIEW to Any PLC With Modbus (perhaps Sandy can confirm this is the method being used)
Alternatives can be found here: Introduction to Modbus using LabVIEW.
In particular, you can see in Figure 3, for example, reading multiple values into an array.
That might significantly aid your progress.
As a following option, if you prefer the NSV, you can programmatically access them by name (but then you'll need to use the names and generate those in a loop, for example a For loop with a fixed number of values, or autoindexing through a list (probably more messy if your registers are continuous).
08-20-2019 05:40 AM
cbutcher, both links point to same page. Is that correct?
08-20-2019 06:34 AM
@RolfO wrote:
cbutcher, both links point to same page. Is that correct?
Oops! Copy-paste fail.
First link should be this one: Connect LabVIEW to Any PLC With Modbus