LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Please tell me what is wrong with my code.

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:

 

motorver1_0d (1).png

motorver1_0d (2).png

 

For my subvi:Motor_2.png

Motor_1.png

Motor.png

 

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.

Untitled1.png

 

0 Kudos
Message 1 of 9
(3,224 Views)

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.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 9
(3,212 Views)

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?

0 Kudos
Message 3 of 9
(3,207 Views)

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?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 9
(3,197 Views)

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?

0 Kudos
Message 5 of 9
(3,193 Views)

For learning state machine you can check here, here, here and here.

 

Good Luck

-----

The best solution is the one you find it by yourself
0 Kudos
Message 6 of 9
(3,181 Views)

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.

 

1.PNG 

 

 

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 7 of 9
(3,169 Views)

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.

0 Kudos
Message 8 of 9
(3,165 Views)

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.

0 Kudos
Message 9 of 9
(3,120 Views)