moha_sa Posted February 15, 2022 Share Posted February 15, 2022 I aim to update the desired position of Motor#n in a user-defined servoCtrl externally via a background C program. Unfortunately, as soon as I enable motor by Motor[n].ServoCtrl=1 command in terminal, the desired value of Motor[n].DesPos on watch window resets to zero. How can I avoid it? My goal is to update the value of Motor[n].DesPos in user-defined servo from a background C program. Quote Link to comment Share on other sites More sharing options...
Eric Hotchkiss Posted February 16, 2022 Share Posted February 16, 2022 If a motor's servo algorithm is enabled, PMAC will write to certain registers for that motor every servo cycle. You will not be able to write to these registers directly. Fortunately, PMAC has several ways to inject a little bit extra into a few of them for flexibility. In your case the easiest method will be to enable the motor at a position of 0 #nJ=0 and write your desired position to Motor[n].MasterPos. Note that Motor[x].MasterMaxSpeed and Motor[x].MasterMaxAccel can be used to smooth this trajectory. If you are already using Motor[x].pMasterEnc for position following this may interfere. This method is better suited for cases where you are creating a smooth trajectory and calculating a desired position every servo cycle. A custom servo routine for motor 0 would be a good location if it is not computationally intensive. It is also possible to jog motors or run motion programs from C code. This allows you to take advantage of PMAC's trajectory generation. 1 Quote Link to comment Share on other sites More sharing options...
JeffLowe Posted February 17, 2022 Share Posted February 17, 2022 Motor[x].CompDesPos is also an available node for injecting externally generated trajectory if not targeted by a CompTable. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.