LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

input terminal configuration

I'm having trouble measuring accelerations, voltage and voltage with excitation on the same VI and wonder if someone could help.

I am using:

 

  • 10 accelerometers (4 channels in 9234 + 4 channels in 9233 + 2 channels in 9233)
  • 2 outputs from a strain guage transducer measuring just voltage (2 channels 9233)
  • 4 outputs from 4 strain gauge full bridges measuring voltage and applying excitation voltage (4 channels in 9237)

I think this is purely a coding issue as I have tried all channels with DAQmx signal express and they work well individually. The problem comes when I try to attach them all to one measurement task and therefore have to use different input configurations for each channel type. This looks fine in code but when I go to run it the code no longer triggers on my first accelerometer channel when I excite the accelerometer. I have attached the initial code which works when only using accelerometers and the new code which has all of the strain guage channels set up. Can anyone offer a nugget of wisdom?

 

Thanks, Alby

 

Old code.JPGNew code.JPG

 

0 Kudos
Message 1 of 6
(7,631 Views)

Alby,

 

     As this is your first Post here on the Forum, you may not have seen my numerous "rants" asking that you not post "pictures" of code (unless you post Snippets, which can be dragged into a suitable Block Diagram on our machines and magically become LabVIEW code), but rather post the VIs themselves.  The reason to do this is this lets us "play" with your code without having eyestrain or the risk of carpal tunnel syndrome as we try to reproduce your VI.

 

     A suggestion to help "clean up" your code and simplify your multi-channel question is to use MAX to create Tasks for each of your sub-Tasks.  If you open MAX, you can click on one of your devices (such as the 9233) and do a Create Task.  This takes you to a Wizard that asks whether you want to Acquire or Generate Signals, then lets you get more specific (Analog, Digital, Counter, Voltage, Acceleration, etc.).  It lets you select (and name, if you want) specific channels or lines, set up the timing source, set the Max/Min range, Terminal Configuration, Scales, etc, and then give this Task a meaningful name (like Neck Channels).  Note that these are largely the parameters that you are specifying in your VI using a bunch of DAQmx functions (and consuming considerable VI Real Estate).  With a Task, you open a single Config Channels function, connect a Constant to the Task input, click the Selector triangle, and choose the Task that MAX has saved for you.  Alternatively, in your Project, you can also create a Task and save it right in the Project!  [With MAX, you can test the code by running the Task ...].

 

     Try seeing if Tasks simplifies your life and your code.  If not, post your VIs and we'll take a look.

 

Bob Schor

 

0 Kudos
Message 2 of 6
(7,624 Views)

Bob_Schor.png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 3 of 6
(7,611 Views)

Thanks Bob, 

 

Apologies for the jpeg, I'm running Labview 8.6 and struggling to find a way to include code snippets. I've tried downloading the Code Capture Tool but it says it is incompatible with my version of Labview. I have attached a PNG, perhaps this will work?

 

Thanks for the MAX tip, it looks like it could certainly hep keep my code clean. However once I create a channel and wire the MAX Task I have created to it the Channel function still has a number of inputs which look like they need wiring up in the same way that I have done in my original code. Perhaps when run these take on the values stored in the MAX Task? If so is it possible to change these further down the line in the code (for example I want to vary the sample period and rate according to a user input on the front panel)?

 

Secondly, below is the code of the section of code which I think is falling over when I add in the different measurement types (strain gauge, accelerometer, etc). Normally, when all of the measurement types are the same the SW Trigger triggers on the first item in the array. Seemingly when I change one of the channels to a type which requires a different input terminal configuration (pseudodifferential / differential) then it stops triggering. Do you have any ideas? I am using a cDAQ 9172 chassis with the modules listed above. Perhaps it is something to do with the slots I am using? Stumped...

 

Thanks for your help,

 

Alby

 

Download All
0 Kudos
Message 4 of 6
(7,557 Views)

Yes, you attach your VI!  Now I can (hopefully) make some more helpful suggestions that should help.

 

