11-30-2011 06:09 AM
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.
11-30-2011 07:33 AM
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?
11-30-2011 07:42 AM
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.
11-30-2011 08:05 AM
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
11-30-2011 08:30 AM
How do you operate this? Why are the controls and indicators spread over an area the size of about 60 screens?
11-30-2011 08:35 AM - edited 11-30-2011 08:35 AM
Houston, we have a problem. Well, more than one, actually:
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.
11-30-2011 10:11 AM
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.)
12-05-2011 08:08 PM
12-05-2011 10:34 PM
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.
12-05-2011 11:05 PM
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