06-21-2009 05:26 PM
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.
Solved! Go to Solution.
06-22-2009 07:11 AM
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
06-22-2009 08:52 AM
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.
06-22-2009 01:58 PM
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!
06-23-2009 02:00 AM
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
06-23-2009 01:49 PM
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.
06-24-2009 03:02 AM
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
06-24-2009 02:26 PM
Hi Jochen,
Here is the mofdified code which I am trying. Can you kindly help me trace where the error lies?
Thanks.
Sasi.
06-29-2009 03:47 AM
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):
Kind regards,
Jochen
06-29-2009 07:57 AM
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.