05-29-2012 09:51 PM
This is what I am trying to do with my first motor.
1) allow user to set the motor's initial position
2) allow user to set the increment value (step size)
3) set the maximum value that the initial value can increment to.
next add a second motor with similar function:
1) allow user to set the initial value
2) allow user to set the increment value (this increment value is the same as the motor increment value)
3) set the maximum value that the initial value can increment to.
The first motor first increment until the max degree then the second motor increment by the increment value.
The program only stop when 2 motor is at their respective max degree. This program can be pause anytime and the initial value can be change.
I am doing this to find all the possible combination.
The program I have now is:
For my subvi:
e.g I put the inital position for both to start at 10 and maximum position at 50. Can you tell me what is wrong there is repeated data. I need to finish this by today :(Thank alot!! I had done alot of attempt to fix it but it fail.
05-29-2012 11:37 PM
One important thing I observed here is you are running the loop without a delay never run the while loop like this ( if there is any delay inside the sub vi then it is fine ). What is happening inside the sub vi? Any data acquisition or some calculation?
The data is repeated means you are not meeting the condition properly or the condition kept is not proper.
05-30-2012 12:20 AM - edited 05-30-2012 12:27 AM
No there is no delay inside subvi. There is no data acquisition in the subvi. It is just simply setting the motor's position and the displacement. Those calculation code is just to make it as accurate as possible. The subvi is included in the image. Thank for your reply I added in the delay. How do I solve the problem I am encountering?
05-30-2012 12:33 AM
Its difficult to give a solution by seeing the Image. Do you want to stop the loop once the Target position of the Motor 2 is reached right?. So take a proper Design Pattern ( State Machine ) so in one state keep the motor 1 and once it is done go to the next motor in the next state complete the task and stop the code. Is this clear?
05-30-2012 12:42 AM - edited 05-30-2012 12:45 AM
Thanks!!! I am much more clear now. How do I implement the state machine. I need to complete all this by today, can you guide and help me? What do I need?
05-30-2012 12:52 AM
05-30-2012 01:34 AM - edited 05-30-2012 01:34 AM
Is your problem that you get repeated data in your 2d array? Since you use the build array function and also connect it to the shift-register, you will get an array that will keep growing and growing and that is not good over time. You should use Replace array subset instead of build array. Note that you'll need to initialize the array first.
05-30-2012 01:43 AM
Yes my problem is the repeated data in 2D array, but another problem is also to ensure that the motor will not repeat the same data as I need to acquire data from my other equipment using the motor combination.
05-30-2012 08:45 AM
Beside state machine anyone still got any suggestion or can find the error in my program? I found that it is hard for me to use because I need to integrate it with another program.