Amar Posted October 3, 2017 Share Posted October 3, 2017 I am trying to implement cascade loop with analog feedback in PPMAC. Resolution of the analog feedback is +/-10 volts mapped into -32767 to 32767 counts. I am giving this signal to a virtual axis through encoder conversion table. I am closing the virtual loop by giving command #14j=32767. I want to make error zero. Somewhere i am making mistake. After some time Motor[14].IqCmd is reaching at 32767 and it will stop motion of inner loop if still error is there. Please suggest me if i am making any mistake. Below is the setting for encoder table, outer loop motor and gearing with inner loop. ptr ainError->Acc28E[4].AdcSdata[3] Sys.Idata[1501] = ainError + 32767; //(Error will be +/- 32767) //Encoder table settings EncTable[12].type = 1 EncTable[12].pEnc = Sys.Idata[1501].a EncTable[12].pEnc1 = Sys.pushm //Sys.Idata[1501].a EncTable[12].index1 = 0 EncTable[12].index2 = 0 EncTable[12].index3 = 0 EncTable[12].index4 = 0 EncTable[12].index5 = 0 EncTable[12].ScaleFactor = 1 EncTable[14].type = 1 EncTable[14].pEnc = Sys.Idata[3001].a EncTable[14].pEnc1 = Sys.pushm EncTable[14].index1 = 0 EncTable[14].index2 = 0 EncTable[14].index3 = 0 EncTable[14].index4 = 0 EncTable[14].index5 = 0 EncTable[14].ScaleFactor = 1/65536 //Cascade motor setup Motor[14].pDac = Sys.Idata[3001].a Motor[14].pEnc = EncTable[12].a Motor[14].pEnc2 = EncTable[12].a Motor[14].Servo.Kvfb = 0 Motor[14].Servo.Kp = 0.1 Motor[14].Servo.Ki = 0.0001 Motor[14].Servo.BreakPosErr = 0 Motor[14].Servo.Kvff = 0 Motor[14].Servo.Kaff = 0 Motor[14].pAmpEnable = 0 Motor[14].FatalFeLimit = 0 Motor[14].PosSf = 1 Motor[14].Pos2Sf = 1 Motor[14].AbortTa = 256 Motor[14].InvAmax = 256 Motor[14].JogTa = 256 Motor[14].JogTs = 32 Motor[14].JogSpeed = 16384 Motor[14].PwmSf = 1 Motor[14].MaxDac=32767 Motor[14].InPosBand = 100 Motor[14].FatalFeLimit = 32000 Motor[14].WarnFeLimit = 16000 Motor[14].pAmpFault=0 Motor[14].pLimits=0 //PLC for controlling inner loop using gearing open plc0 Motor[1].pMasterEnc = EncTable[14].a Motor[1].MasterPosSf = 1 Motor[1].MasterCtrl = 1 CMD "#14j=32767" close Link to comment Share on other sites More sharing options...
Richard Naddaf Posted October 3, 2017 Share Posted October 3, 2017 You know that the PLC (0 in this case) keeps on executing over and over again... At RTI rate. That is NOT good. I would never write a PLC with motion until I have full control over the system. You do NOT need a PLC for this function. You can turn it on/off with MasterCtrl. Do you need to do cascaded loop or just electronic gearing? What is it physically that you are trying to achieve? What does the input represent? Typically, force, height, or tension work better with integrating the cascaded motor output in the ECT. You do need to make sure that your cascaded motor output direction matches your physical motor direction or else you are creating a runway condition. Link to comment Share on other sites More sharing options...
Amar Posted October 4, 2017 Author Share Posted October 4, 2017 You know that the PLC (0 in this case) keeps on executing over and over again... At RTI rate. That is NOT good. I would never write a PLC with motion until I have full control over the system. You do NOT need a PLC for this function. You can turn it on/off with MasterCtrl. Do you need to do cascaded loop or just electronic gearing? What is it physically that you are trying to achieve? What does the input represent? Typically, force, height, or tension work better with integrating the cascaded motor output in the ECT. You do need to make sure that your cascaded motor output direction matches your physical motor direction or else you are creating a runway condition. Thanks.. Here i haven't described whole plc0. In plc0 i am taking care of, it will execute once and other task will execute over and over again. We are using same scenario in UMAC for Auto Mode in Antenna system for satellite tracking. Error will generate at continuous rate from integrated tracking receiver. I want to know what i missing in PPMAC. Why DAC is reaching at maxdac value? Till reaching at maxdac value of outer loop inner loop motor is following correctly. once outer loop dac output reach at maxdac value it will stop motion. Link to comment Share on other sites More sharing options...
Richard Naddaf Posted October 4, 2017 Share Posted October 4, 2017 Is the following error building up? Does it look like it is speed dependent? If it saturates faster with higher speed, this could mean that your gains are not suitable. Once you have control over both loops, you should be able to perform tuning moves on the cascaded (outer loop) motor to see the response. On a side note, usually best results with cascaded loops is obtained by integrating the virtual motor output in the ECT (using index4, typically =1) before feeding it into the master position of the inner loop. If you apply this, tuning gains will change. Make sure you have a reasonable fatal following error limit set on the inner loop. Link to comment Share on other sites More sharing options...
koustubh_h Posted October 5, 2017 Share Posted October 5, 2017 Hi Richard, I am Kaustubh, working along with Amar. I agree that it could be the gains who are creating a problem with cascade loop. To verify the same we created a user written servo implemented through either PLC0 or through the user written algorithm. We used the template given in the PowerPMAC user manual page no. 763. The template is as shown below - double user_pid_ctrl(struct MotorData *Mptr) { double ctrl_out; if (Mptr->ClosedLoop) { // Compute PD terms ctrl_out=Mptr->Servo.Kp*Mptr->PosError-Mptr->Servo.Kvfb*Mptr->ActVel; Mptr->Servo.Integrator+=Mptr->PosError*Mptr->Servo.Ki; // I term ctrl_out+=Mptr->Servo.Integrator; // Combine return ctrl_out; } else { Mptr->Servo.Integrator=0.0; return 0.0; } But, here the error we are talking about is coming from an analog source. It is not coming from a feedback device like encoder for e.g., so the error doesn't mean following error. Hence, what i am doing right now is subtracting the error value read at the last RTI from the present error value so as to get the value equivalent to following error. This value i m feeding to the servo.integrator. Now, i m getting a proper servo output with integration, it is not saturating. But, still the system oscillates maybe due to the integral error value i m putting. Slight change is making it unstable. My question now is that according to the template the first line ctrl_out calculates the servo out based on Kp, should i be doing the same thing to generate "following error" kind of error to be multiplied with Kp to generate ctrl_out as well in the first place before integration? Link to comment Share on other sites More sharing options...
Richard Naddaf Posted October 5, 2017 Share Posted October 5, 2017 I sent you a private message with my e-mail address Link to comment Share on other sites More sharing options...
koustubh_h Posted October 5, 2017 Share Posted October 5, 2017 I sent you a private message with my e-mail address Where? and how should i read that? Link to comment Share on other sites More sharing options...
Richard Naddaf Posted October 5, 2017 Share Posted October 5, 2017 Click on your user name. Upper right hand side, click on private messages Link to comment Share on other sites More sharing options...
koustubh_h Posted October 5, 2017 Share Posted October 5, 2017 Click on your user name. Upper right hand side, click on private messages When i click on private messages it says - You cannot use the private messaging functionality as it has been disabled by the Administrator. Can you email me? kaustubh@intelmotion.com or kaustubh.hunswadkar@gmail.com Link to comment Share on other sites More sharing options...
Amar Posted October 6, 2017 Author Share Posted October 6, 2017 Click on your user name. Upper right hand side, click on private messages i haven't received any messages. please mail me on Kaustubh and mail id. kaustubh@intelmotion.com amar@intelmotion.com Link to comment Share on other sites More sharing options...
Recommended Posts