ESM7000是基于NXP i.MX7D的高性能低功耗工控主板,支持以太网、CAN、串口、USB等丰富的通讯接口。ESM7000提供了RGB和LVDS两种显示接口可选,支持从320x240到1920x1080的显示分辨率,支持电容/电阻触摸屏。
ESM7000还集成了两个ADC单元,每个ADC单元支持4通道的模拟量采集, ADC的基准电压为1.8V,分辨率为14位,输入模拟量信号范围为0~1.8V。通过标定,ESM7000的ADC可实现14位精度的模拟信号采集。基于ESM7000可快速构建通讯接口丰富、人机交互良好、高性价比的数据采集方案。支持AD功能的ESM7000售价保持不变,用户可在英创ESM7000主页查看对应的定货型号和价格。
ESM7000的AD输入引脚与主板的ISA总线引脚是复用的,复用关系如下表所示:
ESM7000引脚E列 | ||
8-bit精简ISA | 8通道ADC接口 | |
E1 | GND电源地 | GND电源地 |
E2 | ISA_D0 | ADC1_CH0 |
E3 | ISA_D1 | ADC1_CH1 |
E4 | ISA_D2 | ADC1_CH2 |
E5 | ISA_D3 | ADC1_CH3 |
E6 | ISA_D4 | ADC2_CH0 |
E7 | ISA_D5 | ADC2_CH1 |
E8 | ISA_D6 | ADC2_CH2 |
E9 | ISA_D7 | ADC2_CH3 |
E10 | ISA_RDn | NC |
E11 | ISA_WEn | NC |
E12 | ISA_ADVn | NC |
E13 | ISA_CSn | NC |
软件操作上,ESM7000的两个ADC对应设备名称为L"ADC1:"和L"ADC2:",通过标准的文件读函数ReadFile就可读取指定通道的ADC转换结果。下面是连续读取ESM7000指定AD通道,并记录最大值、最小值和计算直方图的示例代码。
#define VBASE 1800 // 1800mV #define resolution 0x4000 // 14-bit UINT32 histogram[resolution]; int _tmain(int argc, _TCHAR* argv[]) { HANDLE hADC; DWORD adc_val, inst; DWORD dwMinVal, dwMaxVal, i, times, dwBytesofRead; ADC_INFO adcInfo; TCHAR adcInst[][10]={TEXT("ADC1:"), TEXT("ADC2:")}; // ADC设备名 inst = 0; hADC = CreateFile(adcInst[inst], GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hADC == INVALID_HANDLE_VALUE) { ERRORMSG(1, (_T("Could not retrieve an handle on \r\n"))); return -1; } memset( histogram,0, sizeof(histogram)); dwMinVal = 0xffffffff; dwMaxVal = 0; adcInfo.dwChannels = 1; // ADC通道0~3 adcInfo.pData = &adc_val; // 14位的ADC数据 for(i=0; i<1000; i++) { ReadFile(hADC, &adcInfo, 1, &dwBytesofRead, NULL); dwMinVal = adc_val < dwMinVal ? adc_val : dwMinVal; dwMaxVal = adc_val > dwMaxVal ? adc_val : dwMaxVal; histogram[adc_val]++; } RETAILMSG( 1, (TEXT("----------- Data Analysis-%s-CH%d -----------\r\n"), adcInst[inst], adcInfo.dwChannels)); for( i=0, times=0; i<resolution;i++ ) { if( histogram[i] ) times += histogram[i]; } #ifdef VBASE TCHAR szBuf[100]; for( i=0; i<resolution;i++ ) { if( histogram[i] ) { wsprintf(szBuf, TEXT(" value :%5.2fmv times:%5d %d%%\r\n"), i * (float)VBASE / resolution, histogram[i], histogram[i]*100/times); RETAILMSG( 1, (TEXT(" %s"), szBuf)); } } wsprintf(szBuf, TEXT(" MinVal:%5.2fmv MaxVal:%5.2fmv MaxVal-MinVal:%5.2fmv\r\n"), dwMinVal* (float)VBASE / resolution, dwMaxVal* (float)VBASE / resolution, (dwMaxVal-dwMinVal)* (float)VBASE / resolution); RETAILMSG( 1, (TEXT(" %s"), szBuf)); #else for( i=0; i<resolution;i++ ) { if( histogram[i] ) RETAILMSG( 1, (TEXT(" datas :%5d times:%5d %d%%\r\n"), i, histogram[i], histogram[i]*100/times)); } RETAILMSG( 1, (TEXT(" MinVal:%5d MaxVal:%5d MaxVal-MinVal:%d\r\n"), dwMinVal, dwMaxVal, dwMaxVal-dwMinVal)); #endif RETAILMSG( 1, (TEXT("--------------------- END ---------------------\r\n\r\n"))); CloseHandle(hADC); return 0; }
成都英创信息技术有限公司 028-8618 0660