Jump to content
OMRON Forums

Recommended Posts

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Hi,

 

Below is an example of creating 8 virtual motors, all of which read the commanded position into the Encoder Conversion Table to be used as feedback.

 

// Activate servo algorithms for motors
Motor[1].ServoCtrl=1
Motor[2].ServoCtrl=1
Motor[3].ServoCtrl=1
Motor[4].ServoCtrl=1
Motor[5].ServoCtrl=1
Motor[6].ServoCtrl=1
Motor[7].ServoCtrl=1
Motor[8].ServoCtrl=1

// Write servo output to user shared memory registers
Motor[1].pDac=Sys.Idata[1].a	// Same as EncTable[1].pEnc
Motor[2].pDac=Sys.Idata[2].a	// Same as EncTable[2].pEnc
Motor[3].pDac=Sys.Idata[3].a	// Same as EncTable[3].pEnc
Motor[4].pDac=Sys.Idata[4].a	// Same as EncTable[4].pEnc
Motor[5].pDac=Sys.Idata[5].a	// Same as EncTable[5].pEnc
Motor[6].pDac=Sys.Idata[6].a	// Same as EncTable[6].pEnc
Motor[7].pDac=Sys.Idata[7].a	// Same as EncTable[7].pEnc
Motor[8].pDac=Sys.Idata[8].a	// Same as EncTable[8].pEnc

// Encoder conversion table entry to read and integrate this
EncTable[1].type=1			// 32-bit register read
EncTable[1].pEnc=Sys.idata[1].a	// Same as Motor[1].pDac
EncTable[1].pEnc1=Sys.pushm		// Dummy read (not used)
EncTable[1].index1=0			// No shift right of source data
EncTable[1].index2=0			// No shift left of source data
EncTable[1].index3=0			// No accel limiting
EncTable[1].index4=1			// Single integration
EncTable[1].PrevDelta=0		// No bias before integration
EncTable[1].MaxDelta=0		// No velocity limit
EncTable[1].ScaleFactor=1/65536	// 32 bits -> 16 bits

EncTable[2].type=1			// 32-bit register read
EncTable[2].pEnc=Sys.idata[2].a	// Same as Motor[2].pDac
EncTable[2].pEnc1=Sys.pushm		// Dummy read (not used)
EncTable[2].index1=0			// No shift right of source data
EncTable[2].index2=0			// No shift left of source data
EncTable[2].index3=0			// No accel limiting
EncTable[2].index4=1			// Single integration
EncTable[2].PrevDelta=0		// No bias before integration
EncTable[2].MaxDelta=0		// No velocity limit
EncTable[2].ScaleFactor=1/65536	// 32 bits -> 16 bits

EncTable[3].type=1			// 32-bit register read
EncTable[3].pEnc=Sys.idata[3].a	// Same as Motor[3].pDac
EncTable[3].pEnc1=Sys.pushm		// Dummy read (not used)
EncTable[3].index1=0			// No shift right of source data
EncTable[3].index2=0			// No shift left of source data
EncTable[3].index3=0			// No accel limiting
EncTable[3].index4=1			// Single integration
EncTable[3].PrevDelta=0		// No bias before integration
EncTable[3].MaxDelta=0		// No velocity limit
EncTable[3].ScaleFactor=1/65536	// 32 bits -> 16 bits

EncTable[4].type=1			// 32-bit register read
EncTable[4].pEnc=Sys.idata[4].a	// Same as Motor[4].pDac
EncTable[4].pEnc1=Sys.pushm		// Dummy read (not used)
EncTable[4].index1=0			// No shift right of source data
EncTable[4].index2=0			// No shift left of source data
EncTable[4].index3=0			// No accel limiting
EncTable[4].index4=1			// Single integration
EncTable[4].PrevDelta=0		// No bias before integration
EncTable[4].MaxDelta=0		// No velocity limit
EncTable[4].ScaleFactor=1/65536	// 32 bits -> 16 bits

