Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

returning the motor to the initial position at which it started?

Solved!
Go to solution

Hi,

 

I am writing an application to control an AC servomotor. It is based on torque feedback. I am using a state machine architecture. The result I am aiming for is,

 

1) The motor spins at a user specified velocity and accel/decel.

 

2) Whenever the torque toggles between the upper and lower limits, the motor spin direction is changed.

 

3) At the end (User specifies the no. of times it should do this cycling) the motor returns to the initial zero position at which it started.

 

4) Outputs the data to file and stops executing the program.

 

(1) and (2)  have been taken care of. However, I am still struggling with (3) and (4).

 

What I have been trying is, to make a note of the encoder position at the start of the program and then after n cycles subtract the current position from it and give it as an input to "Reset postion" state. Other thing I thought of is playing around with the voltages ( The starting voltage output from torque cell is always +5V) so I thought to call the "Run motor" state again at the end to move the motor to initial position. I have tried some trial and errors but am fultile in the efforts. 

 

Can anyone be of a kind helping hand? 

 

Thanks,

 

Sasidhar.

 

 

0 Kudos
Message 1 of 10
(6,281 Views)

Sasidhar,

 

what exactly are you trying to do with "Reset position"? This function resets the current value of the position counter of an axis to a user defineable value. Looking into your program I get the impression, that you are trying to load a target position with "Reset position". If this is the case, you should use "Load target position" instead.

 

Kind regards,

Jochen

0 Kudos
Message 2 of 10
(6,272 Views)

Thanks Jochen,

 

I understood what u said and made the changes.

 

In the Reset motor state, I changed the operation mode to relative position and gave the new target position as 0, but still after the final cycle my motor is not spinning back to 0.

 

Thanks.

 

Sasi.

0 Kudos
Message 3 of 10
(6,266 Views)

Hi Sasidhar,

 

 

 It sounds like you'd like for the motor to return "home"when the application is finished.  You should use the Find Reference.vi to There is an example on this in the example finder called Simple One-Axis Home and Index. 

 

Please note that you will also need to enable "home" and your limit switches within MAX: http://digital.ni.com/public.nsf/allkb/0806A5F3E582AE448625711D000CEA9D?OpenDocument. 

 

This should be a good start, please post again if you have more questions. 

 

Cheers!

Marti C
Applications Engineer
National Instruments
NI Medical
0 Kudos
Message 4 of 10
(6,263 Views)

Sasidhar,

 

as much I understood, you just want to return to the starting point and this is not necessarily the reference position of your system, so Marti's suggestion will only work in the case that your starting point equals to the reference point. 

In relative position mode the target position is entered in relation to the current position. So if you load a target position of 10,000, your motor will move by 10,000 counts. Loading 0 as target position in relative mode results in no move at all.

 

Your method will work fine, if you reset the position to 0 at the very start of your move sequence. At the time you want to return to your starting point you should configure the operation mode to "absolute position", load the target position (0) and execute the move.

 

Jochen

0 Kudos
Message 5 of 10
(6,250 Views)

I included a new set operation block in reset motor state. Told it to be in absolute position. and loaded the target position as 0. Also, in the run motor state, I added a reset position block with input as 0.

 

But this too doesn't work. After my nth cycle the motor stops there only. It is not coming back. Is there anyway to include in the current logic telling the motor to continue moving in the opp vel till voltage is 5.

 

Thnx.

 

Sasi.

0 Kudos
Message 6 of 10
(6,241 Views)

Sasidhar,

 

I don't know your code well enough to be able to follow your description. Please post your modified code again. In general: If you reset the position to 0 and then command the axis to move to position 0 the motor won't move at all, as it is already at the commanded position.

 

Jochen

0 Kudos
Message 7 of 10
(6,236 Views)

Hi Jochen,

 

Here is the mofdified code which I am trying. Can you kindly help me trace where the error lies?

 

Thanks.

 

Sasi.

0 Kudos
Message 8 of 10
(6,223 Views)
Solution
Accepted by topic author Sasidhar

Hi Sasi,

 

for the case that you haven't found your programming mistake by yourself, yet:

After your state machine has entered the "RESET POSITION " state you start a move to position 0 but you don't wait until the move is complete (this should be an additional state). Instead you branch immediately into "STOP MOTOR" and this halts the move without returning to the initial position.

 

By the way, there are several things in your code that could get optimized (here are some examples):

 

  • Comparing a boolean value like your STOP button with a TRUE constant is redundant, as the output is always the value of your STOP button. This is kind of a Rube Goldberg code.
  • Your initialize state executes the same sequence of commands (move motor position 0) until the START button is pressed. This is a lot of redundant commands sent to the motion control board.


Kind regards,

Jochen

0 Kudos
Message 9 of 10
(6,182 Views)

Thanks Jochen, It helped. And also thanks for your inputs on other parts of the code. As I mentioned to you earlier, I am new to LabVIEW and so the redundancy in many parts. I am attending a course held by NI this month. Hope that would help in getting cleaner code.

 

Sasi.

0 Kudos
Message 10 of 10
(6,177 Views)