10-16-2018 07:12 AM
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
10-16-2018 07:39 AM
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
10-16-2018 07:48 AM
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.
10-16-2018 07:59 AM
10-16-2018 08:12 AM
Thanks, GerdW,
you're right, so the code is a bit simpler