LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shift register

Hi there, 

 

Actually i am having a trouble to initialize a shift register, so my purpose is that like the following: 

i am having a matrix within a for loop and in each iteration it has a proper value, so all what i need is to multiply all these matrix with each others. i though about using a shift register but it must initialized cause the first iteration might be the first matrix times the identity matrix.  

 i am willing to hear any other manner that serve the same purpose  or how to initialize the register.

Please check the picture below for further illustration. 

Thanks 

0 Kudos
Message 1 of 9
(3,653 Views)

That inner FOR loop looks like it is not needed at all.  All you are doing is multiplying a 2D array with itself 6 times.  I think you need the shift register on the outer loop.  If you know the size of the matrix, then initialize with the identity matrix.  If you do not know the size, then initialize to an empty array.  On the first iteration (i = 0) set the value to the current value.  Subsequent iterations perform the multiplication.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 9
(3,645 Views)

We don't debug pictures, so please attach the VI and subVIs.

 

I would recommend a few simple tutorials on LabVIEW and dataflow, because there are some glaring weird code constructs, for example:

 

  1. Index array is re-sizable, you don't need four instances for the same source array.
  2. What's the size of the 2D array coming out of the subVI?
  3. It would be much cleaner if the inner subVI would have a 1D array input instead of four scalars.
  4. Array multiplications are element by element. All that ever survives the inner FOR loop is the diagonal. You might as well represent the diagonal as a 1D array during all the computations (unless you are trying to do matrix multiplications. In that case, you are using the wrong datatype and primitives). Just multiplying a 2D array with an identity matrix and itself N times can probably be simplified, right?
  5. The comparison and boolean output at the bottom is guaranteed always the same when the loop completes and can be eliminated completely. No data leaves the FOR loop until the loop is completed.
  6. I assume all the indicators in the inner FOR loop are for debugging
  7. A "stop button" does not work as expected if the outer WHILE loop condition is "continue when true".
  8. Once the outer FOR loop is done, "Array" only contains the result of the last iteration. Unless the intermediary values are used for some animation or the subVIs do something interesting used elsewhere, all you need is to do the last iteration of the outer FOR loop.
  9. "iteration" is spelled wrong twice (unless it is some foreign language)
  10. The first "index array" could be replaced with autoindexing.
  11. ...

Again please attach the VI and explain what it is supposed to do.

 

 

0 Kudos
Message 3 of 9
(3,628 Views)

Thanks,  i am glad to hear such tremendous response thanks. 

Okay i will attach the VI below as well as for the whole post. 

all what i want is to multiply all that matrix with each other like H06=H01*H02*H03*H0i....

Thanks

Download All
0 Kudos
Message 4 of 9
(3,619 Views)

@DALIXX wrote:

 

all what i want is to multiply all that matrix with each other like H06=H01*H02*H03*H0i....

 


As I said, you don't have a "matrix", just a 2D array. If you want real matrix multiplication, you need to change things. Multiplications on arrays are "element by element", while matrix multiplications are very different. So what is it?

0 Kudos
Message 5 of 9
(3,614 Views)

Here's how you would do it using matrix multiplications. Of course order matters so switch the multiplication inputs if needed. I am sure the mathscript node could be easily replaced by plain G code.

 

This is just a quick draft, check for errors and things... No guarantees.

 

MMult.png

 

If you want  plain multiplications, modify as needed. Should be trivial to change.

 

(Of course you don't need the delays and indicators in the FOR loop, but I left them in to aid in debugging)

0 Kudos
Message 6 of 9
(3,600 Views)

Thanks, 

Your kindly gesture it's deeply appreciated, 

You gave me the clue to solve my problem and i did, 

So now my issue is that i need to use all that code to generate the inverse kinematic using the Robotic Solver. 

May you please check the attachments below for what i did and what i am willing to do. 

 

Regards. 

0 Kudos
Message 7 of 9
(3,560 Views)

Sorry, I don't have the robotics module. Cannot help further.

 

  • You still have that completely pointless comparison with 4 and incorrect stop condition. Get rid of it! Why is there even an outer while loop to recalculate the same things 5x per second.
  • Your multiplication subVI will not work as you think it should because the feedback node is globally initialized. Basically, you are piling on the calculations with every iteration of the outer while loop. Why do you stray so far from my advice? I never told you to do it that way.
  • You have not implemented any of my suggestions, so please do that.
  • ... and why are most of your diagrams and front panel maximized to the screen? That's very annoying and interferes with debugging.
0 Kudos
Message 8 of 9
(3,544 Views)

Please keep it all in one place. Continued here.

0 Kudos
Message 9 of 9
(3,538 Views)