Hello,
I have problems with the I2C communication to an ADS7828 AD converter.
I don't get any value back from the chip.
I use a Kontron chip (ARM 32SC) with Linux as the operating system.
I also use the CmpCharDevice library.
ADS7828 parameters
Address: A1 = 0 / A0 = 0 =
SD = 1 = Single End
C2 = 0 / C1= 0 / C0= 0 / Channel 0
PD1 = Internal Reference and PD0 = AD Converter ON
Here is my code:
VARb_i2cAdr:BYTE:=16#48;(*StandardI2C-AdressedesADS7828*)x_Init:BOOL;(*FlagfürdieInitialisierung*)b_config_byte:BYTE;(*KonfigurationsbytefürdenADS7828*)ab_cmd_buffer:ARRAY[0..0]OFBYTE;(*BufferfürdenBefehl*)ab_data_buffer:ARRAY[0..1]OFBYTE;(*BufferfürdieempfangenenDaten*)ui_adc_value_1:UINT;(*AusgelesenerADC-Wert*)I2C_Handle:RTS_IEC_HANDLE;(*HandlefürdasI2C-Device*)di_result_open:DINT;(*ErgebnisderFunktionsaufrufe*)di_result_adr:DINT;(*ErgebnisderFunktionsaufrufe*)di_result_wr_cmd:DINT;(*ErgebnisderFunktionsaufrufe*)di_result_rd_cmd:DINT;(*ErgebnisderFunktionsaufrufe*)di_result_close:DINT;(*ErgebnisderFunktionsaufrufe*)END_VAR//*** Init from the I2C communication port ***IFNOTx_InitTHENI2C_Handle:=CDOpen(szFile:='/dev/i2c-0',dFlags:=O_RDWR,pResult:=ADR(di_result_open));//* I2C opening *//*** set of the I2C address ***CDIoctl(hFile:=I2C_Handle,dRequest:=1795,dParameter:=b_i2cAdr,pResult:=ADR(di_result_adr));x_Init:=TRUE;END_IF(*Hauptlogik*)IFI2C_Handle<>0THEN(*Konfigurationsbytesetzen:Single-EndedKanal0,interneReferenz*)b_config_byte:=16#8C;(*10001100b:AIN0,interneReferenz,Single-Ended*)ab_cmd_buffer[0]:=b_config_byte;(*SchreiboperationzumKonfigurierendesChips*)CDWrite(hFile:=I2C_Handle,pbyBuffer:=ADR(ab_cmd_buffer),udCount:=SIZEOF(ab_cmd_buffer),pResult:=ADR(di_result_wr_cmd));IFdi_result_wr_cmd=0THEN(*Leseoperation,umdenADC-Wertzuerhalten*)CDRead(hFile:=I2C_Handle,pbyBuffer:=ADR(ab_data_buffer),udCount:=SIZEOF(ab_data_buffer),pResult:=ADR(di_result_rd_cmd));IFdi_result_rd_cmd=0THEN(*ADC-WertausdenDatenextrahieren*)ui_adc_value_1:=SHL(TO_UINT(ab_data_buffer[0]),8)ORTO_UINT(ab_data_buffer[1]);ELSE(*FehlerbeimLesenderDaten*)ui_adc_value_1:=0;(*ADC-Wertauf0setzen*)END_IFELSE(*FehlerbeimSchreibenderKonfiguration*)ui_adc_value_1:=0;END_IFEND_IF
Last edit: GordiTron 6 days ago
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have problems with the I2C communication to an ADS7828 AD converter.
I don't get any value back from the chip.
I use a Kontron chip (ARM 32SC) with Linux as the operating system.
I also use the CmpCharDevice library.
ADS7828 parameters
Address: A1 = 0 / A0 = 0 =
SD = 1 = Single End
C2 = 0 / C1= 0 / C0= 0 / Channel 0
PD1 = Internal Reference and PD0 = AD Converter ON
Here is my code:
Last edit: GordiTron 6 days ago