EncTable[5].type=1			// 32-bit register read
EncTable[5].pEnc=Sys.idata[5].a	// Same as Motor[5].pDac
EncTable[5].pEnc1=Sys.pushm		// Dummy read (not used)
EncTable[5].index1=0			// No shift right of source data
EncTable[5].index2=0			// No shift left of source data
EncTable[5].index3=0			// No accel limiting
EncTable[5].index4=1			// Single integration
EncTable[5].PrevDelta=0		// No bias before integration
EncTable[5].MaxDelta=0		// No velocity limit
EncTable[5].ScaleFactor=1/65536	// 32 bits -> 16 bits

EncTable[6].type=1			// 32-bit register read
EncTable[6].pEnc=Sys.idata[6].a	// Same as Motor[6].pDac
EncTable[6].pEnc1=Sys.pushm		// Dummy read (not used)
EncTable[6].index1=0			// No shift right of source data
EncTable[6].index2=0			// No shift left of source data
EncTable[6].index3=0			// No accel limiting
EncTable[6].index4=1			// Single integration
EncTable[6].PrevDelta=0		// No bias before integration
EncTable[6].MaxDelta=0		// No velocity limit
EncTable[6].ScaleFactor=1/65536	// 32 bits -> 16 bits

EncTable[7].type=1			// 32-bit register read
EncTable[7].pEnc=Sys.idata[7].a	// Same as Motor[7].pDac
EncTable[7].pEnc1=Sys.pushm		// Dummy read (not used)
EncTable[7].index1=0			// No shift right of source data
EncTable[7].index2=0			// No shift left of source data
EncTable[7].index3=0			// No accel limiting
EncTable[7].index4=1			// Single integration
EncTable[7].PrevDelta=0		// No bias before integration
EncTable[7].MaxDelta=0		// No velocity limit
EncTable[7].ScaleFactor=1/65536	// 32 bits -> 16 bits

EncTable[8].type=1			// 32-bit register read
EncTable[8].pEnc=Sys.idata[8].a	// Same as Motor[8].pDac
EncTable[8].pEnc1=Sys.pushm		// Dummy read (not used)
EncTable[8].index1=0			// No shift right of source data
EncTable[8].index2=0			// No shift left of source data
EncTable[8].index3=0			// No accel limiting
EncTable[8].index4=1			// Single integration
EncTable[8].PrevDelta=0		// No bias before integration
EncTable[8].MaxDelta=0		// No velocity limit
EncTable[8].ScaleFactor=1/65536	// 32 bits -> 16 bits

// Read the encoder conversion table result as feedback
Motor[1].pEnc=EncTable[1].a		// Position loop feedback source
Motor[1].pEnc2=EncTable[1].a	// Velocity loop feedback source
Motor[2].pEnc=EncTable[2].a		// Position loop feedback source
Motor[2].pEnc2=EncTable[2].a	// Velocity loop feedback source
Motor[3].pEnc=EncTable[3].a		// Position loop feedback source
Motor[3].pEnc2=EncTable[3].a	// Velocity loop feedback source
Motor[4].pEnc=EncTable[4].a		// Position loop feedback source
Motor[4].pEnc2=EncTable[4].a	// Velocity loop feedback source
Motor[5].pEnc=EncTable[5].a		// Position loop feedback source
Motor[5].pEnc2=EncTable[5].a	// Velocity loop feedback source
Motor[6].pEnc=EncTable[6].a		// Position loop feedback source
Motor[6].pEnc2=EncTable[6].a	// Velocity loop feedback source
Motor[7].pEnc=EncTable[7].a		// Position loop feedback source
Motor[7].pEnc2=EncTable[7].a	// Velocity loop feedback source
Motor[8].pEnc=EncTable[8].a		// Position loop feedback source
Motor[8].pEnc2=EncTable[8].a	// Velocity loop feedback source