First, I can't (yet) directly address the question you are asking (about the section of code in your PNG) because it is impossible to see the entire VI and to get an idea of what is going on!  I measured it, and with a 1280 x 1024 monitor, it is 6 monitors wide by 4 monitors tall, which means I can only look at roughly 4% of the code at a time.

 

When I was learning LabVIEW, the single most useful book I read was Peter Blume's The LabVIEW Style Book.  One of his "Style" principles was to keep every VI to the size of a single monitor.  But how can you possibly do that?  Be "aggressive" in creating sub-VIs!

 

Here's a (very brief) example.  Your routine starts with a screen-full of code on the left that does nothing but initialize DAQmx tasks, returning two "Task Wires".  Put all of this in a single VI whose icon, another "Style" requirement, says something like "Init DAQ Tasks".

 

Next, I see a very repetetive piece of code that involves removing sequential elements from an array, doing sequential things to them, and rebundling them into another array.  Because of the way the wires "go backwards" (a severe "Style" violation), I didn't realize that this was processing the output of the DAQmx read.  Again, this can all be "hidden" inside a sub-VI (with an icon having a name that says what you are doing).  Also, doing repetetive things to elements of an array just screams "For Loop with Auto-Indexing" -- this saves you picking out array elements and reassembling the array when you are done, a huge savings of screen space.  It should easily be possible to get this entire While loop down to a size smaller than this post.

 

Once you've gotten things encapsulated (a fancy word for "hidden the messy details inside a sub-VI"), you'll be able to see the Forest for the Trees.  Even better, you will have code elements that you can test in isolation to see if they "do what I mean, not necessarily what I say" (code has a nasty habit of usually doing what you tell it to do, whether or not that's what you really want to do).

 

If you don't have access to Peter's book, here are a few more Style Principles for you (I'm not necessarily quoting the Book, just listing things that I now tell my students) ...

  • All VIs should fit on a single screen.
  • (Almost) all VIs should use the 4-2-2-4 Connector Pattern, with Error In and Error Out on the lower corners.
  • All VIs (and many controls) should have an Icon that "self-documents" it (you should be able to fit 3 medium words).
  • All wires should run left-to-right, and be as straight as possible.
  • Don't be afraid to use Clusters to multi-element Input and Output connections.
  • All Clusters and Enums that you define need a TypeDef -- use the TypeDef "everywhere".
  • Try to make your sub-VIs have a single purpose.  Note that you can have a hierarchy of "purposes", as sub-VIs can (and, in many cases, should) have their own sub-sub-VIs.
  • Use LabVIEW Project to organize your "project".

I threw that last one in there -- I'm pretty sure LabVIEW Project was available in LabVIEW 8.6 (I got started with LabVIEW 7.0, which didn't have Project).

 

A final note -- if you follow these suggestions, you will end up with lots (maybe dozens and dozens, even hundreds) of VIs -- that's not only OK, that's probably a Good Thing, particularly if you keep them organized by choosing Good (mnemonic) Names and having a useful Folder structure.  But now how do you post your code?  Simple -- put the code you want to post (even the entire Project!) into a folder, compress the Folder with Windows to create a .ZIP file, and attach the .ZIP file.

 

Good luck.  I'm off to a conference, but I'll have my laptop ...

 

Bob Schor

Message 5 of 6
(7,538 Views)

@AlbyRoseveare wrote:

Apologies for the jpeg, I'm running Labview 8.6 and struggling to find a way to include code snippets. I've tried downloading the Code Capture Tool but it says it is incompatible with my version of Labview. I have attached a PNG, perhaps this will work?


There should definitely be CCT versions which can run on 8.6 and create snippets, as that feature was originally added in the LV 7.0 code, although I don't remember the specific version numbers. You can try installing older versions through VIPM or go to the LAVA CR and find the relevant version there.


___________________
Try to take over the world!
0 Kudos
Message 6 of 6
(7,476 Views)