本文摘自先楫開發(fā)者@xiashuang的測評內(nèi)容,分享了先楫HPM6750 如何賦能 ADS1263 實現(xiàn)32位高精度數(shù)據(jù)采集及處理 ,來看看吧
--------------- 以下為測評內(nèi)容---------------
(本期測評開發(fā)板為 HPM6750EVK)
據(jù)官方用戶手冊, TI 的32位ADC:ADS1263 性能很強,最高采樣到38.4k(26us),需要的處理器性能必須要具有很強的運算功能,正好試下HPM6750,于是畫了一塊PCB板,經(jīng)過一周的等待終于到了,焊接了必要的元件就開干!
為了先驗證板子的情況,先用軟件模擬 SPI 進行實驗,需要 7 根信號線進行連接通訊,定義的GPIO如下:
*RST---------PE25
*DRDY--------PE26
*MISO--------SPI2.MISO PB25
*MOSI--------SPI2.MOSI PB22
*SCK---------SPI2.SCK PB21
*CS----------PF1
*START-------PF4
先初始化IO口,時鐘的開啟已經(jīng)在board_init()中完成,所以指示配置一下寄存器就行
/*設(shè)置IO口為通用IO*/
HPM_IOC->PAD[IOC_PAD_PE25].FUNC_CTL = IOC_PE25_FUNC_CTL_GPIO_E_25;
HPM_IOC->PAD[IOC_PAD_PE26].FUNC_CTL = IOC_PE26_FUNC_CTL_GPIO_E_26;
HPM_IOC->PAD[IOC_PAD_PB25].FUNC_CTL = IOC_PB25_FUNC_CTL_GPIO_B_25;
HPM_IOC->PAD[IOC_PAD_PB22].FUNC_CTL = IOC_PB22_FUNC_CTL_GPIO_B_22;
HPM_IOC->PAD[IOC_PAD_PB21].FUNC_CTL = IOC_PB21_FUNC_CTL_GPIO_B_21;
HPM_IOC->PAD[IOC_PAD_PF01].FUNC_CTL = IOC_PF01_FUNC_CTL_GPIO_F_01;
HPM_IOC->PAD[IOC_PAD_PF04].FUNC_CTL = IOC_PF04_FUNC_CTL_GPIO_F_04;
/*配置輸入輸出*/
/*ps-上下拉電阻 PE-上下拉開關(guān) SMT-施密特 DS-驅(qū)動強度 OD-開漏 MS-電壓選擇*/
uint32_t pad_ctl_out = IOC_PAD_PAD_CTL_PE_SET(1) | IOC_PAD_PAD_CTL_PS_SET(1);
uint32_t pad_ctl_in = IOC_PAD_PAD_CTL_PE_SET(1) | IOC_PAD_PAD_CTL_PS_SET(1)|IOC_PAD_PAD_CTL_SMT_SET(1);
gpio_set_pin_output_with_initial(HPM_GPIO0, GPIO_DO_GPIOE, 25, 1);
gpio_set_pin_output_with_initial(HPM_GPIO0, GPIO_DO_GPIOB, 22, 1);
gpio_set_pin_output_with_initial(HPM_GPIO0, GPIO_DO_GPIOB, 21, 1);
gpio_set_pin_output_with_initial(HPM_GPIO0, GPIO_DO_GPIOF, 01, 1);
gpio_set_pin_output_with_initial(HPM_GPIO0, GPIO_DO_GPIOF, 04, 1);
HPM_IOC->PAD[IOC_PAD_PE25].PAD_CTL = pad_ctl_out;
HPM_IOC->PAD[IOC_PAD_PB22].PAD_CTL = pad_ctl_out;
HPM_IOC->PAD[IOC_PAD_PB21].PAD_CTL = pad_ctl_out;
HPM_IOC->PAD[IOC_PAD_PF01].PAD_CTL = pad_ctl_out;
HPM_IOC->PAD[IOC_PAD_PF04].PAD_CTL = pad_ctl_out;
HPM_IOC->PAD[IOC_PAD_PE26].PAD_CTL = pad_ctl_in;
HPM_IOC->PAD[IOC_PAD_PB25].PAD_CTL = pad_ctl_in;
相應(yīng)的IO輸出及輸入讀取如下:
#define ADS1263_RESET_H gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOE, 25, 1)
#define ADS1263_RESET_L gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOE, 25, 0)
#define ADS1263_START_H gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOF, 4, 1)
#define ADS1263_START_L gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOF, 4, 0)
#define ADS1263_CS_H gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOF, 1, 1)
#define ADS1263_CS_L gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOF, 1, 0)
#define ADS1263_SCLK_H gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOB, 21, 1)
#define ADS1263_SCLK_L gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOB, 21, 0)
#define ADS1263_DIN_H gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOB, 22, 1)
#define ADS1263_DIN_L gpio_write_pin(HPM_GPIO0, GPIO_DO_GPIOB, 22, 0)
#define ADS1263_DOUT gpio_read_pin(HPM_GPIO0, GPIO_DI_GPIOB, 25)
#define ADS1263_DRDY gpio_read_pin(HPM_GPIO0, GPIO_DI_GPIOE, 26)
初始化ADS1263
int init_ads1263(void)
{
printf("*************************************************************\r\n");
printf("* *\r\n");
printf("* ADS1263 TEST ^_^ *\r\n");
printf("* *\r\n");
printf("*************************************************************\r\n");
GPIO_Configuration();
ADS1263_INIT();//ADS1263初始化
ADS1263_CS_L;
Delay(0xf);
ADS1263_WRITE(0x08);//START1 command,當(dāng)START引腳為低電平時,可由此命令啟動ADC1的轉(zhuǎn)換。
ADS1263_CS_H;
Delay(0xf);
return 0;
}
讀取AD值
int read_ads1263(void)
{
if(ADS1263_DRDY != 1)
{
ADS1263_CS_L;
Delay(0xf);
ADS1263_WRITE(0x12);//讀取ADC1
STATUS=ADS1263_READ_REG();
ADC1_DATA=ADS1263_READ();
checksum = ADS1263_READ_REG();
ADS1263_CS_H;
count++;
D[47]++;
if(D[76] > 0)
{
ADC1_DATA = Filter_ch1(ADC1_DATA,D[76],D[77]);
}
ADC1_DATA = CELL_ADSOURSE_FILTER(ADC1_DATA,D[78],D[79]);
mv_Now = ADC1_DATA / 2147483648.0 * 2500 / 32;//mv數(shù)
//測試重量參數(shù)
Weight = (mv_Now - mv_Zero)/ 10.0f * mv_Full * mv_Cali;
INT32toREG(ADC1_DATA,&D[0]);//源碼
FP32toREG(mv_Now,&D[2]);//mv數(shù)
FP32toREG(Weight,&D[4]);//重量
//校秤參數(shù)
mv_Zero = REGtoFP32(&D[70]);//mv零點
mv_Full = REGtoFP32(&D[72]);//滿量程
mv_Cali = REGtoFP32(&D[74]);//校準(zhǔn)系數(shù)
return ADC1_DATA;
}
else
return 0;
}
利用上次移植的modbus 裸機例子,在主循環(huán)中不斷查詢AD狀態(tài)讀取。
連接好線,接上稱重傳感器開始測試
MODBUS上位機畫面,使用50kg C3電阻應(yīng)變橋式稱重傳感器采樣400次精度在±1g,后來降低采樣到60次/s,滑動平均5次,精度在±0.2g 。
邏輯分析儀抓取波形圖。采用軟件模擬SPI,速度在3M左右,讀取命令+狀態(tài)+4字節(jié)數(shù)據(jù)+校驗共7個字節(jié)數(shù)據(jù)在20.5us左右
【實驗總結(jié)】
HPM6750 在配置IO時要注意名稱,因為IO引腳較多,宏定義也比較多,在初始化容易寫錯(這次因為IO編號寫錯導(dǎo)致兩個IO口沒有輸出,查了1個多小時)??磥韴D形化代碼工具還是很有必要的(*悄咪咪告訴你們,先楫圖形化代碼工具已經(jīng)上線使用中啦);
HPM6750 的驅(qū)動強度和施密特單獨出來和I.MX RT系列比較像增加了IO控制的靈活性,PCB上高速信號的抗信號反射電阻和驅(qū)動限流電阻都可以省去了,等以后試下芯片的施密特能否代替外部輸入上的 74HC14;
HPM6750 運算速度很快,等以后試試高階FIR看看;
ADS1263 的高速采樣及其以來模擬電源的紋波,對內(nèi)部DCDC電源還是要增加濾波器,采樣60HZ對50-hz和60hz紋波抑制后精度一下就上來了;
--------------- 以上為全部測評內(nèi)容---------------
本期的測評分享就到這里,若想獲取更多關(guān)于HPM6750的精彩內(nèi)容,可點擊下面 “ 閱讀原文 ”了解詳情哦~
-
開發(fā)板
+關(guān)注
關(guān)注
25文章
4896瀏覽量
97058
發(fā)布評論請先 登錄
相關(guān)推薦
評論