bradp Posted August 6, 2010 Posted August 6, 2010 This is a sample setup for the Gate3 serial encoder interface. This was done with an EnDat 2.1 encoder // parts of Gate3[i].SerialEncCtrl #define ClockMDiv 0 // 31-24 100MHz = 100MHz/(SerialClockMDiv + 1) #define ClockNDiv 4 // 23-20 6.25MHz = 1MHz/(2^SerialClockNDiv) #define TrigClockSel 1 // 17 1=trigger on servo #define TrigEdgeSel 0 // 16 1=use falling edge to have more time since only used for power-on read #define TrigDelay 0 // 15-8 no delay #define Protocol 3 // 7-0 endat protocol // Gate3[i].SerialEncCtrl // establishes the protocol, clock frequency, and triggering Gate3[0].SerialEncCtrl = ClockMDiv*pow(2,24) + ClockNDiv*pow(2,20) + TrigClockSel*pow(2,17) + TrigEdgeSel*pow(2,16) + TrigDelay*pow(2,8) + Protocol // which establishes the protocol, clock //parts of Gate3[0].Chan[3].SerialEncCmd // must be set to interface to the particular encoder being used #define SerialEncCmdWord 7 // 31-16 Endat 2.1 send position #define SerialEncParity 0 // 15-14 geobrick has this as zero #define SerialEncTrigMode 0 // 13 0=continuous mode #define SerialEncTrigEna 1 // 12 enable trigger #define SerialEncGtoB 0 // 11 no conversion #define SerialEncDataReady 0 // 10 read only #define SerialEncStatusBits 0 // 9-6 no status bits for Endat #define SerialEncNumBits 25 // 5-0 13-bit encoder with 12-bit multiturn Gate3[0].Chan[2].SerialEncCmd = SerialEncCmdWord*pow(2,16) + SerialEncParity*pow(2,14) + SerialEncTrigMode*pow(2,13) + SerialEncTrigEna*pow(2,12) + SerialEncGtoB*pow(2,11) + SerialEncStatusBits*pow(2,6) + SerialEncNumBits Gate3[0].Chan[3].SerialEncCmd = SerialEncCmdWord*pow(2,16) + SerialEncParity*pow(2,14) + SerialEncTrigMode*pow(2,13) + SerialEncTrigEna*pow(2,12) + SerialEncGtoB*pow(2,11) + SerialEncStatusBits*pow(2,6) + SerialEncNumBits //p1 = SerialEncCmdWord*pow(2,16) + SerialEncParity*pow(2,14) + SerialEncTrigMode*pow(2,13) + SerialEncTrigEna*pow(2,12) + SerialEncGtoB*pow(2,11) + SerialEncStatusBits*pow(2,6) + SerialEncNumBits //p2 = $2A*pow(2,16) + SerialEncParity*pow(2,14) + SerialEncTrigMode*pow(2,13) + SerialEncTrigEna*pow(2,12) + SerialEncGtoB*pow(2,11) + SerialEncStatusBits*pow(2,6) + SerialEncNumBits Gate3[0].Chan[2].SerialEncEna = 1 // must be set to 1 Gate3[0].Chan[3].SerialEncEna = 1 // must be set to 1 //--- motor AbsPhase Setup ------------------------ // Motor[x].AbsPhasePosFormat consists of four byte fields. hexadecimal format $aabbccdd. // $dd specifies the number of the starting bit to be used. It can take a value from $00 to $1F (0 to 31). // $cc specifies the total number of bits to be used. a value of up to $20 (32) // $bb use data in subsequent registers. only used if the number of bits in $cc cannot be found in the first register. // $aa specifies how the Power PMAC will interpret the data. It can take the following values: // $00: Interpret as numerical binary (no conversion required) // $02: Interpret as Gray code and convert to numerical binary // $04: Interpret as 3-phase digital Hall-sensor data with 120o signal spacing and convert to numerical binary // $05: Interpret as 3-phase digital Hall-sensor data with 60o signal spacing and convert to numerical binary // Motor[3].AbsPhasePosFormat = $00000b00 // have 8192 cts/rev / 4 pole pair/rev = 2048 cts/pole pair = 2^11 Motor[4].AbsPhasePosFormat = $00000b00 // have 8192 cts/rev / 4 pole pair/rev = 2048 cts/pole pair = 2^11 // Motor[x].AbsPhasePosOffset amount added to the absolute position value // after it has been scaled by Motor[x].AbsPhasePosSf into the commutation // units of 1/2048 of a cycle. As such, this term expressed in the units // of 1/0248 of a cycle. Motor[3].AbsPhasePosSf = -1 // Endat gives 8192 cts/rev * 1 rev / 4 elec cycles = 2048 cts/elec cycle Motor[3].AbsPhasePosOffset = -1542 // seems like encoder is aligned to phase Motor[4].AbsPhasePosSf = -1 // Endat gives 8192 cts/rev * 1 rev / 4 elec cycles = 2048 cts/elec cycle Motor[4].AbsPhasePosOffset = -1593 // seems like encoder is aligned to phase Motor[3].pAbsPhasePos = Gate3[0].Chan[2].SerialEncDataA.a Motor[4].pAbsPhasePos = Gate3[0].Chan[3].SerialEncDataA.a Motor[3].PhaseFindingTime = 4 Motor[4].PhaseFindingTime = 4 //--- Motor Abs Position Setup --------------------- // Motor[x].AbsPosFormat consists of four byte fields. hexadecimal format $aabbccdd. // $dd specifies the number of the starting bit to be used. It can take a value from $00 to $1F (0 to 31). // $cc specifies the total number of bits to be used. a value of up to $20 (32) // $bb use data in subsequent registers. only used if the number of bits in $cc cannot be found in the first register. // $aa specifies how the Power PMAC will interpret the data. It can take the following values: // $00: Interpret as numerical binary (no conversion required) // $02: Interpret as Gray code and convert to numerical binary // $04: Interpret as 3-phase digital Hall-sensor data with 120o signal spacing and convert to numerical binary // $05: Interpret as 3-phase digital Hall-sensor data with 60o signal spacing and convert to numerical binary // Motor[3].AbsPosFormat = $00001900 // have 25-bit encoder Motor[4].AbsPosFormat = $00001900 // have 25-bit encoder Motor[3].AbsPosSf = -16000/8192 // Endat gives 8192 cts/mtr rev * 1 mtr rev / 16000 um = 8192/16000 cts/um Motor[3].HomeOffset = -3993117.3 // seems like encoder is aligned to phase Motor[4].AbsPosSf = -360000*20/8192/72 // Endat gives 8192 cts/mtr rev * 72 mtr rev / 20 head rev * 1 head rev / 360000 millideg = 8192 * 72 / 20 / 360000 cts/millideg Motor[4].HomeOffset = -25003992 // seems like encoder is aligned to phase Motor[3].pAbsPos = Gate3[0].Chan[2].SerialEncDataA.a Motor[4].pAbsPos = Gate3[0].Chan[3].SerialEncDataA.a
dzrong Posted August 24, 2010 Posted August 24, 2010 Does ACC-24E3 support ENDAT 2.2 Encoder? If we want to use ACC-51E to receive the ENDAT Encoder,which version of ENDAT does the ACC-51E support? 2.1 or 2.2? If the ACC-51E support ENDAT 2.2,would you give me a example about how to use it with PPMAC ?
Richard Naddaf Posted August 25, 2010 Posted August 25, 2010 The ACC-24E3 does support EnDat2.2 directly: There is a typo in the above setup, the SerialEncCmdWord is actually bits 21-16. Bits 30-22 are not used, and bit 31 is start delay compensation. The SerialEncCmdWord can take one of these values: $38 111000 – Encoder to Send Position (EnDat2.2 only) $15 010101 – Encoder to Receive Reset (EnDat2.2 only) $07 000111 – Encoder to Send Position (EnDat 2.1 & 2.2)--This is used in the example above $2A 101010 – Encoder to Receive Reset (EnDat 2.1 & 2.2) Note that per Heidenhain, this command set should work for both protocols but I have seen EnDat 2.2 encoders work with $7 rather than $38, and vice-versa. We are trying to identify the subtle differences with them to document it properly. The ACC-51E does not support either protocols for absolute position, power-on or obviously on-going(absolute). This defeats the desired use of EnDat. I would suggest using the universal serial interface ACC-84E (fairly new!) instead.
Recommended Posts