06-21-2015 11:23 PM
Dear LabView users,
i've been struggling with a program I need to write about the stress-strain curve and the E-modulus of a material tested with strain gauges, and LVDT's.
The thing is, I need to acquire data with the nDAQ-system from strain gauges (Virtual channel: Strain), LVDT's (Virtual channel: Voltage) AND a pressure cell (Virtual channel: Voltage), and I need to log this data and do some operations with this data. The problem is, this program needs to work with either the combination of 1 strain gauge, 1 LVDT and 1 pressure cell, but also with the combination, for example, of 4 strain gauges, 2 LVDT's and 1 pressure cell. For the strain gauge I need to be able to configure the strain gauge properties (but this is able with the bridge configuration cluster provided by LabView) for each strain gauge seperatly, also I need to be able to configure the scale and the input voltage for each LVDT or pressure cell, also seperatly. And I need to be able to select the channel for each gauge,LVDT and force cell. Also I need to be able to set these elements to zero before the testing begins.
Thereafter all these data needs to be logged into an excel file and also be shown on a clear graph that shows me the strain from the gauges, the displacement of the LVDT's and the force of the pressure cell.
Eventually, I need to become a stress-strain curve and the E-modulus of the material we're testing, presented in LabVIEW.
Does someone has an idea about how I should work this out step by step? Any help would be very usefull.
With kind regards,
Peter
06-22-2015 07:18 AM
We're doing things the "old-fashioned way", acquiring multiple channels of sampled data and saving everything as I16 integers (somewhat "legacy" code, no individual "scaling" and reporting in "natural units"). What we do is define a cluster for each channel that names the channel and provides the scaling information, which we do in "natural units/volt" (and knowing that the A/D is ±10V) (yes, it is "old-fashioned"). This gets stored in a Configuration file, and is included as part of the header record for the experiment.
I'd suggest something similar for your situation -- a cluster having the type of channel (LVDT, strain gauge, pressure transducer), it's Name (to distinguish between multiple LVDTs, say), and any channel-specific information you need to configure/interpret it. If this is relatively "fixed" (i.e. the basic hardware doesn't change -- LVDT1 always has one scale setting and LVDT2 always has another, say), you could simply create a list of Channel names desired for a particular run, use the names to look up the channel particulars from the Config file, use that information to set up the DAQmx channels, and configure everything "on the fly" just from the list of names. On the other hand, if the Scale settings are more variable, you could create an experiment-specific file containing just the clusters for the (physical) channels you needed, making sure that the scale settings for the chosen channels were correct for that run.
Bob Schor
06-22-2015 09:39 AM
Thank you Bob Schor for the fast reply.
You remember my previous post? Is it something like that you mean? I started there also with a cluster with name and scale information, but for the strain gauges it was too difficult to complete this. And eventually, it was getting way to complicated for me to proceed with programming.
And what do you mean with the configuration file? You mean a notebook file like I already tried?
Do you have some easy example (.vi) about how I should do this?
With kind regards,
Peter
06-22-2015 10:26 AM
@PeteTheGod wrote:
You remember my previous post? Is it something like that you mean? I started there also with a cluster with name and scale information, but for the strain gauges it was too difficult to complete this. And eventually, it was getting way to complicated for me to proceed with programming.
And what do you mean with the configuration file? You mean a notebook file like I already tried?
Do you have some easy example (.vi) about how I should do this?
Dear Peter,
I'm sorry, but I did not remember your previous post (though I did remember looking at something you had posted). However, I did "look it up" and saw that I'd made a suggestion that you store your configuration information in a Cluster, use an Enum (that you define) for the various types of Bridges, and store the data in a Configuration File of some form. LabVIEW has a series of Functions on the File I/O Palette for .INI files (which it calls "Configuration Files", and I provided an example for using an Excel Workbook as a Storage format, but you can use anything, even a Text file.
The important thing is this allows you, the User, to have a set of "Details" (Bridge Type, Gauge Factor, Gauge Resistance, etc.) stored along with a Name that you choose, and at Run Time, you can specify or choose just the Name (say, from a Drop-down List) and pick up all of the other parameters from your Configuration File.
If you were going to use a Drop Down List, you would want to populate it with the "Correct Choices", i.e. the list of Names in your Configuration File. So your Initialization Code would read the Configuration File and create a Ring (or something similar) populated with all of the Names. Then, when you choose which Device using the Ring to force you to choose one of the named Devices, you would simply use the Ring value to index your array of Configuration information to get Bridge Type, Gauge Factor, etc.
My earlier Post was "specialized" in that it only applied to Bridge Specification. If you want to include other Devices, such as LVDTs, you can certainly do that. Now your basic Cluster would change -- instead of Name, Bridge Type, etc., which is specific for Bridges, you would have Name, Device Type (an Enum that was Bridge, LVDT, etc.), and perhaps a Variant that could be called Device Specs (my earlier Example shows a possible Bridge Device Spec as a cluster of Bridge Type and two Gauge parameters).
Do you know about Variants and how to handle them? It just means a little more processing at the time of Reading, Writing, and Using. Here the LabVIEW .INI Config Functions might be simpler as you could particularize the sub-parameters based on the Device Type. You could still use Excel, but you'd need to give some thought about how to handle the different sets of columns for the different Device Types. If you want to go the Excel route, design an Example Worksheet (similar to the example you showed at the beginning of this post, which was just for Bridges, I believe) and show us your thoughts.
Spending a little time on design now can really pay off later -- it may take you an extra hour to figure out how to write the code, but the code should take very little time to execute, and will keep your program nimble, effective, and capable of handling multiple and new devices.
Bob Schor
06-22-2015 11:03 AM
Dear,
I'm defenitely gonna try to use these INI files. It seems a lot easier than what I previously tried.
But however, I don't know how to start with this program. When I have these "create virtual channels: strain and voltage (2 times)", do I need to set these up in sequence, so next to each other and connected with each other, then I have only 1 wire with the data from all these channels. Therefore it's impossible for me to select the correct data I need for my operations later. Because I also want to zero these channels, but for the strain gauge, I want to use the Zero vi of labview itself, for the others, i want to acquire 10 samples and calculate the mean value so I can subtract this later on (I don't know if this is the best way to do it...).
Is it possible for you to write an example in LabVIEW about how I should start with this program? It would be very helpfull...
I've never used Variants...
I absolutely appreciate your fast replying, thank you for that.
With kind regards,
Peter
06-22-2015 11:46 AM
06-22-2015 11:50 AM
Dear Peter,
This is yet another example of the utility of having a complete written description of what you have and what you want. You've just added another "piece", namely the DAQmx Task (and possibly other Task-related parameters such as Sampling Rate) associated with each named channel.
The first question to ask is how are you specifying the details of the DAQmx channels? Are you configuring Tasks in the LabVIEW Project (or in MAX) that "defines everything", e.g. the Device, the Channels, the Configuration, the Sampling Rates, the Scales, etc.? If these are basically constant, then having the Task defined "in advance" greatly simplifies the DAQmx processing since it basically boils down to three Functions -- Start, Read (or Write), usually in a loop, and Stop (or Clear).
Note that if you can define the Tasks in advance, and they remain "fixed", then the Configuration issue becomes much simpler. For example, if LVDT1 is always connected to PXI-1234 (a made-up device) and using Analog In 1 in Differential, ±10V, 1KHz, Continuous sampling mode, and LVDT2 is always connect to Analog2, but has a different Scale associated with it, you could save these as Tasks in the Project (call them TASK LVDT1 and TASK LVDT2 for mnemonic purposes). You don't need, for example, the type of Bridge for your Strain Gauges because they will be part of TASK Bridge1, for example.
Now your Cluster just got extremely simple -- it is a cluster of Name + Task, i.e. "LVDT1" and the Task Constant TASK LVDT1. Make an array of these and save them in your .INI file (I'm not sure how easy it is to write Task Constants, but some work-around can be found).
Now, at Run Time, get a list of the Devices you need, say Bridge 1 and LVDT2, and put them in an Array. Open your Config File, read all of the data. Run your Array of Device Names into a For Loop. Use the Name to index into the Config Array, get the correct Cluster, unbundle the Task, and create a corresponding Array of Tasks as the output to the For Loop.
You can now initialize all of your devices at once in a single loop (if you want to do so) -- simply run the Task Array into another For Loop, wire the Task to Start Task, and bring the Task back out into the original Array. You may want to have separate loops for Reading and Writing -- simply pick the Task Array apart using Index Array and send the separate Tasks to the appropriate loops.
This sounds much more complicated than it is. I'm sure you are familiar with For loops and how they work with Arrays. Are you familiar with creating Tasks inside LabVIEW Project? If so, go ahead and do so for your devices, and try building a Device Cluster such as I have described, and combine several of them (by hand, in LabVIEW, for testing purposes) into an Array. Now you can try creating a test array of just the Device Names and seeing if you can use the For Loop to get the corresponding Array of Device Tasks. Also see if you can (with a single For loop) start all of your chosen Tasks (you should probably also try stopping or clearing them). You are now On your Way ...
Bob Schor
06-25-2015 10:24 AM
Dear,
I've tried working with Clusters to configure my channels. I'm not gonna try to load the config from a file anymore, so i'm trying to do it when starting the program itself.
Now i've written some code, everything works, i think, but i get an error every time for the bridge configuration, every time it says that the requested value is <0> and the possible values are Full bridge I, II etc...
I don't understand how this comes...
I've attached my program to this post.
With kind regards,
Peter
06-29-2015 10:27 AM
Dear,
I have found what was the issue, I worked on my program, and tried to use Tab Control. However the Zero-ing of my channels won't work, also I couldn't get any reading on my graph....??
I've added my program in attachement.