LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programming

Good day all,

An advice on what to do in this case would be appreciated.

I have two amplitude data that I am getting based on the motion of a motor. Lets say the two amplitudes are X1 and X2. If the motor moves CW let say I get X1 and if CCW lets say I will get X2.

 

The movement of the motor will either cause X1 to be greater than X2 or X2 to be greater than X1. So at any time that the motor moves it will make one of the two ( X1 or X2) to be the smallest.

I already wrote a code to move the motor and then  obtain X1 and X2 sequentially using  the sequence structure in labview.

 

My problem is how to  write a code to determine the lowest value between X1 and X2 and ask the motor to repeat the motion that caused the lowest ( I mean the lowest between X1 and X2).

I would have love to attached my code but it is just to big and their is no ZOOM OUT options on the block diagram yet.

 

Please how do I do this. Thanks in anticipation.

0 Kudos
Message 1 of 18
(3,268 Views)

If you attach the actual VI, there is no zooming needed.

 

What makes the motor move and what makes the X1,X2 to be different for each run? 

0 Kudos
Message 2 of 18
(3,260 Views)

And if you actually need a ZOOM capability perhaps your block diagram is too big and you need to rethink your design. As noted, post your VI so you can get better help.

0 Kudos
Message 3 of 18
(3,257 Views)

 

The motor is moving based on certain frequencies that the accelerometer gets. If the accelerometer reading(peak frequency) is within the three ranges of 4-8Hz,15-20Hz and 25-30Hz then the motor will move to position A, B, C, respectively where A is for frequency 4-8, B is for 15-20Hz and C is for 26-30Hz.

Attached is vi as requested.

The comparison palette at the end is where I opt to to solve my problem and where I did felt their should be a better way of comparing the two accelerometer signals which will then be the means of deciding where the motor moves to.

Thanks in anticipation

0 Kudos
Message 4 of 18
(3,252 Views)

How do you operate this? Why are the controls and indicators spread over an area the size of about 60 screens?

0 Kudos
Message 5 of 18
(3,240 Views)

Houston, we have a problem. Well, more than one, actually:

 

  • Why do you need 9 stop buttons?  Smiley Surprised
  • Why do you need all those graphs?
  • NEVER, EVER use equality to compare floats. You owe me another nickel in my retirement fund.
  • How is this VI run? Are you using the Run Continuously button? It seems as if you are. If you are, STOP. That is only supposed to be used for specific debugging instances. 

I don't understand the overall operation of this VI. I don't know what those subVIs are doing, so I don't know if having them would make it more clear, but I sincerely doubt it. Can you explain what the various frames are doing?

 

I would strongly suggest you look at some basic programming architectures. It seems to me that the state machine is the most suitable one here. Application Design Patterns: State Machines

 

 

EDIT: Well, it's comforting to know that I wasn't the only one not able to understand the VI.

0 Kudos
Message 6 of 18
(3,235 Views)

To add what has been posted already you should not use controls and indicators as variables. LabVIEW does not use variables like traditional programming languages. Think of the wires as your variables. (They aren't techinically a variable but it is the core method for passing data.)



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 18
(3,214 Views)
Good Morning all, and thanks for your usual support. Though I felt like I have been batched but anyway thanks it is from your comments that makes me learn the more.

I am working on a state machine vi (as suggested in your response) for my project and having some issues on it, I would like to get your assistance. Let me explain what I am trying to do first and then I will state my problem(s).
I am using an accelerometer to acquire vibration signal from a building. My main aim is to get the frequency and amplitude of vibration.I have been able to use the Sound and Vibration Toolkit effectively for this. I am suppose to get 3 frequency and 3 amplitude. This I have also done  thanks to labview. Depending on the frequency of vibration, I want to send TRIGGERS to a motor using the serial communication port and VISA in labview. When I send the triggers I want the motor to move to 3 positions.Each position of the motor corresponds to the 3 frequency I mentioned earlier. I mean if for example I have  frequencies A(Hz), B(Hz), and C(Hz), I want the motor to move to position A(m), B(m) and C(m) respectively. I have been able to do this also using LABVIEW VISA. If I move the motor precisely to those positions A, B and C(m), the amplitude of vibration is suppose to reduced based on theory. and simulation. To automate the whole process
I believe state machine would be the best options to solve my problem considering the fact that the motor will be moving to get the best position to reduce the vibration amplitudes and the numerous sequence involved.
I wrote a state machine vi using labview.(I am sure it is not the best but pardon me if you see fundamental errors).
Below are the issues which I will like you to assist on:
1) I want the vi to first acquire the vibration signals using DAQ and then generate the 3 frequencies and amplitude which will be sent as triggers to the motor. I already define the three frequencies using the INPUT VALUE you can see on the vi. Please how do I configure the input value depending on which of the three frequencies to send TRIGGERS to the case structure (which will move the motor the way I want).

2)If I use the Highlight execution button, I noticed that in the case structure I want the states to run until they get to the end. THIS IS NOT HAPPENING. Example if you run state 1. The execution will stop at "Calibrate motor" state. I want it to run and stop at "END" state. How do I do this.
3) Lastly any suggestion on how to make this work will be further appreciated.
0 Kudos
Message 8 of 18
(3,168 Views)

I'm no trying to bash you but this is a very strange implentation of a state machine. The outer case state doesn't seem to serve any purpose. The state machine should consist basically of your inner case statement. The logic required to select the next state should be within the states themselves. Also,  your ENUMs should be a typedef. If you modify the ENUM you will have to manually update every copy of it in your program. A typedef would update all of them automatically.

 

The reason your state machine stops unexpectedly is because it is doing exactly what you coded. In the example you provide (calibrate in case 1) you are passing a True value out which causes you to exit. You need specific logic in your state macine to determine when to stop.

 

Before writing any code you should probably sit down with pen and paper and define your states and the transitions. As written it is very difficult to read your code and trace what is supposed to happen.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 18
(3,150 Views)

Thanks Mark.

Let me explain why I have put a case structure in a case structure. The outercase is suppose to select if I have Different frequency i.e. if I have frequency between 4-8Hz, 15-18Hz and 25-30Hz which I think are 3 different cases. Also for each of these 3 different cases, I have sequence of states from "initialize" to "Default". Though the 3 different frequency states runs same state(s) from "initialize" to "default" . Please kindly suggest what to do on these.

As for the enum typedef I already read now and change to it. Thanks for your advice

0 Kudos
Message 10 of 18
(3,143 Views)