如何识别一个电容式触摸屏控制器器或者说Touch Controller

电容式触摸屏控制器介绍
电容式触摸屏受到消费者的青睐,主要有两个原因:
1、 电容式触摸屏使用两层TIO,有时使用一层。它利用一个与棋盘格类似的有纹理传感器(图2),因此它可以使用一个整片覆盖在LCD上,从而带来更加清楚透亮的屏幕。
2、 由于电容式触摸屏控制使用电解电容方法实现检测,安全玻璃层可放置于顶层来实现密封,这与电阻屏的聚氨酯柔性层不同。它还给用户带来一种更加耐用的设计。
电容式触摸屏设计考虑
电容式触摸屏的设计人员面对三大主要问题:功耗、噪声控制与手势识别。本文后面部分将为你逐一讲解。
今天的电池供电型设备如此之多,功耗是我们需要考虑的关键系统问题之一。诸如 TI 的TSC3060等器件,便是按照低功耗要求设计的。在标准工作条件下,它的功耗小于60mA。在对触摸行为进行检测时,它的功耗更可低至11 ?A。在相同工作状态下,它比其竞争者至少低了一个数量级。
市场上的许多解决方案一开始都是设计为微控制器,然后再逐渐发展为电容式触摸屏控制器。一开始就设计为电容式触摸屏控制器的器件,没有会消耗额外电流和时钟周期的多余硬件。大多数系统都已有一个主中央处理器,其可以是数字信号处理器、微处理器或者微控制器单元(MCU)。因此,为什么要给一个已经经过精密调整的系统再增加一个引擎呢?TSC3060为一种没有微控制器的专门设计。
如果控制器无法区分实际触摸和潜在干扰源,则更不用提实现超长的电池使用时间。触摸屏的主要噪声源通常来自LCD,其最终取决于质量和成本之间的折中权衡。AC公共接地LCD通常更便宜,但噪声水平更高。DC公共接地LCD拥有DC屏蔽,可以降低噪声,但会增加成本。
可以帮助降低ITO传感器以及触摸屏控制器可感知噪声数量的一种典型方法是,在LCD和ITO之间保持一定的空气间隙。这样可在两者之间留出一定的间距,从而减少相互干扰。处理噪声的另一种方法是使用滤波器。例如,TSC3060包含了一套可编程混合信号滤波器,可用于降低噪声。这些滤波器通过一个集成MCU安装到硬件中。这意味着,它们就近完成任务的速度要比使用软件的滤波器快。对实际触摸坐标的快速响应,还可降低总系统资源消耗。
最后一个设计问题是手势识别。手势不一定是大幅度、复杂的挥舞。手势可以是简单的一次手指滑动。系统主机MCU可以轻松地识别出一些简单的手势,例如:捏、拉、缩放、旋转以及双击和三连击等,并可进行&内部&处理。增加一个专用引擎,可能可以降低一点点系统MCU带宽处理负荷,但却会增加功耗。另外,专用引擎用于完成手势识别的专有算法,设计人员无法看到。TSC3060等器件把这种工作都推给系统中已有的主处理器,让广大设计人员可以自由地开发自己的免版税算法。电容式触摸屏的控制器电路设计
电容式触摸屏的控制器电路设计
发布: | 作者:-- | 来源: -- | 查看:1143次 | 用户关注:
计算机触摸屏是一种显著改善人机操作界面的输入设备,具有直接、简单、快捷的优点,在各个领域中有着广泛的应用前景,尤其适用于计算机屏幕菜单式问答系统,例如工业控制监控、军事指挥、商场导购、宾馆功能介绍、各种咨询系统等。目前国外触摸屏有电容式、电阻式和红外式之分。由于电容式触摸屏具有数据连续、分辨率高、屏结构简单、内藏式等优点,可以不改变原计算机结构,因而获得广泛应用。触摸屏是履盖在计算机显示终端上的玻
计算机触摸屏是一种显著改善人机操作界面的输入设备,具有直接、简单、快捷的优点,在各个领域中有着广泛的应用前景,尤其适用于计算机屏幕菜单式问答系统,例如工业控制监控、军事指挥、商场导购、宾馆功能介绍、各种咨询系统等。目前国外触摸屏有电容式、电阻式和红外式之分。由于电容式触摸屏具有数据连续、分辨率高、屏结构简单、内藏式等优点,可以不改变原计算机结构,因而获得广泛应用。触摸屏是履盖在计算机显示终端上的玻璃屏,透过玻璃屏能看到显示屏上的图象。电容式触摸屏是在玻璃屏上喷涂某种金属氧化物薄膜,如可使用铟锡氧化物。在触摸屏的四周边缘上安排有若干电极,使得交流电能够较均匀地在一个方向上流过整个触摸屏,其结构如图1 所示。触摸屏每一边可安排5个或6 个电极,以适合 14&P 、17&P 等不同触摸屏的需要。当用手指触摸玻璃屏某一位置时,使用者的体电容加到电路中,引起电极之间电容的变化。为了感应电容值的变化,并确定手指触摸的位置,必须设计1 个能与主机CPU 通讯的控制器。为此笔者研制了适用于电容式触摸屏的控制器。本文主要介绍该控制器的硬件组成、各部分功能以及确定触摸位置的原理和方法。
图1 电容式触摸屏结构
Fig. 1 St ructure of capacitive touch panel
1 触摸屏控制器电路及其功能
触摸屏控制器总体结构如图2 所示。控制器的所有时序都由单片机控制,各部分功能叙述如下。
图2 触摸屏控制器总体框图
Fig. 2 General diagram of controller for touch panel
1. 1 触摸屏激励信号源
控制器的激励信号源如图3 所示。信号由函数信号发生器8038 产生,它能够输出正弦波和方波,正弦波用作触摸屏的激励信号。单片机通过 8 位 D/ A 转换器可控制8038 的振荡频率,一般控制在200 kHz 左右,以避开计算机显示器扫描信号产生的干扰。同时,由8038 产生的方波信号提供给模拟解调器,作为解调信号参考源。由于8038输出的正弦波信号功率有限,为此在8038的正弦波信号输出端增加了功率放大电路。
图3 控制器的激励信号源
Fig. 3 Excitat ion signal sour ce in cont roller
1. 2 触摸电流处理电路
触摸电流处理电路如图4 所示。假设在没有触摸时,调零电路已使变压器次级中心抽头上的电流为零。当有触摸时,将使中心抽头上的电流产生变化,其波形为经信号激励源频率X0 调制的信号。如果在位置坐标为X、Y的点上进行触摸,则中心抽头电流通过模拟解调器解调输出,并由低通滤波器滤波后,可得到与坐标X、Y及触摸轻重度Z 相对应的触摸电流i X、iY、iZ。
由于测量值的变化范围较宽,如果简单地将其信号放大后,接入 A/ D 转换器ADC1001,将使其位置测量精度大大下降。为此使用了积分器,使其输出的电压与t XiX、tYiY、tZi Z 相对应,其中,tX、t Y、t Z 为积分因子,对应的积分时间由单片机控制模拟开关的开通时间来实现,这样就能适合于测量值的变化。
1. 3 自动调零电路
在没有触摸的情况下,由于元器件的误差等原因,变压器次级中心抽头上的电流不一定为零,从而引起测量误差,为此本控制器设置了自动调零电路,如图5 所示。该电路将12 位D/ A 转换器DAC1230 的输出,通过电容耦合到SIG-信号上,使得变压器次级中心抽头上的电流调整为零。
推荐相关文章:
滤波电路设计
电动车控制器功率管
防雷电路设计方案
图4 触摸电流处理电路
Fig. 4 Touch current pr ocessing circuit
1. 4 通讯接口
电容式触摸屏控制器设置了串行接口和并行接口,将测量计算得到的位置坐标数据传送给计算机。串行接口为RS - 232 标准接口,可通过拨码开关进行设置:波特率为 或19 200; 进行奇/偶校验或不校验; 采用二进制码或ASCⅡ码通讯。并行接口为CENTRONICS标准接口。由拨码开关还可设置4 种数据发送模式: 连续模式、增量模式、按下发送模式和放开发送模式。
2 触摸屏扫描模式和触摸位置的确定
在图1 所示的触摸屏上,如果在 P 点触摸,为了确定触摸坐标X、Y及触摸的轻重度,必须设计适当的扫描模式,使得激励信号SIG+和SIG-按预先安排好的时序分别作用于触摸屏的各边电极上,依次形成各方向的触摸电流。扫描时序由控制器中的单片机通过多路开关进行控制。本控制器设计了4 种扫描模式。第 1种模式为将SIG+加到触摸屏的左边电极上,SIG-
加到触摸屏的右边电极上,触摸屏的上边和下边电极全部开路,这样在触摸屏的X 方向上建立了交流电压梯度,经解调器解调和滤波后,可得到X 方向上的触摸电流为iX= KXXV/ Zf ,其中,V为变压器次级对于中心抽头虚地的电压,KX 为常量,V/ Zf 为电路等价阻抗触摸电流。第2 种模式为将SIG+加到触摸屏的左边电极上,同时也加到触摸屏的右边电极上,这时在X 方向上建立了均匀的交流电压。如果在触摸屏上任意一点进行触摸,则经解调器解调和滤波后,得到其触摸电流为i ZX= KZXV/ Zf ,其中,KZX为常量。由iX 和iZX得X 方向的触摸位置坐标为X= (KZX/ KX)&( iX/ i ZX ) ,式中,iX、iZX在以上2 种扫描模式下测得,而常量KZX/ KX 可由实验确定。一旦确定了KZX / KX,就可计算出X 方向的任意触摸位置坐标X。同样,第3 种模式是将SIG+和SIG-分别加到触摸屏的上边电极和下边电极上,即可得到Y方向上的触摸电流为i Y= KYYV/ Zf ,其中,KY 为常量。第4种模式是同时将SIG+加到触摸屏的上边电极和下边电极上,得等价阻抗触摸电流为 iZY= KZYV/ Zf ,其中,KZY为常量。也可由 iY 和 iZY得Y 方向的触摸位置坐标为 Y=(KZY/ KY) ( i Y/ i ZX) ,其中,常量KZY/ KY 同样可由实验确定。
触摸坐标的计算由单片机软件实现。在测量触摸位置坐标的同时,也得到了触摸轻重度
的信息,该信息可用于设置触摸轻重度的阈值或唤起一个应用程序。
本文给出了电容式触摸屏控制器的硬件线路,该控制器电路已全部实现。通过硬件线路
设计及相应软件的配合,在触摸同一点的重复精度与触摸灵敏度上得到用户认可,达到了预
想的技术要求,有关控制器的软件部分将另文论述。
本页面信息由华强电子网用户提供,如果涉嫌侵权,请与我们客服联系,我们核实后将及时处理。
应用与方案分类
&&& 目前,处理器性能的主要衡量指标是时钟您的位置: >
触摸屏控制器入门
摘要:本应用笔记介绍怎样使用MAX1233/MAX1234触摸屏控制器的功能。所提供的简化控制台菜单系统支持对MAX1233/MAX1234器件寄存器的底层直接访问。每一寄存器在32个SPI™时钟周期内完成读写操作。软件对每一寄存器使用简短的助记名。使用MAX1234评估板(EV Kit)和MINIQUSB+命令模块时,软件支持最大底层控制。在随附的zip文件中,提供所有源代码。 MAX1233的工作方式和
MAX1234一致,只是MAX1233采用3.3V供电,而不是5.0V。MAX1234评估板上的跳接器JU1使MAX1234工作在3.3V,以仿真MAX1233。注意:符号"/" (例如,/CS)表示CS、PENIRQ、KEYIRQ和BUSY引脚为低电平有效。内容目录MAX1233/MAX1234触摸屏控制器入门1.1) 需要的硬件1.2) MINIQUSB+固件更新说明1.3) 设置1.4) 步骤1.5) 解释SPI data in实例格式2) 模拟I/O实例2.1) 控制DAC输出电压2.2) 选择ADC基准电源模式2.3) 测量外部电压输入AUX1和AUX22.4) 将AUX1和AUX2转换结果译为物理值2.5) 测量外部电压输入BAT1和BAT22.6) 将BAT1和BAT2转换结果译为物理值2.7) 测量内部温度TEMP1和TEMP22.8) 将TEMP1转换结果译为物理值2.9) 将TEMP1和TEMP2转换结果译为物理值2.10) 测量外部电压输入AUX1、AUX2、BAT1、BAT2和温度3) 触摸屏实例3.1) 低成本商用触摸屏3.2) 连接触摸屏和评估板3.3) 验证触摸屏的连接3.4) 检测触摸屏操作:根据需要扫描3.5) 检测触摸屏操作:自动扫描4) 键盘和通用输入/输出引脚4.1) 配置键盘和GPIO引脚4.2) 读写GPIO引脚4.3) 检测按键:自动扫描4.4) 从键盘中屏蔽单个按键4.5) 从键盘中屏蔽一列5) 管理功耗6) 菜单系统6.1) 寄存器读/写命令6.2) 中断和状态引脚命令6.3) 加入到更新后的MINIQUSB+固件中的命令7) 结论
1.1) 需要的硬件
Maxim MAX1234评估板 (MAX1234EVKIT)
Maxim MINIQUSB+ (包括USB A-B电缆和MINIQUSB-X+扩展板)
Windows& 2000/XP PC,支持USB。
四线阻性触摸屏(例如,PDA数字转换器/玻璃屏等)
可选:测量DAC输出电压的DMM
可选:驱动AUX和BAT输入的电压源
可选:示波器,用于观察/PENIRQ和/KEYIRQ引脚上的自动扫描中断脉冲。
1.2) MINIQUSB+固件更新说明/要求/CS引脚在第一次转换结束之前,解除高电平置位;否则,ADC将无法存储转换结果。在使用本应用笔记之前,必须更新标准MINIQUSB+模块固件,使SPI接口/CS引脚在第32个SCLK 1.4&s内解除置位。在2MHz时,32位自动/CS受控模式将/CS保持低电平21.70&s。只需要对MAXQ2000微控制器非易失闪存MINIQUSB+固件更新一次。这一新固件和标准01.05.39基本固件后向兼容。除了提高SPI接口的/CS时序之外,固件更新还包括中断驱动脉冲累加器,在MAX1233/MAX1234配置为自动扫描模式时,支持验证/PENIRQ和/KEYIRQ是否发送其自清除中断脉冲。/PENIRQ的持续时间取决于所配置的ADC转换率,/KEYIRQ的持续时间取决于所配置的开关反弹时间。
1.3) 设置下载并解压缩应用笔记文件 (ZIP, 2.4MB)。根据图1来组装硬件。
按照表1连接MAX1234评估板连接器J1和MINIQUSB-X+扩展电路板(包含在MINIQUSB+中)。可以采用3M&内部连接器来替代连接MAX1234评估板的焊线,将其插入到J1中,以提供方便的连接点。不要连接终端模块TB1。表1. MAX1234评估板和MINIQUSB+电路板之间的连接设置
3.3V supply from MINIQUSB+
GPIO-K7 (MAXQ2000-INT2)
PENIRQ-Bar
GPIO-K6 (MAXQ2000-INT1)
KEYIRQ-Bar
GPIO-K5 (MAXQ2000-INT0)
MISO (SPI master in, slave out)
MOSI (SPI master out, slave in)
SCLK (SPI clock)
CS-bar (SPI chip select)
USB+5V supply from PC* 注释:必须通过连接器J1来驱动MAX1234评估板数字输入,不能直接将其驱动至U1周围的测试点。必须采用板上MAX1841电平转换器来驱动MAX1234评估板数字信号。
将MINIQUSB+插入到扩展板的顶部。
连接MINIQUSB+和PC的USB端口。如果这是MINIQUSB+第一次和PC连接,将出现即插即用向导。指南窗口将提示器件驱动器(它包含在随附zip文件中)的安装位置。
启动固件更新批处理文件FWUPDATE.BAT来更新MINIQUSB+固件。
固件更新完成后,从PC的USB端口断开MINIQUSB+。 图1. 硬件配置(在后面章节中连接触摸屏)。图2. 系统图片,使用一个3M内部连接器来连接MINIQUSB+和MAX1234评估板。
将MAX1234评估板跳接器JU1设置到“MAX1234”位置。
将MINIQUSB+连接至PC的USB端口。确定DACOUT电压 = mid-scale (2.2V)。
启动DEMO1234.EXE程序。屏幕上将出现控制台。
在控制台中输入下面的命令序列。 表2. 连接并验证命令序列
Board connected.
Got board banner: Maxim MINIQUSB V01.05.41 &
Firmware version is OK.
(configured for SPI auto-CS 4-byte mode) (SCLK=2MHz) ...
Write_Register(regAddr=0x000b wr_DAC_data
data=0x00ff
{(no bits defined for this register)}) result = 1
0x000b 0x00ff
DACOUT = full-scale (4.5V)
Read_Register(regAddr=0x800b wr_DAC_data
) result = 1,
buffer = 0x00ff = 255
{(no bits defined for this register)}
0x800b 0x0000
Data buffer = 0x00ff
Write_Register(regAddr=0x000b wr_DAC_data
data=0x0080
{(no bits defined for this register)}) result = 1
0x000b 0x0080
DACOUT = mid-scale (2.2V)
Read_Register(regAddr=0x800b wr_DAC_data
) result = 1,
buffer = 0x0080 = 128
{(no bits defined for this register)}
0x800b 0x0000
data buffer = 0x0080* DEMO1234 Command命令列出了输入到DEMO1234.exe程序中的命令。** Verification列出了可以进行的物理测试,验证所执行的命令。
1.5) SPI data in实例格式SPI data in一列列出了驱动至MAX1233/MAX1234 DIN引脚的SPI数据,采用了十六进制格式,最高有效字节在前。例如,序列0x000b 0x00ff中的SPI数据表示同步输入到DIN的32位序列是00 00 。第一位0用于寄存器写操作,1用于寄存器读操作。寄存器写操作是 a7-a0 d15-d0格式的32位SPI传送过程。寄存器读操作是 a7-a0 格式的32位SPI传送过程,在最后16位,接收到的数据从DOUT同步输入。
2) 模拟I/O实例下面的例子介绍了怎样使用DEMO1234.EXE程序来控制DAC输出,配置基准电压,测量AUX1/AUX2/BAT1/BAT2电压输入,以及测量内部MAX1234温度。
2.1) 控制DAC输出电压由两个寄存器来控制DAC。写入DAC数据寄存器来设置输出电压。写入DAC控制寄存器来关断或者对DAC上电。默认上电状态是DAC加电,DAC输出位于量程中部。DAC满量程电压通常为AVDD的90% (最小85%,最大95%)。对于AVDD = 3.3V ±5%,DACOUT满量程范围在2.65V和3.27V之间,通常为2.96V。对于AVDD = 5.0V ±5%,DACOUT满量程范围在4.02V和4.97V之间,通常为4.48V。表3. DAC输出命令
DACOUT = full-scale
0x000b 0x00ff
DACOUT = 2.96V
DACOUT = 4.48V
DACOUT = 0V
0x000b 0x0000
DACOUT = 0.0V
DACOUT = 0.0V
DACOUT = mid-scale
0x000b 0x0080
DACOUT = 1.485V
DACOUT = 2.25V
T W DC 8000
Disable DAC
DACOUT = 0.0V
DACOUT = 0.0V
Enable DAC
DACOUT = 1.485V
DACOUT = 2.25V
2.2) 选择ADC基准电源模式ADC需要一个基准电压。对于典型的嵌入式系统工作,默认设置是fine。在自动上电模式(ADC3210 = 0000,RES10 = 00)下,MAX1233/MAX1234提供自己的内部基准电压。在每次测量之前,内部基准自动上电,测量完成后关断。对于第一次诊断,保持上电模式(ADC3210 = 0000,RES10 = 01)支持使用手持式DVM对基准电压进行外部验证。ADC扫描选择位设置为0000,写入ADC控制寄存器(0x40),来设置ADC基准电源模式。RES1/RES0位选择基准电源模式,基准控制位RFV选择内部1.0V或者2.5V基准(请参考MAX1233/MAX1234数据资料的表13)。ADC控制字:x x 0 0 0 0 RES1 RES0 x x x x x x x RFV表4. 内部基准命令
T W AC 0100
Internal 1V refe write ADC control word with ADC3210 = 0000, RES10 = 01, RFV = 0
Voltage at pin 12 REF is between 0.98V and 1.02V
T W AC 0101
Internal 2.5V refe write ADC control word with ADC3210 = 0000, RES10 = 01, RFV = 1
Voltage at pin 12 REF is between 2.47V and 2.53V
T W AC 0001
Internal 2.5V reference write ADC control word with ADC3210 = 0000, RES10 = 00, RFV = 1
Voltage at pin 12 REF will be powered only briefly as necessary表5. 外部基准命令
T W AC 0300
External refereADC_control_wr_demand_scan:(write)demand scan ADC_control_AD0000:configure reference ADC_control_RES11:external reference
2.3) 测量外部电压输入AUX1和AUX2表6. ADC测量命令序列
Measure AUX1 with 12-bit resolution and 3.5&s conversion rate
T W AC 2301
Trigger ADC scan of AUX1;ADC control word 0x2301 means:ADC_control_wr_demand_scanADC_control_AD1000 /* measure AUX1 */ADC_control_RES11 /* 12-bit resolution */ADC_control_AVG00 /* no averaging */ADC_control_CNR00 /* conversion rate 3.5&s */ADC_control_RFV /* RFV=1: VREF=2.5V */
Read AUX1 result AUX1_code
Measure AUX2 with 12-bit resolution and 3.5&s conversion rate
2.4) 将AUX1和AUX2转换结果译为物理值下面的C/C++伪代码片断总结了DEMO1234程序是怎样解释AUX1和AUX2转换结果的。
/* ADC control resolution value selects num_codes 4096 (12-bit), 1024 (10-bit), or 256 (8-bit) */
int num_codes = 4096; /* ADC_control_RES11: 12-bit resolution */
/* Voltage that corresponds to the full-scale ADC may be internal 1V or 2.5V ref, or ext ref. */
double ADC_fullscale_voltage = 2.5; /* ADC_control_RFV=1: VREF=2.5V.
RFV=0: VREF=1.0V. */
/* AUX1_code is the 16-bit result read by SPI command 0x8007 */
double AUX1_Voltage = (AUX1_code * ADC_fullscale_voltage) / num_
/* AUX2_code is the 16-bit result read by SPI command 0x8008 */
double AUX2_Voltage = (AUX2_code * ADC_fullscale_voltage) / num_
2.5) 测量外部电压输入BAT1和BAT2表7. ADC测量命令序列
Measure BAT1 with 12-bit resolution and 3.5&s conversion rate
T W AC 1b01
Trigger ADC scan of BAT1;ADC control word 0x1b01 means:ADC_control_wr_demand_scanADC_control_AD0110 /* measure BAT1 */ADC_control_RES11 /* 12-bit resolution */ADC_control_AVG00 /* no averaging */ADC_control_CNR00 /* conversion rate 3.5&s */ADC_control_RFV /* RFV=1: VREF=2.5V */
Read BAT1 result BAT1_code
T W AC 1b21
Trigger ADC scan of BAT1;ADC control word 0x1b21 means:ADC_control_wr_demand_scanADC_control_AD0110 /* measure BAT1 */ADC_control_RES11 /* 12-bit resolution */ADC_control_AVG00 /* no averaging */ADC_control_CNR10 /* conversion rate 10&s */ADC_control_RFV /* RFV=1: VREF=2.5V */
Read BAT1 result BAT1_code
Measure BAT2 with 12-bit resolution and 3.5&s conversion rate
2.6) 将BAT1和BAT2转换结果译为物理值下面的C/C++伪代码片断总结了DEMO1234程序是怎样解释BAT1和BAT2转换结果的。注意:通过一个4:1输入分配器来测量BAT1和BAT2。
/* ADC control resolution value selects num_codes 4096 (12-bit), 1024 (10-bit), or 256 (8-bit) */
int num_codes = 4096; /* ADC_control_RES11: 12-bit resolution */
/* Voltage that corresponds to the full-scale ADC may be internal 1V or 2.5V ref, or ext ref. */
double ADC_fullscale_voltage = 2.5; /* ADC_control_RFV=1: VREF=2.5V.
RFV=0: VREF=1.0V. */
/* Note: BAT1 and BAT2 measure through a 4:1 input divider. */
/* BAT1_code is the 16-bit result read by SPI command 0x8005 */
double BAT1_Voltage = 4 * (BAT1_code * ADC_fullscale_voltage) / num_
/* BAT2_code is the 16-bit result read by SPI command 0x8006 */
double BAT2_Voltage = 4 * (BAT2_code * ADC_fullscale_voltage) / num_
2.7) 测量内部温度TEMP1和TEMP2表8. ADC测量命令序列
Measure TEMP1 with 12-bit resolution and 3.5&s conversion rate
T W AC 2b01
Trigger ADC scan of TEMP1;ADC control word 0x2b01 means:ADC_control_wr_demand_scanADC_control_ AD1010 /* measure TEMP1 */ADC_control_RES11 /* 12-bit resolution */ADC_control_AVG00 /* no averaging */ADC_control_CNR00 /* conversion rate 3.5&s */ADC_control_RFV /* RFV=1: VREF=2.5V */
Read TEMP1 result TEMP1 _code
Measure TEMP1, TEMP2 with 12-bit resolution and 3.5&s conversion rate
0x10x00x800a 0x0000
T W AC 3301
Trigger ADC scan of TEMP1 and TEMP2;ADC control word 0x3301 means:ADC_control_wr_demand_scanADC_control_ AD1100 /* measure TEMP1,TEMP2 */ADC_control_RES11 /* 12-bit resolution */ADC_control_AVG00 /* no averaging */ADC_control_CNR00 /* conversion rate 3.5&s */ADC_control_RFV /* RFV=1: VREF=2.5V */
Read TEMP1 result TEMP1 _code
Read TEMP2 result TEMP2 _code
0x800a 0x0000
2.8) 将TEMP1转换结果译为物理值下面的C/C++伪代码片断总结了DEMO1234程序是怎样解释TEMP1转换结果的。
/* ADC control resolution value selects num_codes 4096 (12-bit), 1024 (10-bit), or 256 (8-bit) */
int num_codes = 4096; /* ADC_control_RES11: 12-bit resolution */
/* Voltage that corresponds to the full-scale ADC may be internal 1V or 2.5V ref, or ext ref. */
double ADC_fullscale_voltage = 2.5; /* ADC_control_RFV=1: VREF=2.5V.
RFV=0: VREF=1.0V. */
/* TEMP1_code is the 16-bit result read by SPI command 0x8009 */
double TEMP1_Voltage = (TEMP1_code * ADC_fullscale_voltage) / num_
/* Calibration values */
const double Temp1V_Room = 0.590; // temp1 voltage at room temperature 25C
const double Temp1K_Room = 298.15;
// Room temperature Kelvins (298.15K=25C)
const double Temp1V_Per_K = -0.002; // TempCo -2mV per degree C
/* Convert to absolute temperature */
double Kelvin = (TEMP1_Voltage - Temp1V_Room) / Temp1V_Per_K + Temp1K_R
/* Optional conversion to commonly used temperature units */
double Centigrade = Kelvin - 273.15;
double Fahrenheit = (Centigrade * 9.0 / 5.0) + 32;
2.9) 将TEMP1和TEMP2转换结果译为物理值下面的C/C++伪代码片断总结了DEMO1234程序是怎样解释TEMP1和TEMP2转换结果的。TEMP2只在和TEMP1对比时才有意义。
/* ADC control resolution value selects num_codes 4096 (12-bit), 1024 (10-bit), or 256 (8-bit) */
int num_codes = 4096; /* ADC_control_RES11: 12-bit resolution */
/* Voltage that corresponds to the full-scale ADC may be internal 1V or 2.5V ref, or ext ref. */
double ADC_fullscale_voltage = 2.5; /* ADC_control_RFV=1: VREF=2.5V.
RFV=0: VREF=1.0V. */
/* TEMP1_code is the 16-bit result read by SPI command 0x8009 */
double TEMP1_Voltage = (TEMP1_code * ADC_fullscale_voltage) / num_
/* TEMP2_code is the 16-bit result read by SPI command 0x800a */
double TEMP2_Voltage = (TEMP2_code * ADC_fullscale_voltage) / num_
/* Calibration values */
const double K_Per_Temp21_Delta_V = 2680.0; // nominal /2002
/* Convert to absolute temperature */
double Kelvin = (TEMP2_Voltage - TEMP1_Voltage) * K_Per_Temp21_Delta_V;
/* Optional conversion to commonly used temperature units */
double Centigrade = Kelvin - 273.15;
double Fahrenheit = (Centigrade * 9.0 / 5.0) + 32;
2.10) 测量外部电压输入AUX1、AUX2、BAT1、BAT2和温度表9. ADC测量命令序列
Measure BAT1/4, BAT2/4, AUX1, AUX2, TEMP1, TEMP2 with 12-bit resolution and 3.5&s conversion rate
0xf010x00x00x00x00x00x800a 0x0000
T W AC 2f01
Trigger ADC scan of BAT1-2, AUX1-2, TEMP1-2;ADC control word 0x2f01 means:ADC_control_wr_demand_scanADC_control_ AD1011 /* measure AUX1 etc. */ADC_control_RES11 /* 12-bit resolution */ADC_control_AVG00 /* no averaging */ADC_control_CNR00 /* conversion rate 3.5&s */ADC_control_RFV /* RFV=1: VREF=2.5V */
Read BAT1 result BAT1 _code
Read BAT2 result BAT2_code
Read AUX1 result AUX1 _code
Read AUX2 result AUX2 _code
Read TEMP1 result TEMP1 _code
Read TEMP2 result TEMP2 _code
0x800a 0x0000
3) 触摸屏实例下面的例子解释了怎样使用DEMO1234.EXE程序来获得触摸屏数据。
3.1) 低成本商用触摸屏在互联网上搜索"PDA Digitizer/Glasstop",寻找合适的替代触摸屏。高清触摸屏玻璃的价格范围在50美元至10美元之间,价格取决于型号以及玻璃是否全部贴在显示屏上。
3.2) 连接触摸屏和评估板MAX1234评估板提供突出插头H5/H6来连接10mm柔性电缆或者长度更短的电缆。H6连接器的间距是0.5mm,比实际触摸屏柔性电缆间距更精细。把柔性电缆插入H6,上锁,选择位于四条柔性电缆中每一电缆中心位置的H5引脚。跳接器连接H5和标有U1的X+、Y+、X-以及Y-测试点。
3.3) 检验触摸屏的连接第一次连接触摸屏时,通过下面的步骤来验证X和Y连接是否正确。可以有几个触摸屏交叉连接,但大部分不会正常工作。在这些例子中,我们假设X- = left,X+ = right,Y- = top,Y+ = bottom。表10. 触摸屏物理连接验证命令序列
Connect DVM to X+/GND
N drive Y+,Y-
Touch top left
X+ = approx. Y-
Touch top right
X+ = approx. Y-
Touch bottom left
X+ = approx. Y+
Touch bottom right
X+ = approx. Y+
Connect DVM to Y+/GND
N drive X+,X-
Touch top left
Y+ = approx. X-
Touch top right
Y+ = approx. X+
Touch bottom left
Y+ = approx. X-
Touch bottom right
Y+ = approx. X+表11. 纠正触摸屏连接问题
Touch coordinates are mirrored top-to-bottom
Swap the Y+ and Y- connections
Touch coordinates are mirrored left-to-right
Swap the X+ and X- connections
Touch coordinates are rotated 180 degrees
Swap the X+ and X- connections, and swap the Y+ and Y- connections
Touch coordinates are mirrored diagonally
Swap the X+ and Y+ connections, and swap the X- and Y- connections
Touch coordinates do not seem to track, and the distortion is not a simple flip/rotate/mirror transformation
Swap the X+ and Y+if distortion persists, swap the X+ and Y-if distortion still persists, disconnect touch screen and use DVM to verify X+ to X- resistance and Y+ to Y-verify with no touch X+ and X- are isolated from Y+ and Y-
3.4) 检测触摸屏的操作:根据需要扫描在配置MAX1234检测触摸屏操作,根据需要数字化接触屏的位置时,写入寄存器0x40 (ADC控制),其PENSTS=0,ADSTS=0 (请参考MAX1233/MAX1234数据资料的表6)。读取寄存器0x00 (X轴)后,检测到后续的触摸屏操作时,/PENIRQ信号锁存至低电平,在写入ADC控制寄存器测量X、Y轴之前,保持低电平。 表12. 触摸屏检测命令序列:根据需要扫描
T W AC 0b01
Demand scan
Read conversion result register X
Read PENIRQ-bar pin status
PENIRQ = 1
Touch the touch screen
Read PENIRQ-bar pin status
PENIRQ = 0
Measure X,Y,Z1,Z2
0xb010x00x00x00x0
Read PENIRQ-bar pin status
PENIRQ = 1
Touch and hold the touch screen
Read PENIRQ-bar pin status
PENIRQ = 0
Measure X,Y,Z1,Z2
0xb010x00x00x00x0
Read PENIRQ-bar pin status
PENIRQ = 0
Measure X,Y,Z1,Z2
0xb010x00x00x00x0
Read PENIRQ-bar pin status
PENIRQ = 0
Release the touch screen
Read PENIRQ-bar pin status
PENIRQ = 0
Measure X,Y,Z1,Z2
0xb010x00x00x00x0
Read PENIRQ-bar pin status
PENIRQ = 1
3.5) 检测触摸屏操作:自动扫描在检测触摸屏操作,配置MAX1234,自动数字化触摸屏的接触位置时,写入寄存器0x40 (ADC控制),其PENSTS=1,ADSTS=0 (请参考MAX1233/MAX1234数据资料的表6)。第一次接触屏幕时,/PENIRQ信号暂时变为低电平,并在读取X寄存器之前不会变化。表13. 触摸屏检测命令序列:自动扫描
Optional: connect oscilloscope to PENIRQ-bar
Configure PENIRQ-bar pulse accumulator: falling-edge trigger
Reset the pulse accumulator
Read the number of times PENIRQ-bar has pulsed low
T W AC 8bff
Wait for touch, then scan X,Y,Z1,Z2
Touch the touch screen
PENIRQ pulse
Read the number of times PENIRQ-bar has pulsed low
count has increased
Read X,Y,Z1,Z2 conversion results
0x00x00x00x0
Touch the touch screen
PENIRQ pulse
Read the number of times PENIRQ-bar has pulsed low
count has increased
Read X,Y,Z1,Z2 conversion results
0x00x00x00x0
Touch the touch screen
PENIRQ pulse
Read the number of times PENIRQ-bar has pulsed low
count has increased
Read X,Y,Z1,Z2 conversion results
0x00x00x00x0
4) 键盘和通用输入/输出引脚下面的例子介绍了怎样使用DEMO1234.EXE程序来扫描键盘,怎样使用GPIO键盘扫描引脚。
4.1) 配置键盘和GPIO引脚GPIO控制寄存器将每个C1–C4和R1–R4引脚分别配置为输入、输出或者是键盘的一部分(请参考MAX1233/MAX1234数据资料的表26和表27)。此外,写入GPIO上拉禁止寄存器,将输出引脚配置为开漏输出。表14. 键盘和GPIO配置实例
T W GC FFFF
Keypad:GPIO outputs: C4,C3,C2,C1,R4,R3,R2,R1;GPIO inputs: none
0x004f 0xffff
T W GC FF00
Keypad:GPIO outputs:GPIO inputs: C4,C3,C2,C1,R4,R3,R2,R1
0x004f 0xff00
T W GC 0000
Keypad: (C4,C3,C2,C1) x (R4,R3,R2,R1);GPIO outputs:GPIO inputs: none
0x004f 0x0000
T W GC C8C0
Keypad: (C2,C1) x (R3,R2,R1);GPIO outputs: C4,C3;GPIO input: R4
0x004f 0xc8c0
T W GP 4000
GPIO pullup disable: C3
0x004e 0x4000
4.2) 读写GPIO引脚GPIO数据寄存器读取GPIO输入引脚,写入GPIO输出引脚。注意:在这些例子中,C3、C4和R4是引脚名称,而不是元件名称。表15. GPIO实例
T W GC C8C0
Keypad:(C2,C1) x (R3,R2,R1);GPIO outputs: C4,C3;GPIO input: R4
0x004f 0xc8c0
T W GP 4000
GPIO pullup disable: C3
0x004e 0x4000
Connect external resistor between C3 pin and DVDD
Connect DVM to C4 pin
T W GD 8000
GPIO write C4 = 1
0x000f 0x8000
C4 pin = high
T W GD 0000
GPIO write C4 = 0
0x000f 0x0000
C4 pin = low
T W GD 8000
GPIO write C4 = 1
0x000f 0x8000
C4 pin = high
T W GD 0000
GPIO write C4 = 0
0x000f 0x0000
C4 pin = low
Connect DVM to C3 pin
T W GD 4000
GPIO write C3 = 1
0x000f 0x4000
C3 pin = high
T W GD 0000
GPIO write C3 = 0
0x000f 0x0000
C3 pin = low
T W GD 4000
GPIO write C3 = 1
0x000f 0x4000
C3 pin = high
T W GD 0000
GPIO write C3 = 0
0x000f 0x0000
C3 pin = low
Connect R4 pin to DVDD
0x800f 0x0000
Buffer = 0x0800
Connect R4 pin to GND
0x800f 0x0000
Buffer = 0x0000
4.3) 检测按键:自动扫描可以配置键盘控制寄存器在探测到有按键按下时,自动扫描键盘。表16. 按键命令序列:自动扫描
Optional: connect oscilloscope to KEYIRQ-bar
Configure KEYIRQ-bar pulse accumulator: falling-edge trigger
Reset the pulse accumulator
Read the number of times KEYIRQ-bar has pulsed low
T W GC 0000
Keypad:(C4,C3,C2,C1) x (R4,R3,R2,R1);GPIO outputs:GPIO inputs: none
0x004f 0x0000
T W KC bf00
Wmaximum debounce and hold times
0x0041 0xbf00
Press and release R1C1 (key "1")
KEYIRQ pulse
Read the number of times KEYIRQ-bar has pulsed low
count has increased
Read raw keypad result
0x0001 = R1C1 key
Press and release R2C2 (key "5")
KEYIRQ pulse
Read the number of times KEYIRQ-bar has pulsed low
count has increased
Read raw keypad result
0x0020 = R2C2 key
Press and release R3C2 (key "8")
KEYIRQ pulse
Read the number of times KEYIRQ-bar has pulsed low
count has increased
Read raw keypad result
0x0040 = R3C2 key
4.4) 从键盘中屏蔽单个按键使用键盘屏蔽寄存器和键盘2结果寄存器来屏蔽每个按键。屏蔽掉的按键被扫描至KPD寄存器,但是不在键盘2结果寄存器中报告。表17. 按键命令序列:屏蔽单个按键
T W GC 0000
Keypad:(C4,C3,C2,C1) x (R4,R3,R2,R1);GPIO outputs:GPIO inputs: none
0x004f 0x0000
T W KC bf00
Wmaximum debounce and hold times
0x0041 0xbf00
T W KM 0020
Mask only R2C2 key
Press and release R1C1 (key "1")
Read raw keypad result
0x0001 = R1C1 key
Read masked keypad result
0x0001 = R1C1 key
Press and release R2C2 (key "5")
Read raw keypad result
0x0020 = R2C2 key
Read masked keypad result
0x0000 = no key
Press and release R3C2 (key "8")
Read raw keypad result
0x0040 = R3C2 key
Read masked keypad result
0x0040 = R3C2 key
4.5) 从键盘中屏蔽一列使用键盘列寄存器来屏蔽所有列。不扫描屏蔽列,因此,KPD寄存器不会探测这些列中的按键。表18. 按键命令序列:屏蔽键盘的一列
T W GC 0000
Keypad:(C4,C3,C2,C1) x (R4,R3,R2,R1);GPIO outputs:GPIO inputs: none
0x004f 0x0000
T W KC bf00
Wmaximum debounce and hold times
0x0041 0xbf00
T W KK 2000
Mask entire C2 column
Press and release R1C1 (key "1")
Read raw keypad result
0x0001 = R1C1 key
Press and release R2C2 (key "5")
Read raw keypad result
(previous value)
Press and release R3C2 (key "8")
Read raw keypad result
(previous value)
Press and release R2C3 (key "6")
Read raw keypad result
0x0200 = R2C3 key
5) 电源管理表19. 关断命令
T W AC C000
Power off ADC
T W AC 0300
Power off internal reference
REF = not driven
T W DC 8000
Disable DAC
DACOUT = 0.0V
T W KC C000
Power off keypad
6) 菜单系统全部源代码实现下面的控制台菜单系统,它连接至MINIQUSB+模块。CmodComm测试程序主菜单—在连接前A) adjust timing parametersL) CmodLog... functionsC) connectD) Debug MessagesX) exit对C (连接)命令的响应CHardware supports optimized native SMBus commands.Board connected.Got board banner: Maxim MINIQUSB V01.05.41 &Firmware version is OK.(configured for SPI auto-CS 4-byte mode) (SCLK=2MHz) ...主菜单—连接后有效T) Test the device8) CmodP8Bus... functionsA) adjust timing parametersL) CmodLog... functionsP) CmodPin... functionsS) CmodSpi... functionsM) CmodSMBus... functions$) CmodCommStringWrite list of hex codesR) CmodBoardResetD) Disconnect测试菜单命令—连接后有效R) Read registerW) Write registerM0) me configure referenceM1) measure X,YM2) measure X,Y,Z1,Z2M3) measure XM4) measure YM5) measure Z1,Z2M6) measure BAT1/4M7) measure BAT2/4M8) measure AUX1M9) measure AUX2MA) measure TEMP1MB) measure BAT1/4,BAT2/4,AUX1,AUX2,TEMP1,TEMP2MC) measure TEMP1,TEMP2MD) drive Y+,Y-ME) drive X+,X-MF) drive Y+,X-.) Exit this menu
6.1) 寄存器读/写命令表20. 读取寄存器助记符
Test Read AUX1 register
Test Read AUX2 register
Test Read ADC_control register
Test Read X register
Test Read Y register
Test Read Z1 register
Test Read Z2 register
Test Read BAT1 register
Test Read BAT2 register
Test Read DAC_control register
Test Read DAC_data register
0x800b 0x0000
Test Read GPIO_control register
0x804f 0x0000
Test Read GPIO_data register
0x800f 0x0000
Test Read GPIO_pullup register
0x804e 0x0000
Test Read KPDATA1 register
Test Read KPDATA2 register
Test Read KPD register
Test Read KEY_control register
Test Read KPCOLMASK register
Test Read KPKEYMASK register
Test Read TEMP1 register
Test Read TEMP2 register
0x800a 0x0000表21. 写入寄存器助记符
T W AC hexValue
Test Write ADC_control register
0x0040 hexValue
T W DC hexValue
Test Write DAC_control register
0x0042 hexValue
T W DD hexValue
Test Write DAC_data register
0x000b hexValue
T W GC hexValue
Test Write GPIO_control register
0x004f hexValue
T W GD hexValue
Test Write GPIO_data register
0x000f hexValue
T W GP hexValue
Test Write GPIO_pullup register
0x004e hexValue
T W KC hexValue
Test Write KEY_control register
0x0041 hexValue
T W KK hexValue
Test Write KPCOLMASK register
0x0051 hexValue
T W KM hexValue
Test Write KPKEYMASK register
0x0050 hexValue表22. 触摸屏测量命令序列
Measure X,Y
Measure X,Y,Z1,Z2
0xb010x00x00x00x0
Measure Z1,Z2
N drive Y+,Y-
N drive X+,X-
N drive Y+,X-
6.2) 中断和状态引脚命令表23. 引脚状态读取命令
Read KEYIRQ-bar pin status
Enable KEYIRQ-bar falling-edge trigger pulse accumulator
Enable KEYIRQ-bar rising-edge trigger pulse accumulator
Disable KEYIRQ-bar pulse accumulator
Read the number of times KEYIRQ-bar has pulsed low
Clear the KEYIRQ-bar pulse accumulator
Read PENIRQ-bar pin status
Enable PENIRQ-bar falling-edge trigger pulse accumulator
Enable PENIRQ-bar rising-edge trigger pulse accumulator
Disable PENIRQ-bar pulse accumulator
Read the number of times PENIRQ-bar has pulsed low
Clear the PENIRQ-bar pulse accumulator
Read BUSY-bar pin status
6.3) 加入到更新后的MINIQUSB+固件中的命令表24. 更新后MINIQUSB+固件01.05.40支持的SPI命令
Configure SPI for CPOL=0
Configure SPI for CPOL=1
Configure SPI for CPHA=0
Configure SPI for CPHA=1
Configure SPI for 8-bit
Configure SPI for 8-bit auto-CS-bar
Configure SPI for 16-bit auto-CS-bar
Configure SPI for 24-bit auto-CS-bar
Configure SPI for 32-bit auto-CS-bar
$ 2 AE 00
Configure SPI for 8-bit
$ 2 AE 01
Configure SPI for 8-bit
$ 2 AE 02
Configure SPI for 8-bit
$ 2 AE 03
Configure SPI for 8-bit
$ 2 AE 08
Configure SPI for 8-bit auto-CS-bar
$ 2 AE 09
Configure SPI for 8-bit auto-CS-bar
$ 2 AE 0A
Configure SPI for 8-bit auto-CS-bar
$ 2 AE 0B
Configure SPI for 8-bit auto-CS-bar
$ 2 AE 18
Configure SPI for 16-bit auto-CS-bar
$ 2 AE 19
Configure SPI for 16-bit auto-CS-bar
$ 2 AE 1A
Configure SPI for 16-bit auto-CS-bar
$ 2 AE 1B
Configure SPI for 16-bit auto-CS-bar
$ 2 AE 28
Configure SPI for 24-bit auto-CS-bar
$ 2 AE 29
Configure SPI for 24-bit auto-CS-bar
$ 2 AE 2A
Configure SPI for 24-bit auto-CS-bar
$ 2 AE 2B
Configure SPI for 24-bit auto-CS-bar
$ 2 AE 38
Configure SPI for 32-bit auto-CS-bar
$ 2 AE 39
Configure SPI for 32-bit auto-CS-bar
$ 2 AE 3A
Configure SPI for 32-bit auto-CS-bar
$ 2 AE 3B
Configure SPI for 32-bit auto-CS-bar
$ 2 AF xx
Perform an 8-bit SPI transfer (CS-bar = GPIO or auto-CS-bar = 1-byte)
$ 3 AF xx xx
Perform a 16-bit SPI transfer (requires auto-CS-bar = 2-byte mode)
$ 4 AF xx xx xx
Perform a 24-bit SPI transfer (requires auto-CS-bar = 3-byte mode)
$ 5 AF xx xx xx xx
Perform a 32-bit SPI transfer (requires auto-CS-bar = 4-byte mode)
$ 2 F9 0
Drive CS-bar pin low
$ 2 F9 1
Drive CS-bar pin high
—表25. 更新后MINIQUSB+固件01.05.41中的中断脉冲累加器命令
$ 2 C3 00
Query which of the C3 co the return value is a 2-byte bitmap of commands C300 to C30F, msb first
Query configuration of pulse accumulator
Query configuration of pulse accumulator
Query configuration of pulse accumulator
Query configuration of pulse accumulator
Configure pulse accumulator: disable interrupt
C3 02 00 00
Configure pulse accumulator: disable interrupt
C3 02 01 00
Configure pulse accumulator: disable interrupt
C3 02 02 00
Configure pulse accumulator: disable interrupt
C3 02 03 00
Configure pulse accumulator: rising-edge trigger
C3 02 00 01
Configure pulse accumulator: rising-edge trigger
C3 02 01 01
Configure pulse accumulator: rising-edge trigger
C3 02 02 01
Configure pulse accumulator: rising-edge trigger
C3 02 03 01
Configure pulse accumulator: falling-edge trigger
C3 02 00 03
Configure pulse accumulator: falling-edge trigger
C3 02 01 03
Configure pulse accumulator: falling-edge trigger
C3 02 02 03
Configure pulse accumulator: falling-edge trigger
C3 02 03 03
Read pulse accumulator
Read pulse accumulator
Read pulse accumulator
Read pulse accumulator
Clear pulse accumulator
Clear pulse accumulator
Clear pulse accumulator
Clear pulse accumulator
Set pulse accumulator count xx = 0 to 255
C3 05 00 xx
Set pulse accumulator count xx = 0 to 255
C3 05 01 xx
Set pulse accumulator count xx = 0 to 255
C3 05 02 xx
Set pulse accumulator count xx = 0 to 255
C3 05 03 xx
7) 结论这些实例简要介绍了怎样使用MAX1233/MAX1234的主要功能模块,利用简化的控制台C++程序来测量并控制硬件。如果需要深入了解详细信息,请参考MAX1233/MAX1234数据资料。
非常好我支持^.^
不好我反对
相关阅读:
( 发表人:发烧友 )
评价:好评中评差评
技术交流、我要发言
发表评论,获取积分! 请遵守相关规定!提 交
Powered by: 电子发烧友 (
. .All Rights Reserved 粤ICP备号}

我要回帖

更多关于 led controller控制器 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信