// Disable overtravel limit inputs
// May be needed if there are no physical switches present
Motor[1].pLimits=0
Motor[2].pLimits=0
Motor[3].pLimits=0
Motor[4].pLimits=0
Motor[5].pLimits=0
Motor[6].pLimits=0
Motor[7].pLimits=0
Motor[8].pLimits=0

// Disable amplifier enable output
// May be needed if channel is also connected to real amplifier
Motor[1].pAmpEnable=0
Motor[2].pAmpEnable=0
Motor[3].pAmpEnable=0
Motor[4].pAmpEnable=0
Motor[5].pAmpEnable=0
Motor[6].pAmpEnable=0
Motor[7].pAmpEnable=0
Motor[8].pAmpEnable=0

// Disable amplifier fault input
// May be needed if channel is also connected to real amplifier
Motor[1].pAmpFault=0
Motor[2].pAmpFault=0
Motor[3].pAmpFault=0
Motor[4].pAmpFault=0
Motor[5].pAmpFault=0
Motor[6].pAmpFault=0
Motor[7].pAmpFault=0
Motor[8].pAmpFault=0

// Set derivative gain term in servo loop to zero
// This is a Type 1 servo (single integration); does not need Kd
Motor[1].Servo.Kvfb=0
Motor[2].Servo.Kvfb=0
Motor[3].Servo.Kvfb=0
Motor[4].Servo.Kvfb=0
Motor[5].Servo.Kvfb=0
Motor[6].Servo.Kvfb=0
Motor[7].Servo.Kvfb=0
Motor[8].Servo.Kvfb=0
// Lower proportional gain term from default
Motor[1].Servo.Kp=1
Motor[2].Servo.Kp=1
Motor[3].Servo.Kp=1
Motor[4].Servo.Kp=1
Motor[5].Servo.Kp=1
Motor[6].Servo.Kp=1
Motor[7].Servo.Kp=1
Motor[8].Servo.Kp=1
// Add integral gain to force to zero error
Motor[1].Servo.Ki=0.01
Motor[2].Servo.Ki=0.01
Motor[3].Servo.Ki=0.01
Motor[4].Servo.Ki=0.01
Motor[5].Servo.Ki=0.01
Motor[6].Servo.Ki=0.01
Motor[7].Servo.Ki=0.01
Motor[8].Servo.Ki=0.01
// Set deadband zone to zero
Motor[1].Servo.BreakPosErr=0
Motor[2].Servo.BreakPosErr=0
Motor[3].Servo.BreakPosErr=0
Motor[4].Servo.BreakPosErr=0
Motor[5].Servo.BreakPosErr=0
Motor[6].Servo.BreakPosErr=0
Motor[7].Servo.BreakPosErr=0
Motor[8].Servo.BreakPosErr=0
// Add feedforward to minimize tracking error
Motor[1].Servo.Kvff=1
Motor[1].Servo.Kaff=1
Motor[2].Servo.Kvff=1
Motor[2].Servo.Kaff=1
Motor[3].Servo.Kvff=1
Motor[3].Servo.Kaff=1
Motor[4].Servo.Kvff=1
Motor[4].Servo.Kaff=1
Motor[5].Servo.Kvff=1
Motor[5].Servo.Kaff=1
Motor[6].Servo.Kvff=1
Motor[6].Servo.Kaff=1
Motor[7].Servo.Kvff=1
Motor[7].Servo.Kaff=1
Motor[8].Servo.Kvff=1
Motor[8].Servo.Kaff=1

 

Let me know if you have further questions regarding this.

Posted

Curt alerted me to the fact that "there is a slightly easier method now that does not require that you find a unique open register for each motor’s servo output. If you use Type 11 in the ECT, you can read the motor’s IqCmd servo output directly, and integrate it into position for feedback."

 

This would simplify my posted example.

Guest
This topic is now closed to further replies.

×
×
  • Create New...