Agilent(Hewlett-Packard)
HCTL-2016 Datasheet
14MHz,
16-bits up/down counter,
Schmitt-trigger Input noise filter.
Latch Output.
HCTL2016P.H
/***************************************************************************
* HCTL-2016 Encoder 16bit signed value as direction
*/
#ifndef __HCTL2016P_H__
#define __HCTL2016P_H__
#include "BRD.H"
sbit hw2016OE = 0x80;
sbit hw2016Sel = 0x83;
sfr hwEncoderBus = 0xA0;
int16_t Read_HCTL2016(void);
#endif
HCTL2016P.C
#include "HCTL2016P.H"
/***************************************************************************
* HCTL-2016 Make Sure bus stable
*/
void StabeRead( void)
{
unsigned char ucOld, ucNew;
unsigned char i;
for( i=200; i>0; i--)
{
ucOld = hwEncoderBus;
_nop_( );
_nop_( );
_nop_( );
ucNew = hwEncoderBus;
if ( ucOld == ucNew ) break;
}
}
/***************************************************************************
* Read HCTL-2016 16bits AB decode data
* SEL = 0 , Read 2016 High nibble data
* SEL = 1 , Read 2016 Low Nibble data
*/
int16_t Read_HCTL2016(void)
{
idata UnReg uiBuf;
EX0 = 0; // Disable Keyboard Interrupt
hwEncoderBus = 0xFF;
hw2016Sel = 0; /* Read High Nibble */
hw2016OE = 0; /* Lock HCTL-2016 */
_nop_();
StabeRead( );
uiBuf.by[0] = hwEncoderBus;
hw2016Sel = 1; /* Read Low Nibble */
_nop_();
StabeRead( );
uiBuf.by[1] = hwEncoderBus;
hw2016OE = 1; /* Release HCTL-2016 */
uiBuf.by[1] &= 0xFC; /* Mask 4x as filter */
hw2016Sel = 0;
hwEncoderBus = 0xFF; /* Relase Data Bus */
_nop_();
EX0 = 1; // Enable Keyboard Interrupt
return(uiBuf.wd);
}
PS: 淘宝买了10个, 一半是坏的….
之后还是弄一个ZIF测试先, 不行直接退, 东西有些贵, 还耗时间。
HCTL2016 : Quadrature Decoder/Counter Interface ICs
<备份> 资料, 仅供参考。
数据剪辑自原厂Agilent(Hewlett-Packard)规格书, 版权归原所有人拥有。
档案取自互联网!如有侵权或不适用情形, 请联系移除!
** 使用有风险, 请详阅原厂使用说明!
** 范例码为自用,请谨慎引用, Ctrl-C, Ctrl-V结果自行承担!
#Blog转移
#电子零件