TI推出的电感数据转换器LDC1000,LDC1000是一款一种非触摸式、短程传感技能的传感器芯片,具有低本钱、高分辨率遥感的导电性。
因为LDC技能的优势显着,十分合适工厂流水线上的运动状况的传感检测,在工业机器人及智能工厂等工业范畴将发挥杰出效果。
LDC 技能的首要优势:
• 更高的分辨率:可通过 16 位共振阻抗及 24 位电感值,在方位传感运用中完成亚微米级分辨率;
• 更高的可靠性:供给非触摸传感技能避免受油污尘土等非导电污染物的影响,可延长设备运用寿命;
• 更高的灵活性:答应传感器远离电子产品安放,处于 PCB 无法安放的方位;
• 更低的体系本钱:选用低本钱传感器及传导方针,无需磁体;
• 无限或许性:支撑紧缩的金属薄片或导电油墨方针,可为创造性立异体系规划带来无限或许;
• 更低的体系功耗:规范作业时功耗缺乏 8.5mW,待机形式下功耗缺乏 1.25mW。
LDC1000的底层驱动程序:
#ifndef LDC1000_CMD_H_ #define LDC1000_CMD_H_
/************************************** ************* VCC ****************** ************* CLK ****************** ************* DI ****************** ************* DO ****************** ************* CS ****************** ************* GND ****************** **************************************/
#define LDC1000_DO 3 //IN #define LDC1000_CS 5 //out #define LDC1000_DI 6 //out #define LDC1000_CLK 7 //out
#define LDC1000_CS_SET() DATA_OUT(LDC1000_CS,1) #define LDC1000_DI_SET() DATA_OUT(LDC1000_DI,1) #define LDC1000_CLK_SET() DATA_OUT(LDC1000_CLK,1)
#define LDC1000_CS_CLR() DATA_OUT(LDC1000_CS,0) #define LDC1000_DI_CLR() DATA_OUT(LDC1000_DI,0) #define LDC1000_CLK_CLR() DATA_OUT(LDC1000_CLK,0)
#define LDC1000_DO_IN gpio_get(PORTB,LDC1000_DO)
#define Dly_LDC1000CLK() delay250ns(1)
#define RPMAX 0x13 #define RPMIN 0x3A
// LDC COMMANDS
#define LDC1000_CMD_REVID 0x00 #define LDC1000_CMD_RPMAX 0x01 #define LDC1000_CMD_RPMIN 0x02 #define LDC1000_CMD_SENSORFREQ 0x03 #define LDC1000_CMD_LDCCONFIG 0x04 #define LDC1000_CMD_CLKCONFIG 0x05 #define LDC1000_CMD_THRESHILSB 0x06 #define LDC1000_CMD_THRESHIMSB 0x07 #define LDC1000_CMD_THRESLOLSB 0x08 #define LDC1000_CMD_THRESLOMSB 0x09 #define LDC1000_CMD_INTCONFIG 0x0A
#define LDC1000_CMD_PWRCONFIG 0x0B #define LDC1000_CMD_STATUS 0x20 #define LDC1000_CMD_PROXLSB 0x21 #define LDC1000_CMD_PROXMSB 0x22 #define LDC1000_CMD_FREQCTRLSB 0x23 #define LDC1000_CMD_FREQCTRMID 0x24 #define LDC1000_CMD_FREQCTRMSB 0x25
// LDC BITMASKS
#define LDC1000_BIT_AMPLITUDE 0x18 #define LDC1000_BIT_RESPTIME 0x07 #define LDC1000_BIT_CLKSEL 0x02 #define LDC1000_BIT_CLKPD 0x01 #define LDC1000_BIT_INTMODE 0x07 #define LDC1000_BIT_PWRMODE 0x01 #define LDC1000_BIT_STATUSOSC 0x80 #define LDC1000_BIT_STATUSDRDYB 0x40 #define LDC1000_BIT_STATUSWAKEUP 0x20 #define LDC1000_BIT_STATUSCOMP 0x10
void delay250ns(uint32 ms);
void DATA_OUT(uint8 pin,uint8 level);
void LDC1000_write(char ADDR, char data);
void LDC1000_read(uint8 ADDR,char *DATA,char len); void LDC1000_init();
#endif /* LDC1000_CMD_H_ */
#include “LDC1000_cmd.h” char orgVal[20];
/************************************************************************* * 函数称号:delayms
* 功用阐明:延时函数(不精确),内核频率为100M时较为精确 * 备 注:
*************************************************************************/ void delay250ns(uint32 ms) {
uint32 i, j;
for(i = 0; i 《 ms; i++) {
for(j = core_clk_mhz/8; j 》 0; j–)
{
asm(“nop”); } } }
/*******************************************************************************
* Function Name : DATA_OUT
* Description : SCCB数据线的状况 包含输入输出 电平 * Input : uint8 pin 输入?输出? 1为输出 0输入 * :uint8 data 电平
*******************************************************************************/
void DATA_OUT(uint8 pin,uint8 level) {
if(level) {
GPIO_PDOR_REG(PTB_BASE_PTR) |= 1《《pin; //第0位输出1 } else {
GPIO_PDOR_REG(PTB_BASE_PTR) = ~(1《《pin); //第0位输出0 } }
void LDC1000_write(char ADDR, char data) {
uint8 addr=0,dat=0,i=0;
addr = ADDR 0x7f; dat = data;
LDC1000_CS_CLR(); //片选低 Dly_LDC1000CLK();
LDC1000_CLK_CLR(); // Set clock line low for(i=0;i《16;i++) {
if(i《8)//写8位指令段 {
if(addr0X80) LDC1000_DI_SET(); else LDC1000_DI_CLR(); Dly_LDC1000CLK();
LDC1000_CLK_SET(); // Set clock line high
addr 《《= 1; // Shift DATA_BUF Dly_LDC1000CLK();
LDC1000_CLK_CLR(); // Set clock line low } else {
if(dat0X80) LDC1000_DI_SET(); else LDC1000_DI_CLR(); Dly_LDC1000CLK();
LDC1000_CLK_SET(); // Set clock line high dat 《《= 1; // Shift DATA_BUF Dly_LDC1000CLK();
LDC1000_CLK_CLR(); // Set clock line low } }
Dly_LDC1000CLK();
LDC1000_CS_SET(); //片选高 }
void LDC1000_read(uint8 ADDR,char *DATA,char len) {
uint8 addr=0,dat=0,i=0,j=0;
addr = ADDR | 0x80;
LDC1000_CLK_CLR(); // Set clock line low for(i=0;i《8;i++)//写8位指令段 {
if(addr0X80) LDC1000_DI_SET(); else LDC1000_DI_CLR(); Dly_LDC1000CLK(); LDC1000_CLK_SET();
addr 《《= 1; // Shift DATA_BUF Dly_LDC1000CLK();
LDC1000_CLK_CLR(); // Set clock line high }
for(i=0;i《len;i++) {
dat=0;
for(j=0;j《8;j++) {
dat 《《=1 // Right shift DATA_BUF
Dly_LDC1000CLK(); LDC1000_CLK_SET(); // Set clock line high
Dly_LDC1000CLK();
if(LDC1000_DO_IN) dat |= 0x01; // Read data LDC1000_CLK_CLR(); // Set clock line low }
DATA[i] = dat; } }
void LDC1000_init() {
/* 翻开B端口的时钟源 */
SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK
/* LDC运用IO端口初始化 */
PORTB_PCR3 = PORT_PCR_MUX(1); PORTB_PCR5 = PORT_PCR_MUX(1); PORTB_PCR6 = PORT_PCR_MUX(1); PORTB_PCR7 = PORT_PCR_MUX(1);
gpio_init(PORTB,LDC1000_CLK,GPO,LOW); gpio_init(PORTB,LDC1000_DI,GPO,LOW); gpio_init(PORTB,LDC1000_CS,GPO,LOW); gpio_init(PORTB,LDC1000_DO,GPI,LOW);
/* LDC寄存器初始化 */
LDC1000_write(LDC1000_CMD_RPMAX, RPMAX); LDC1000_write(LDC1000_CMD_RPMIN, RPMIN); LDC1000_write(LDC1000_CMD_SENSORFREQ, 0x94); LDC1000_write(LDC1000_CMD_LDCCONFIG, 0x17); LDC1000_write(LDC1000_CMD_CLKCONFIG, 0x02); LDC1000_write(LDC1000_CMD_INTCONFIG, 0x02);
LDC1000_write(LDC1000_CMD_THRESHILSB, 0x50); LDC1000_write(LDC1000_CMD_THRESHIMSB, 0x14); LDC1000_write(LDC1000_CMD_THRESLOLSB, 0xC0); LDC1000_write(LDC1000_CMD_THRESLOMSB, 0x12);
LDC1000_write(LDC1000_CMD_PWRCONFIG, 0x01);
//read all registers LDC1000_CS_CLR(); Dly_LDC1000CLK();
LDC1000_read(LDC1000_CMD_REVID , orgVal , 12); Dly_LDC1000CLK();LDC1000_CS_SET(); }