I am attempting to data log 4-20 mA signals from (3) ADAM-6017 DAQ modules (Advantech) using functions from the NI Modbus Library. I have never used LabView before, but I somewhat understand what is going on. My current VI is attached, but I do not know how to enhance the VI to perform the following tasks:
1. Output time-dependent register values from all 8 channels to Excel spreadsheet with each COLUMN as a register value (right now it outputs all values in the same column and the time is normal at first but then it gets weird -- see attached screenshot of excel sheet).
2. Output the mA reading to Excel, not the decimal value of the register. Even better would be to convert these values to the actual pressure, temperature, flow rate, etc. based on the span of the instruments. But all three ADAM modules have a mix of instruments attached (not all with the same span/units), so this may be difficult?
3. I have (3) modules on different IP addresses and I want to data log all of them. How do I add all IP addresses to the same VI (do I need 3 separate TCP Masters)?
I would greatly appreciate anyone's help!
Solved! Go to Solution.
1. Change that to DDT Express VI bullet to be 1D array of scalars single channel to 1D array of scalars multiple channels.
2. Yes, you can convert from the U16 value to something in mA or engineering units. You just need to know what the conversions are for each register and do the math. Think y= mx + B. The only thing that will be difficult is how to know which instrument as which scaling? You've got the same problem now, you just have to figure out a way to get that info into your LabVIEW program so that it can do the math for you. It might be a matter of reading a configuration .ini file.
3. Yes, you'll need 3 different masters, one that opens each IP address.
In regards to your suggestions, I have a few follow-up questions:
1 & 2. I found that "Unbundling" the holding registers allows me to perform operations on each (see attached image) -- but is there an easier way to do all the arithmetic operations in one function/block? Not all channels are the same device so they need to stay separated.
3. This works! Thanks!
Don't turn the array into a cluster and unbundle. It would have been easler to just use Index Array.
But you don't even need to do that. Since each register has the same math done to it, just do the math operations on the array! The result will be an array of converted numbers.
The math to convert them to 4-20 mA is the same, but "later" math to convert to degC, psi, or GPM is different -- do you have any suggestions for operating on individual channels?
Create an array that contains the conversion factors. (might be an array of clusters as you might want a cluster containing a gain and an offset).
Then use a For Loop and auto-index on the array of registers and the array of conversions. The conversion math will be inside the For Loop acting on each register one by one with its corresponding conversion factors.
Actually, if you keep the gains and offsets in different 1-D arrays, you don't even need a For Loop. Make sure your 1-D arrays are all the same length.
Back in the lab after COVID-19 hiatus -- I 'somewhat' applied your suggested solutions but I have some more followup questions (revised VI attached, simplified to only one ADAM module):
1. Is there any way to condense the conversions of my registers (i.e. do I need to do array to cluster, then cluster to double)? * Note conversion is not the same for all channels -- this one happens to have many similar conversions, but this is not the case for all of my ADAM modules).
2. When I output to excel spread sheet, I just want 1 time column and the rest be all the channels with labelled device name, but right now my excel sheet includes a time column with each channel and all the channel labels are only with the first device (see attached excel sheet)?
Oh, good god NO.
Why would you ever convert from arrays to clusters, to unbundle, then reverse the process? That is among the earliest examples in our
Work with Arrays!
That formula node is a mess also. It looks like a conversion form a U16, through a 4-20, through to either a 0-180 or 0-100 value.
I'm adding a simple subVI I created called Rescale, which take a numeric value, an input range, and rescales it to the output range. I tried to compare my output to yours, but it wasn't quite the same. I suspect that the code you put in those formula nodes is wrong.
As for the time columns. Edit that Express VI and change the setting to "One column only" instead of "one column per channel"
The signal name is because you just concatenated all the names into one string. Then passed that onto Set Dynamic Attributes which is set for signal 0.
You'd be better off if you got rid of the express VI's, and just build your own string arrays and used Write to Spreadsheet string.
Ok, so I have been trying to compile all the data into a spreadsheet, but am running into a few issues:
1. The 'headers' appear at the end of the spreadsheet
2. When I include the headers, it asks me to create a new file each loop iteration -- how do I keep it running and append to same file?
3. Can you get more precision on the timestamp (i.e. 0.01 sec)? When I convert this LV time to Excel time for a single loop iteration, they are all the same time even though I know there is ms of difference between them.
I looked at several of your other discussion posts to attempt to do this... so hopefully it is not garbage haha 😁