03-08-2024 04:27 AM - edited 03-08-2024 04:57 AM
Dear Labview Community,
I am constatly facing two issues with my Labvew code -
1. My q_dot matrix in the code is not giving result, though it should give. (I checked multiple times)
2. I wanted to increment the dt value from 0 to T at a particular time instant using let say 0.02 sec.
3. I wanted to execute the loop at frequency of 200 Hz.
Looking froward help from community.
Solved! Go to Solution.
03-08-2024 06:21 AM
Since you're using lots of Local variables it screams Race Condition.
03-08-2024 07:05 AM - edited 03-08-2024 07:05 AM
what shall I do to avoid the Race codition ?
03-08-2024 07:12 AM
Connect data with the wires so you know what state it's in.
03-08-2024 07:56 AM
I am only using local variables for some parameters which is need for other calculation. You are asking me to connect each and every parameters from the source instead of using the local varible.
03-08-2024 08:16 AM
@rishab_kr wrote:
I am only using local variables for some parameters which is need for other calculation. You are asking me to connect each and every parameters from the source instead of using the local varible.
Yes.
As you've done it, there are lots of race conditions. I wouldn't expect it to work. Learn how to code using dataflow.
Also, your block diagram is way too big (and you've got a superfluous sequence).
03-08-2024 08:28 AM
You will greatly benefit by applying some basic "Good LabVIEW Style" guidelines to your Block Diagrams. Here are a few important starters:
For what you are trying to accomplish, I would recommend something like a State Machine (perhaps something as simple as a While Loop surrounding a Case Statement, with the Loop Index, "i", wired to the Case Selector and the "Cases" being "0", "1", "2", ..., <last case #>, "Default", where the "Default" "catches" all the numbers you don't specify. Note that when this runs, it automatically does the "steps" from 0 to <last case #>.
As for your variables, put a bunch of Shift Registers up at the top and use them to "hold" the Variables. Wire them "through" the Case Statements. Because they are on Shift Registers, they will all hold "the latest values" of these variables, there are no "race" conditions, all the Variables are in one place and easily visible to any Case, and if you want to do an operation (say, add A to B and put the result back in A, leaving B intact), you put in "Add" in the appropriate "Case", drop a wire from the "A Wire" and "B Wire" to the input of the Add, delete the wire going to the Case output tunnel for A, and wire the output of the Add to that tunnel. Of course, you can do multiple arithmetic operations in each Case, and you can also organize it so you do, for example, all your "Build Matrices" in one Case, your "Use Matrices" in another, etc.
Note that there are more "elegant" ways to do this, but this should get you started thinking about Data Flow programming, on which LabVIEW is based, with (for LabVIEW) the data "flowing" in the wires.
A Clean Block Diagram is so much easier to create/build/use/debug/understand than a chaotic mess. Data Flow Is Your Friend!
Bob Schoe
03-08-2024 10:23 AM - edited 03-08-2024 10:26 AM
Thanks Bob, For your time and letting me know about the mistakes I should take care of. I am bigginer to Labview, as I have shared my labview code can you point out the mistakes that I am doing. I understand a bit in above replay.
Thanks Again.
03-09-2024 07:53 AM
Hello Ni Community,
I need your help, In the attached VI finally I am calculating the q_dot matrix by multiplying the x_dot matrix by the pseudo inverse matrix. Ideally It should give an output of 2*1 matrix but, it is not giving any result.
It would be a great help if anyone let me know where I am making the mistake.
03-09-2024 12:20 PM