HCTL-2016, HCTL-2017 AB Decoder

HCTL2016 : Quadrature Decoder/Counter Interface ICs

Agilent(Hewlett-Packard)

HCTL-2016 Datasheet
14MHz,
16-bits up/down counter,
Schmitt-trigger Input noise filter.
Latch Output.

Pinout A

在这里插入图片描述HCTL-2016HCTL-2017
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转移
#电子零件

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值