完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
RDATAC、RESET、SYNC命令之后,需要延迟=3.12uS; 实际测试,在3.3V上电后,及时不做任何配置,ADS125的DRDY口线即开始输出信号(2.6us高,33.4) ,频率30KHz) 3、4WD-L298P驱动板 技术规格: 驱动工作电压:4.8~35V 最大输出电流:单路2A 最大耗散功率:25W(T=75℃) 驱动形式:双路H桥 驱动电源一路外部电源端子/Arduino-VIN 驱动输出接口排:两路电机接线端子/ Arduino控制端口:数字口10,11,12,13 工作温度:-25℃~130℃ 模块尺寸:56x57mm L289P https: //download/download/Rendezvous1/14571 4、稳压源 5、微电机+传感器 结构 软件 1、与读取ADS1256有关的代码已经上传资源 1 ADS1256初始化函数 void bsp_InitADS1256(void) { GPIO_InitTypeDef GPIO_InitStructure; #ifdef SOFT_SPI /* 打开GPIO时钟 */ RCC_APB2PeriphClockCmd(RCC_SCK | RCC_DIN | RCC_DOUT | RCC_CS | RCC_DRDY, ENABLE); /* 配置几个推完输出IO */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /* 设为推挽输出口 */ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /* IO口最大速度 */ GPIO_InitStructure.GPIO_Pin = PIN_SCK; GPIO_Init(PORT_SCK, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = PIN_DIN; GPIO_Init(PORT_DIN, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = PIN_CS; GPIO_Init(PORT_CS, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = PIN_SYNC; GPIO_Init(PORT_SYNC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = PIN_RST; GPIO_Init(PORT_RST, &GPIO_InitStructure); /* 配置GPIO为浮动输入模式(实际上CPU复位后就是输入状态) */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin = PIN_DOUT; GPIO_Init(PORT_DOUT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = PIN_DRDY; GPIO_Init(PORT_DRDY, &GPIO_InitStructure); RST_0(); delay_ms(1); SYNC_1(); RST_1(); delay_ms(100); // CS_1(); SCK_0(); /* SPI总线空闲时,钟线是低电平 */ DI_1(); #endif //ADS1256_CfgADC(ADS1256_GAIN_1, ADS1256_1000SPS); /* 配置ADC参数: 增益1:1, 数据输出速率 1KHz */ } 配置ADC参数,增益和数据输出速率的函数 void ADS1256_CfgADC(ADS1256_GAIN_E _gain, ADS1256_DRATE_E _drate) { g_tADS1256.Gain = _gain; g_tADS1256.DataRate = _drate; ADS1256_StopScan(); /* 暂停CPU中断 */ ADS1256_ResetHard(); /* 硬件复位 */ ADS1256_WaitDRDY(); { uint8_t buf[4]; /* 暂存ADS1256 寄存器配置参数,之后连续写4个寄存器 */ /* 状态寄存器定义 Bits 7-4 ID3, ID2, ID1, ID0 Factory Programmed Identification Bits (Read Only) Bit 3 ORDER: Data Output Bit Order 0 = Most Significant Bit First (default) 1 = Least Significant Bit First Input data is always shifted in most significant byte and bit first. Output data is always shifted out most significant byte first. The ORDER bit only controls the bit order of the output data within the byte. Bit 2 ACAL : Auto-Calibration 0 = Auto-Calibration Disabled (default) 1 = Auto-Calibration Enabled When Auto-Calibration is enabled, self-calibration begins at the completion of the WREG command that changes the PGA (bits 0-2 of ADCON register), DR (bits 7-0 in the DRATE register) or BUFEN (bit 1 in the STATUS register) values. Bit 1 BUFEN: Analog Input Buffer Enable 0 = Buffer Disabled (default) 1 = Buffer Enabled Bit 0 DRDY : Data Ready (Read Only) This bit duplicates the state of the DRDY pin. ACAL=1使能自校准功能。当 PGA,BUFEEN, DRATE改变时会启动自校准 */ buf[0] = (0 << 3) | (1 << 2) | (1 << 1); //ADS1256_WriteReg(REG_STATUS, (0 << 3) | (1 << 2) | (1 << 1)); buf[1] = 0x08; /* 高四位0表示AINP接 AIN0, 低四位8表示 AINN 固定接 AINCOM */ /* ADCON: A/D Control Register (Address 02h) Bit 7 Reserved, always 0 (Read Only) Bits 6-5 CLK1, CLK0 : D0/CLKOUT Clock Out Rate Setting 00 = Clock Out OFF 01 = Clock Out Frequency = fCLKIN (default) 10 = Clock Out Frequency = fCLKIN/2 11 = Clock Out Frequency = fCLKIN/4 When not using CLKOUT, it is recommended that it be turned off. These bits can only be reset using the RESET pin. Bits 4-2 SDCS1, SCDS0: Sensor Detect Current Sources 00 = Sensor Detect OFF (default) 01 = Sensor Detect Current = 0.5 μ A 10 = Sensor Detect Current = 2 μ A 11 = Sensor Detect Current = 10μ A The Sensor Detect Current Sources can be activated to verify the integrity of an external sensor supplying a signal to the ADS1255/6. A shorted sensor produces a very small signal while an open-circuit sensor produces a very large signal. Bits 2-0 PGA2, PGA1, PGA0: Programmable Gain Amplifier Setting 000 = 1 (default) 001 = 2 010 = 4 011 = 8 100 = 16 101 = 32 110 = 64 111 = 64 */ buf[2] = (0 << 5) | (0 << 3) | (_gain << 0); //ADS1256_WriteReg(REG_ADCON, (0 << 5) | (0 << 2) | (GAIN_1 << 0)); /* 选择1;1增益, 输入正负5V */ /* 因为切换通道和读数据耗时 123uS, 因此扫描中断模式工作时,最大速率 = DRATE_1000SPS */ buf[3] = s_tabDataRate[_drate]; // DRATE_10SPS; /* 选择数据输出速率 */ CS_0(); /* SPI片选 = 0 */ ADS1256_Send8Bit(CMD_WREG | 0); /* 写寄存器的命令, 并发送寄存器地址 */ ADS1256_Send8Bit(0x03); /* 寄存器个数 - 1, 此处3表示写4个寄存器 */ ADS1256_Send8Bit(buf[0]); /* 设置状态寄存器 */ ADS1256_Send8Bit(buf[1]); /* 设置输入通道参数 */ ADS1256_Send8Bit(buf[2]); /* 设置ADCON控制寄存器,增益 */ ADS1256_Send8Bit(buf[3]); /* 设置输出数据速率 */ CS_1(); /* SPI片选 = 1 */ } bsp_DelayUS(50); } RESET函数 static void ADS1256_ResetHard(void) { /* ADS1256数据手册第7页 */ //RESET_0(); /* 复位 */ //bsp_DelayUS(5); //RESET_1(); //PWDN_0(); /* 进入掉电 同步*/ //bsp_DelayUS(2); //PWDN_1(); /* 退出掉电 */ bsp_DelayUS(5); //ADS1256_WaitDRDY(); /* 等待 DRDY变为0, 此过程实测: 630us */ } SEND函数 static void ADS1256_Send8Bit(uint8_t _data) { uint8_t i; /* 连续发送多个字节时,需要延迟一下 */ ADS1256_DelaySCLK(); ADS1256_DelaySCLK(); /* ADS1256 要求 SCL高电平和低电平持续时间最小 200ns */ for(i = 0; i < 8; i++) { if (_data & 0x80) { DI_1(); } else { DI_0(); } SCK_1(); ADS1256_DelaySCLK(); _data <<= 1; SCK_0(); /* <---- ADS1256 是在SCK下降沿采样DIN数据, 数据必须维持 50nS */ ADS1256_DelaySCLK(); } } RECEIVE函数 static uint8_t ADS1256_Recive8Bit(void) { uint8_t i; uint8_t read = 0; ADS1256_DelaySCLK(); /* ADS1256 要求 SCL高电平和低电平持续时间最小 200ns */ for (i = 0; i < 8; i++) { SCK_1(); ADS1256_DelaySCLK(); read = read<<1; SCK_0(); if (DO_IS_HIGH()) { read++; } ADS1256_DelaySCLK(); } return read; } 太多了,现将ADS1256相关的资料打包上传资源。自取。https://download.csdn.net/download/Rendezvous1/14945861 2、PID闭环控制可以控制电机正反转,及速度。 资源已上传自取 1 3、还可以增加通信模块,以发送让电机运动的指令。 |
|
|
|
只有小组成员才能发言,加入小组>>
2434 浏览 0 评论
9096 浏览 4 评论
36765 浏览 19 评论
5025 浏览 0 评论
24737 浏览 34 评论
1526浏览 2评论
1741浏览 1评论
2191浏览 1评论
1551浏览 0评论
522浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 09:56 , Processed in 1.134605 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号