Reading and writing to ADS112c04 (24 bit ADC) with Arduino and MATLAB

18 views (last 30 days)
Hello all, (sorry for the long post, I want to provide as much context as possible)
I have been working with a 16 bit ADC (ADS1115) using MATLAB and its plugin for Arduino but I am looking to upgrade to a 24 bit ADC (ADS112c04). I have attached both datasheets as a reference. Programming the ADS1115 is pretty straight forward (referencing page 27 from the ADS1115 datasheet). There are four registers, each with their own address. I am ignoring registers 2 (10) and 3 (11) and leaving them at their default values
Using the I2C protocol I write the appropriate configuration number into the config register and I read data out of the conversion register.
ard = arduino('com3','uno','Libraries','I2C');
ADC = i2cdev(ard,'0x48');
writeRegister(ADC,1,50307,'uint16');
pause(0.05);
data=double(readRegister(ADC,0,'uint16'))*62.5e-6;
Above is the code I used to communicate with the ADS1115. The code makes use of the already defined I2C library included and is pretty short.
I want to upgrade to a better ADC and ran into a few questions when I was reading the datasheet for ADS122 (going to drop the c04 from the name for simplicity). I am referencing page 41 in the ADS122 datasheet. Similar to the ADS1115, the ADS122 has a 4 configuration registers. I initially assumed writing these registers would be exactly the same as the ADS1115, I can use the writeRegister command, and write the appropriate 8 bit number. However, I dont think that's the case?
Page 38 lists some preprogrammed commands which can be sent to the ADS122. The datasheet suggests writing to the config registers using the WREG command.
Page 39 further elaborates on the WREG command. This is where my confusion lies. In the ADS1115 example, when I called the writeRegister command, I had a register address to write to ( writeRegister(ADC,1,50307,'uint16') the second argument). However, when I am tasked with calling the WREG command, I need to write (0100 rrxx #### ####) somewhere, but where?
Also, in the ADS1115 example, I was sending a single 16bit word at a time using the writeRegister command. Now I am tasked with sending two 8bit words, how would go about doing that?
My last set of questions lie in reading the measured data using the RDATA command. Once again, where would I write the RDATA command? Once the new measurment is loaded into the output register, what is it's address as well when i try and call the readRegister command?
Thanks for any and all help
Happy to provide more context

Answers (0)

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!