LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tracking mechanism - while loop with voltage subtraction with shift registers

Solved!
Go to solution

Hi there,

I hope somebody will be able to help me with a simple (at least I was thinking like this) code… I need to implement the algorithm in Labview has been designed in Matlab/Simulink. The trickiest part for me was implementation of Memory blocks (initial value=350 and initial value=0) that will be able to save values for the previous iterations.

 

function u2=fcn(speed,u2d)

if speed>120

    u2=u2d+0.25;

else

    u2=u2d;

end

 1.png

AI measures an electro-hydraulic drive speed. AO generates a control signal that will power up the drive-train. When the speed exceeds a threshold (120 in our case) the code should decrease the control voltage in order to decelerate the drive and stay below the threshold without any further changes (hence the control system should keep the latest “successful” voltage). The model above runs the drive at 350 rpm from its start.

 

In the algorithm I am doing the comparison speed>120 and sending its Boolean output to a switch with two inputs (0 – false) and u2d – true. The reason I’ve designed to use 0 is because I don’t want any changes to the control voltage before the algorithm kicks in.   The code u2 = u2d + 0.05 is built on shift registers. And then u2/u2d I am subtracting from the control voltage to decrease it to the required level below 120 threshold.

 

The point is that after the comparison speed > 120 becomes “false”, I want to keep the value of the voltage (u2=u2d). But since I am using a switch in the top part, when it gives falls, it sends zero + 0.05 to the node AO0 and then the cycle starts again (these voltage spikes gives speed spikes). I was trying to use different combinations of switches and also case structures, but any results. I know that I miss something simple but could not figure what exactly. Will be great if somebody can help out with this case. Thank you in advance.

0 Kudos
Message 1 of 3
(2,695 Views)
Solution
Accepted by ESturov

Hi ESturov,

 

why don't you just program the algorithm from your comment?

check.png

(According to your comment you need to replace the ">=" by a ">"!)

 

The trickiest part for me was implementation of Memory blocks (initial value=350 and initial value=0) that will be able to save values for the previous iterations.

You're using LabVIEW for nearly 2 years now and still have problems with the very basic "shift register" usage? (Btw. you save values from previous iteration or for next iteration… :D)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 3
(2,673 Views)

GerdW,

As always you save me and my little project. Thank you. However, you can admit that my code was close enough to yours Smiley Happy But yeah, assigning zero to the left shift register is the best solution. I knew that I need to use this register as the last "successful" voltage but I admit that could not figure out how to make a proper start from zero volts and then get "u2" in the end of execution. 

 

" (Btw. you save values from previous iteration or for next iteration… Smiley Very Happy)"

 

Bummer, sorry for the typo Smiley Very Happy  I use Labview and my cRIO mainly as an acquisition unit and for FPGA programming (from time to time)... Can admit that sometimes I am not able to finish all required tasks. Thank you a lot for your help!

 

Best Regards

ESturov

 

 

 

0 Kudos
Message 3 of 3
(2,633 Views)