Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

motor code

Solved!
Go to solution

Hi,

 

I took the example Velocity Profiling and modified it for two motors, the error came out said no Board ID are wired, but they are wired. Can anyone check the code for me please?

 

Thank you

 

CKH

0 Kudos
Message 1 of 25
(6,280 Views)

Please ignore the first post, I found another sample than can control 2 axes at the same time, this is exactly what I need. However, the motors will not stop after i click the stop button, I have to run another program to make them stop, is there any way I can fix the issue? Another question I have is, how can I make 1 motor run CW the other one run CCW?

 

Thank you

 

CKH

0 Kudos
Message 2 of 25
(6,272 Views)
0 Kudos
Message 3 of 25
(6,271 Views)

Hi there. Let me try to answer your questions. 

 

1) To stop the motors, you have to include a "Stop Motion.flx" function outside of the while loop. This way, when you hit the stop button on the front panel, it exits the while loop (that's what the stop button controls), and then the "Stop Motion" functions execute and stop the motors. I've attached modified code that should accomplish that.

 

2) To go the other direction, try putting in a negative velocity.

 

I hope this helps. 🙂

Ravi A.
National Instruments | Applications Engineer
0 Kudos
Message 4 of 25
(6,258 Views)

I didn't attach the file. Woops! A classic mistake.

Ravi A.
National Instruments | Applications Engineer
0 Kudos
Message 5 of 25
(6,257 Views)

Hi Ravi,

 

Thanks for the reply, I solved the direction problem by adding negative sign on the step poistion, I'll try the velocity as well.

 

Thank you,

 

CKH

0 Kudos
Message 6 of 25
(6,255 Views)

Hi Ravi,

 

I tried to put the stop motion into my vi, but the motor still moving forward after I hit the stop button, I have to go to MAX manually reset the poistion "Reset Position button". Is there other way that I can stop the program whenever I want?

 

Thank you,

 

CKH

0 Kudos
Message 7 of 25
(6,233 Views)

Hi Ravi,

 

I solved the stop button problem now, but is there a way to reset the position to 0? After I stop the motor and try to run it again, it will pick up previous position and continue the count from that specific position, I know I can try to reset it in MAX, but just wanted to know if there is any easier way to do.

 

Thank you,

 

CKH

0 Kudos
Message 8 of 25
(6,226 Views)

Hi CKH,

 

So right after your Stop Motion.flx VI, you can put a "Reset Position.flx" VI, located in the Functions Palette at Vision and Motion >> NI 73xx >> Trajectory Control. The attached screenshot shows you where it is. If you'll notice, the functions around here provide many control options for your motor, many of the operations you perform in MAX.

 

I hope this helps. 🙂

Ravi A.
National Instruments | Applications Engineer
0 Kudos
Message 9 of 25
(6,220 Views)

Hi Ravi,

 

Right now I am looking for much simpler way to switch the motor direction, from CW to CCW, I'm thinking making a switch do the work. I know I can just mannually added a negative sign in front of the target position, but I think if I can just add a trigger switch function, this might be easier. Is there any way to do it, I was thinking duplicate the same code but using "negative sign" times the "position" to make it negative target position under "case structure".

 

The following is the vi I created before adding the trigger switch.

 

Thank you,

 

CKH

0 Kudos
Message 10 of 25
(6,213 Views)