RafaelFalcaro Posted April 28, 2021 Share Posted April 28, 2021 Hi, I need to make the same channel on my controller control two types of motors, according to the user's choice. For this, I created two virtual motors and a plc that makes the selection between the setups according to a Boolean flag, but it is not working. Follow the plc: if (homeInit == 0) { if (Gate3[0].Chan[0].Status & $100) { Motor[12].ServoCtrl = 0 Motor[12].pDac = Sys.pushm Motor[11].ServoCtrl = 1 Motor[11].pDac = PowerBrick[0].Chan[0].Pwm[0].a setup = 1 } else { Motor[11].ServoCtrl = 0 Motor[11].pDac = Sys.pushm Motor[12].ServoCtrl = 1 Motor[12].pDac = PowerBrick[0].Chan[0].Pwm[0].a setup = 2 } homeValue = Gate3[0].Chan[0].Status & $100 homeInit = 1 } Link to comment Share on other sites More sharing options...
leandro.martins Posted April 29, 2021 Share Posted April 29, 2021 Hello, I guess it's necessary to change the values of: Motor[11].pAbsPhasePos Motor[12].pAbsPhasePos For the proper phase commutation If the motor is a stepper without encoder, for example, you will also need to consider the changes in Motor[11].pAbsPos Motor[12].pAbsPos Motor[11].pEnc Motor[12].pEnc Motor[11].pEnc2 Motor[12].pEnc2 Link to comment Share on other sites More sharing options...
RafaelFalcaro Posted April 29, 2021 Author Share Posted April 29, 2021 Hello, Thank you for your support. After I did the post yesterday, I tried a few more things and managed to get Motor[2] to operate a motor allocated on channel 1 of the controller. These were the changes I made: Motor[2].ServoCtrl = 1 Motor[2].pAbsPhasePos = PowerBrick[0].Chan[0].PhaseCapt.a Motor[2].pDac = PowerBrick[0].Chan[0].Pwm[0].a Motor[2].pAdc = PowerBrick[0].Chan[0].AdcAmp[0].a Motor[2].pAmpEnable = PowerBrick[0].Chan[0].OutCtrl.a Motor[2].pAmpFault = PowerBrick[0].Chan[0].Status.a Motor[2].pEncCtrl = PowerBrick[0].Chan[0].OutCtrl.a Motor[2].pEncStatus = PowerBrick[0].Chan[0].Status.a Motor[2].pCaptFlag = PowerBrick[0].Chan[0].Status.a Motor[2].pCaptPos = PowerBrick[0].Chan[0].HomeCapt.a Motor[2].pPhaseEnc = PowerBrick[0].Chan[0].PhaseCapt.a And this is my Open Loop EncTable: EncTable[2].type = 11 EncTable[2].pEnc = Motor[2].PhasePos.a EncTable[2].index1 = 5 EncTable[2].index2 = 0 EncTable[2].index3 = 0 EncTable[2].index4 = 0 EncTable[2].index5 = 255 EncTable[2].index6 = 1 EncTable[2].ScaleFactor = 1 / (256 * (EncTable[1].index5 + 1) * EXP2(EncTable[1].index1)) But when I try to do exactly that configuration with Motor[11] controlling channel 1 of the controller, what happens is the operation of a common virtual motor, with no real output on the controller. Link to comment Share on other sites More sharing options...
Alex Anikstein Posted April 29, 2021 Share Posted April 29, 2021 If Motor 2 works, but Motor 11 (with otherwise identical settings) doesn't, what value is Sys.MaxMotors? Is it possible that you have multiple motors writing to the same target register at the same time? If Motors 2 and 11 are both set such that Motor[x].pDac = PowerBrick[0].Chan[0].Pwm[0].a at the same time, the motors will fight one another and overwrite each other. Just to make sure you don't have any other motors that might be conflicting, can you try to set Motor[x].ServoCtrl = 0 for all motors other than Motor 11? Link to comment Share on other sites More sharing options...
RafaelFalcaro Posted April 30, 2021 Author Share Posted April 30, 2021 Hello, Thank you for your support. I made sure that the Sys.MaxMotors parameter was greater than 11 (I put 50). I added this following lines on my configuration to make sure I don't have any other motors that might be conflicting, but it's still not working: Motor[1].pDac = Sys.pushm Motor[1].ServoCtrl = 0 Motor[11].ServoCtrl = 1 Motor[11].pAbsPhasePos = PowerBrick[0].Chan[0].PhaseCapt.a Motor[11].pDac = PowerBrick[0].Chan[0].Pwm[0].a Motor[11].pAdc = PowerBrick[0].Chan[0].AdcAmp[0].a Motor[11].pAmpEnable = PowerBrick[0].Chan[0].OutCtrl.a Motor[11].pAmpFault = PowerBrick[0].Chan[0].Status.a Motor[11].pEncCtrl = PowerBrick[0].Chan[0].OutCtrl.a Motor[11].pEncStatus = PowerBrick[0].Chan[0].Status.a Motor[11].pCaptFlag = PowerBrick[0].Chan[0].Status.a Motor[11].pCaptPos = PowerBrick[0].Chan[0].HomeCapt.a Motor[11].pPhaseEnc = PowerBrick[0].Chan[0].PhaseCapt.a Link to comment Share on other sites More sharing options...
RafaelFalcaro Posted May 1, 2021 Author Share Posted May 1, 2021 Hi, I finally found the solution! I needed to add the registers below to my Motor[11] .phm file: Motor[11].EncType = 5 Motor[11].AmpEnableBit = 8 Motor[11].LimitBits = 9 Motor[11].AmpFaultBit = 7 Motor[11].CaptControl = $14080801 Thank you all for your help! Link to comment Share on other sites More sharing options...
Recommended Posts