LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Shift Register?

Hi
 
Today I spend hours to ficure out how to use a shift register with labview.
I am going to calculate the acceleration of the wheels of an RC-car.
I want to use the simple function to calculate the acceleration.
 
a=(v1 -v0)/time
 
From this it follows that I need two speed (ms) values. I was thinking about including a shiftregister that I made before (attached) into the SpeedAngle.vi
But that doesn't work.
Is there maybe an other way to store two following values of the calculated speed? So that I can use it for further calculations.
 
Thank you!
 
 
Attached the two program files.
 
Bye
Download All
0 Kudos
Message 1 of 9
(4,552 Views)
Hello lableo,

I modified your example... I hope this helps!

Everytime you call this vi the "new value" is put into the shift register. The 3 lastmost values are shown (t-0, t-1, t-2) and the last 2 deltas are calculated.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(4,537 Views)

Hi LabLeo,

I unfortunately cannot open you vi's at this time because i do not have LV installed at my customer's site.

However, I can suggest the following:

Shift registers are used within a loop (while, for) to pass the last value to the next iteration of the loop.  You can initialize the shift register from outside the loop with a default value (shift register to the left of the loop).  I think that in your example, the last value would be Vo.  At time t=0, you could initialize the shift register to 0 (Vo = 0 for the first iteration).  You would pass the sampled speed V1 to the shift register on the right of the loop and it's value would be Vo in the next iteration. 

As for storing two values, you have to be careful if you want both in shift registers.  For instance if you expand the shift register down (multiple shift registers), it becomes a buffer... the top value works it's way down.  But in your example, you don;t really need to store the 2 values, do you?  You're newly sampled velocity should be used in the present calculation and passed to the shift register.  As for the old one, it is "dropped" at the end of the loop.

Unless you want to keep track of acceleration..  (I can't see your vi).  If so, then creating an array would be better.

Hopefully the explanation of the shift register helps.  If no one else posts a reply, you can post a jpg image of your vi.  I can then look at it from work.

Thanks,

Ray

Message 3 of 9
(4,534 Views)

Hi LabLeo,

Please take a look at the following example...

Hope this helps!

Alex

Message 4 of 9
(4,531 Views)

Hi

 

Thank you very much. Now it works. Attached you will find the program. Now I need to adjust the car with the program. Hope this also works.

 

One more question. Why isn't it possible to use a Numeric Control twice?

Because I wanted to use the Numeric Control that I use for the time constant (time) also for the calculation of the acceleration.

That doesn't work. Than I placed a Numeric Indicator to display the value of the time constant. But it just displayed the default value.

Bye

 

 

0 Kudos
Message 5 of 9
(4,505 Views)
Hello LabLeo,

you can use controls twice (or even more often). But this depends on the real usage:
1) you can use wires from your control. Then it will be read just once and this value is used in all wired computations.
2) You can use local variables (property nodes: value will also do). Then the value of the control is read whenever you read from the local. So you get the actual value of the control, but you have to take care of race conditions!


Message Edited by GerdW on 11-10-2005 10:33 AM

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 9
(4,499 Views)
Hi
went through ur VI
 but could not understand what you mean by; "Why isn't it possible to use a Numeric Control twice?" and the succeding part of your query
do you mean you want to use time control value in derieving accleration?
could u plz eloberate?
 
regards
 
dev
 
 
 
Message 7 of 9
(4,495 Views)

Sers

I hope the picture makes it obvious what I am going to do.

I want to use the time constant on top also as the divider for the acceleration function. But when I just connect it to the input of the divide function it doesn't work.

 

Bye

0 Kudos
Message 8 of 9
(4,481 Views)
Hello LabLeo,

what do you mean with "it doesn't work"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 9
(4,474 Views)