Sina.Sattari Posted April 6, 2009 Posted April 6, 2009 Brick family of products support EnDat encoders if ordered with correct option: EnDat 2.2 : Only order EnDat2.2 serial feedback option EnDat 2.1 : Order Both EnDat serial option and Sinusoidal option To use EnDat encoders you have to have a Global Register and Channel Register set to correct values before the data is transferred properly. Use the following Excel(R) spreadsheet to figure out your settings. [attachment=1317:name] If you don't know how many bits to set for the encoder data length, set an arbitrary number in the Excel spreadsheet and use the following PLC to calculate the correct number of bits in your encoder [code]// EnDat Encoder Bit-Count Finder // By: Sina Sattari // Date: 04-06-09 #define GlobalReg M7500 #define ChannelReg M7501 #define ChannelCRC M7502 #define ChannelLoss M7503 #define BitCount P7500 #define Timer I6612 #define msec *8388607/i10while(I6612>0)endwhile #define ChnRegBase P7501 #define CRCFailFlag P7502 GlobalReg->X:$78B2F,0,24 // Channels 1~4 //GlobalReg->X:$78B3F,0,24 // Channels 5~8 ChannelReg->X:$78B20,0,24 // Channel 1 //ChannelReg->X:$78B24,0,24 // Channel 2 //ChannelReg->X:$78B28,0,24 // Channel 3 //ChannelReg->X:$78B2C,0,24 // Channel 4 //ChannelReg->X:$78B30,0,24 // Channel 5 //ChannelReg->X:$78B34,0,24 // Channel 6 //ChannelReg->X:$78B38,0,24 // Channel 7 //ChannelReg->X:$78B3C,0,24 // Channel 8 ChannelCRC->Y:$78B21,22 // Channel 1 //ChannelCRC->Y:$78B25,22 // Channel 2 //ChannelCRC->Y:$78B29,22 // Channel 3 //ChannelCRC->Y:$78B2D,22 // Channel 4 //ChannelCRC->Y:$78B31,22 // Channel 5 //ChannelCRC->Y:$78B35,22 // Channel 6 //ChannelCRC->Y:$78B39,22 // Channel 7 //ChannelCRC->Y:$78B3D,22 // Channel 8 ChannelLoss->Y:$78B21,23 // Channel 1 //ChannelLoss->Y:$78B25,23 // Channel 2 //ChannelLoss->Y:$78B29,23 // Channel 3 //ChannelLoss->Y:$78B2D,23 // Channel 4 //ChannelLoss->Y:$78B31,23 // Channel 5 //ChannelLoss->Y:$78B35,23 // Channel 6 //ChannelLoss->Y:$78B39,23 // Channel 7 //ChannelLoss->Y:$78B3D,23 // Channel 8 GlobalReg=$002003 // Set Based upon the documentation or Excel Spreadsheet ChannelReg=$071401 Open PLC 29 Clear GlobalReg=$002003 // Set Based upon the documentation or Excel Spreadsheet ChnRegBase=$071420 // Set Based upon the documentation or Excel Spreadsheet with Number of bits=0 BitCount=0; ChnRegBase = ChnRegBase & $FFFF00; CRCFailFlag=1; While(CRCFailFlag=1 or ChannelLoss=1) BitCount = BitCount+1; ChannelReg=ChnRegBase + BitCount; Timer = 10 msec if (BitCount>40) BitCount = -1; Disable PLC 29 Endif CRCFailFlag=0; Timer = 100 *8388607/i10 While (Timer>0 and CRCFailFlag=0) if (ChannelCRC=1) CRCFailFlag=1; endif Endwhile EndWhile Disable PLC 29 Close [/code] After running this PLC, the correct number of counts will appear in variable named BitCount. If the BitCount = -1, there has been an error. You can also find out the number of bits, by looking at the data sheet or connecting the CLOCK and DATA lines on a scope. [attachment=1318:name] The nuumber of clock periods between the first bit, which is a start but and always a one, and the last bit sent from the encoder will determine the number of bits in the encoder. In the example above, the time is measured between the first bit , which is a start bit and always is a one and the first bit of the CRC, which is 34usec in a 1MHz clock setting. Since there are 2 header bits, start and error, the position data is actually 32bits.
oliver.h Posted April 25, 2013 Posted April 25, 2013 Dear Sina, I have a GeoBrick LV (GBD4-F3-400-14D4D300) and want to set up an Endat 2.2 Controller. Regarding the Geobrick manual: 4D3: 4 Sinusoidal Encoder and Serial Enc. (EnDat 2.1 / 2.2 Protocol) ... the endat 2.2 protocol should work? Best Regards, Oliver
Recommended Posts