LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Software to analyze Triaxial accelerometer to determine orientation information.

I am trying to write a program that will turn on an LED when the 3 axial accelerometer (ADXL337) detects that it is on a flat surface. The accelerometer is correctly hooked up to my NI 9228 module, it is the code writing/analysis that I cannot figure out.

0 Kudos
Message 1 of 4
(2,230 Views)

Problem is almost certainly caused by strange behaviour with Dynamic Data Type wires (the blue ones).

These are fine but difficult for me and lots of other users to understand.

 

A much better choice is to use the standard operations. For example, in your Case Structure, you're checking if 3 values are between 3 pairs of values, and presumably the output should be "Are these all true - yes/no?". To do that, you can simply use the "And" version of the Compound Arithmetic Operator.

car.png

To do this, I simply dropped a Compound Arithmetic node (found on Numeric or Boolean palettes - I used Ctrl+Space, then typed "car" which is the shortcut using quick-drop), then dragged down one slot (like with Build Array) to create 3 inputs. I wired it (you'll get broken wires if you use the Numeric palette or Quick-Drop options, but this is fine) then left clicked on the + symbol (the default from QD or Numeric) and chose "Change Mode" > "AND". You can also do "Add", "Multiply", "OR" and "XOR" with this node. To do subtractions, choose Add and then right click on an input and choose "Invert" (you'll see a little stub appear to the left - this negates the input so you get A-B == A + (-B) ). Same with divide (A/B == A * (1/B)).

 

As an aside, you also don't need to wire all the inputs to Index Array.

The following demonstrates a similar case:

indexOnlyNeeded.png

The outputs for this code are 0, 1, 2, 5, 6, 7 (i.e. first 3 elements, since no index wired, then the next 3 elements starting at 5, since that's wired to the 4th input).


GCentral
0 Kudos
Message 2 of 4
(2,161 Views)

Have you examined the specifications of your accelerometer?  Did you notice its voltage range?  Are you using a "reasonable" voltage range on your A/D converter?  [I'm guessing the answer to all three questions is "No"].

 

Before even thinking about LabVIEW, you need to think about the question you are trying to answer and come up with some reasonable definitions.  The first question I would ask is what you mean by "is on a flat surface".  Can you define this relative to the coordinate frame of the accelerometer?  Which axis (or axes) do you think would be most critical to measure to give you the most precise answer?

 

Once you have some better idea of your device and your sensor, you can start to formulate how you might get useful information from your sensor.  Once you know that, you can start thinking about coding ...

 

Bob Schor

0 Kudos
Message 3 of 4
(2,121 Views)

@cbutcher wrote:

..., then dragged down one slot (like with Build Array) to create 3 inputs.


It would be so much easier to just carry the data as arrays of three elements. (3x fewer wires and diagram constants, easier to read code, etc.) Here's an example.

 

(and yes, try to avoid dynamic data unless absolutely necessary)

 

corallingwires.png

 

(of course it seems silly to show the coerced output, so you might want to tap into the wire before coercion for the upper chart. It's not clear what you really want).

 

 

0 Kudos
Message 4 of 4
(2,107 Views)