LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

New at LabVIEW, please help

So I started working with this program but there is a problem.
This program is used for changing the direction of the servo motor. When the signal value doesn't exceed the treshold value then the Case structure value is FALSE. 
Next, when signal exceed treshold, TRUE value of the case structure  negates the initial false value of the memory block and we get true value on the output of the case structure. This value is sent to Select function and we send value 1 to motor direction control. So far so good 

But, when we have second iteration where true value from the output of the case structure is input value of the memory block, that's where the problem begins. For the TRUE case, memory block value, which is true, is being negated so we get false on the output of the case selector even though we have true on the input of the case selector.  
I really hope you can understand me and i would really appreciate your help. 

I will also attach diagram 1 of the servo direction, where you can clearly see that the direction is constantly changing and diagram 2 where is shown what the diagram should look like. 

Thank you for all your help 

Download All
0 Kudos
Message 1 of 5
(2,236 Views)

In general, it is better to post your actual VI instead of just images. This way we can open the code in LabVIEW and possibly run it ourselves to investigate the problem.

 

It sounds like your goal is to only change directions when the signal goes from below the threshold to above it rather than every loop iteration that it is above the threshold. If that is the case, then you need to check for a rising edge in your signal rather than just comparing it to the threshold. This is very simple to do. You just compare the previous value of your "Signal above threshold?" boolean to the current value of it.

 

For example, if the last iteration resulted in Signal above threshold? being false, and this iteration it is true, then change direction. If the last iteration Signal above threshold? was true and this iteration it is still true, don't change direction. You will need to add another feedback node or shift register to keep track of the Signal above threshold? value, or better yet you can do it in a functional global variable!

 

-Jordan

Message 2 of 5
(2,226 Views)

I'm not sure that I understand the task correctly, but I think you need something like that.
Change the direction of rotation only if the threshold was crossed in any direction.

direction.png

Message 3 of 5
(2,220 Views)

Hi Artem,

 

what about replacing that NOT and the Select node by a simple XOR?

Best regards,
GerdW


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

Thanks, GerdW,

you're right, so the code is a bit simpler

direction2.png

Message 5 of 5
(2,200 Views)