LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pass value through cases in cases structure

Hello everyone

 

I am in the same situation as Monse. I have 5 different cases which are being controlled of 4 round led booleans. I have a stepper motor which controls a surface that moves in a circular way , and an optoswitch sensor that i am taking the signal (Voltage ). In each case there are defined steps for the stepper motor but not for the 2nd case where i have to know the indicator of min index that exists in the first case. So in the first case when booleans are all switches off, my stepper motor moves for one revolution (8000 steps) and an indicator shoes where is the minimum value (min index). So to go to the initial position i have to connect the indicator of 1st case to the steps definition (2nd case , DAQmx Timing>Samples per channel). I tried with feedback node but my stepper didnt move. I attach the current VI. I dont know where is my mistake.

 

Thanks in advance

0 Kudos
Message 11 of 16
(403 Views)
  • The scalar value in your feedback node gets reset to zero except in the few cases where it is wired. Is that what you want?
  • Why is there so much duplicate code???
  • Why do you create the same virtual channels over and over? Most you never close later.
  • What is the point of converting a 1D DBL array to dynamic data and immediately back to a 1D DBL array?
  • Why do you use LEDs as controls? They are typically more suitable as indicators.
  • Is it allowed to have more than one LED lit? If not, why don't you use a radiobutton control instead?
  • Why do you have so many stop buttons? Most trapping the code in a innermost loop. Any random button press will screw up the execution irreversibly.

I would say clean up the code and things will fall into place.

0 Kudos
Message 12 of 16
(382 Views)

First of all thanks for your answer.

I am new to labview programming so i understand that my code is a little complex.

As for your notes:

 

1)The 2nd case is the only case that my feedback node needs to have a value. As i explained before, running the 1st case i am taking a value from an indicator( min index) and this value needs to the 2nd case which will be the step definition value (DAQmx Timing>Samples per channel). I want to put the first boolean "true" and automatically my stepper to moves the "min index" steps. I am doing this with the feedback node and my stepper motor not moving. Am i doing this wrong? 

2)Yes you are right. I cleaned up a big part of my code that is useless, mainly the tasks with signal sensor because the only case that i need them is the first one.

3)I think that i corrected that. Now its only one virtual channel that is repeatable (CO Pulse Freq) for all the cases...i dont know if i could put this out of the case structure maybe??

4)I had forgotten to correct this. Of course you are right. There was no point to do this.

5)I use LEDs as control for my personal choice not for any other reason.

6)I have never used until now radiobutton controls. I dont know much more about that. Do you think that its a better solution? 

7)As you know, these stop buttons come from the inner while loop with the use of DAQmx is task done. I used this from an example that said "this loop ensures that the task has completed before attempting to clear it" and i did with the same way. I tried to run the code without this loop and i had some problems like running in a continuous way or with a very slow frequency. Maybe this loop is useless but with this loop my stepper motor runs exactly as i define.

 

Thanks again for your help. 

 

0 Kudos
Message 13 of 16
(353 Views)

I attach the current VI.

0 Kudos
Message 14 of 16
(349 Views)

@ChrisEv wrote:

7)As you know, these stop buttons come from the inner while loop with the use of DAQmx is task done. I used this from an example that said "this loop ensures that the task has completed before attempting to clear it" and i did with the same way. I tried to run the code without this loop and i had some problems like running in a continuous way or with a very slow frequency. Maybe this loop is useless but with this loop my stepper motor runs exactly as i define.

 

 


I would go back and take a closer look at that example again.  I doubt that they had it the way you have it wired up.

 

Right now the VI doesn't care whether the task is done (you never look at its output).  It only cares whether the user happens to have clicked the correct stop button (how do they know which is the correct stop button for a particulare case?).

 

The boolean output of the Is Task Done should be wired to the stop terminal of the loop.  You should also have a small wait statement in there so it is not a greedy loop.

0 Kudos
Message 15 of 16
(344 Views)

Hi RavensFan

 

This is the link where there is the example that my code was based on. Is there a mistake??

 

https://decibel.ni.com/content/docs/DOC-35115

 

i am trying to understand what you said so i am looking closer to these nodes. I dont know exactly the best way to do this.

 

Thanks for your help

 

0 Kudos
Message 16 of 16
(336 Views)