Communicating to MCP3426 ADC chip using I2C and Arduino





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I am trying to communicate to a MCP3426 ADC chip attached to an arduino shield using the I2C serial protocol and with little experience in...well anything there are quite a bunch of questions I have. First let me explain the system.



Currently, I have the MCP3426A1-E-S/N chip (datasheet found here: https://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf) attached to a PCB that is connected to an arduino UNO using header pins. Vdd and Vss are connected to the 5V arduino power supply and GND respectively. Only one channel is being used with the positive input connected to an MCP4725 DAC and the negative input connected to a 2.5V reference voltage. Right now, I am simply trying to see if I can read a signal from the ADC without necessarily sending a signal through the DAC. This is the code I have written:



#include <Wire.h>

void setup(void) {
Serial.begin(9600);
Wire.begin();
}

void loop(void) {
int adcValueRead = 0;
int adcValueRead1 =0;
int adcValueRead2=0;

//address of MCP3426A1-E/SN corresponding to 0b1101010
Wire.beginTransmission(0x6A);

//configuration register corresponding to 0b10001000 which is a one-shot
//conversion in channel 1 and a 16 bit resolution
Wire.write(0x88);

delay(500);

//requestion 3 bytes from the MCP3426 address
Wire.requestFrom(0x6A, 3);
adcValueRead= Wire.read();
adcValueRead1=Wire.read();
adcValueRead2=Wire.read();


Serial.print("tADC Value: ");
Serial.print(adcValueRead);
Serial.print(" ");
Serial.print(adcValueRead1);
Serial.print(" ");
Serial.print(adcValueRead2);

Serial.print('n');

}


When I open the serial monitor the value that I get is:



ADC Value 0 21 16


So I have several questions, first of which being whether I correctly interpreted the datasheet and 0x6A is in fact the address and 0x88 is the correct configuration register for what I want. The relevant parts of the datasheet I believe can be found here:



address byte(datasheet pg. 20) and configuration resgister (datasheet pg. 18)



Now if I am interpreting the datasheet correctly, after the conversion I should be expecting three 8 bit bytes, with the first two being the voltage value in 16 bits and the third byte being the configuration register. So knowing that, I would expect my program to return



ADC Value 128 0 136


The reason I believe this is because the voltage difference between the two inputs should be 2.5V (since I'm not sending anything through the DAC) which, being half of 5V, should correspond to a 16 bit byte of 1000000000000000 and the third byte should be the same configuration register I sent originally. That, of course, is not what I got and I'm not sure why.



As you can probably tell, there are some pretty basic fundamental stuff I don't really understand and I am just trying to interpret the datasheet as correctly as I can. So is my interpretation of the system correct and is there something wrong with my code/connections or is my interpretation of the system incorrect and I should in fact be expecting "0 21 16" as my ADC values. Please let me know if there is any other information that needs to be known but any help in letting me understand my system would be greatly appreciated.










share|improve this question























  • You are using the MCP3426, with a fixed I2C address - I can't see in the datasheet where it specifies the fixed address?

    – jfowkes
    Nov 26 '18 at 11:14











  • Ah, based on this answer on the microchip forums:microchip.com/forums/m643488.aspx, you should be using address 0xD0 for the device. Try that and see what you get.

    – jfowkes
    Nov 26 '18 at 11:19













  • I tried that address and it still gives me the same output ): Ah well, gotta keep trying I guess.

    – lwang94
    Nov 26 '18 at 17:15


















1















I am trying to communicate to a MCP3426 ADC chip attached to an arduino shield using the I2C serial protocol and with little experience in...well anything there are quite a bunch of questions I have. First let me explain the system.



Currently, I have the MCP3426A1-E-S/N chip (datasheet found here: https://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf) attached to a PCB that is connected to an arduino UNO using header pins. Vdd and Vss are connected to the 5V arduino power supply and GND respectively. Only one channel is being used with the positive input connected to an MCP4725 DAC and the negative input connected to a 2.5V reference voltage. Right now, I am simply trying to see if I can read a signal from the ADC without necessarily sending a signal through the DAC. This is the code I have written:



#include <Wire.h>

void setup(void) {
Serial.begin(9600);
Wire.begin();
}

void loop(void) {
int adcValueRead = 0;
int adcValueRead1 =0;
int adcValueRead2=0;

//address of MCP3426A1-E/SN corresponding to 0b1101010
Wire.beginTransmission(0x6A);

//configuration register corresponding to 0b10001000 which is a one-shot
//conversion in channel 1 and a 16 bit resolution
Wire.write(0x88);

delay(500);

//requestion 3 bytes from the MCP3426 address
Wire.requestFrom(0x6A, 3);
adcValueRead= Wire.read();
adcValueRead1=Wire.read();
adcValueRead2=Wire.read();


Serial.print("tADC Value: ");
Serial.print(adcValueRead);
Serial.print(" ");
Serial.print(adcValueRead1);
Serial.print(" ");
Serial.print(adcValueRead2);

Serial.print('n');

}


When I open the serial monitor the value that I get is:



ADC Value 0 21 16


So I have several questions, first of which being whether I correctly interpreted the datasheet and 0x6A is in fact the address and 0x88 is the correct configuration register for what I want. The relevant parts of the datasheet I believe can be found here:



address byte(datasheet pg. 20) and configuration resgister (datasheet pg. 18)



Now if I am interpreting the datasheet correctly, after the conversion I should be expecting three 8 bit bytes, with the first two being the voltage value in 16 bits and the third byte being the configuration register. So knowing that, I would expect my program to return



ADC Value 128 0 136


The reason I believe this is because the voltage difference between the two inputs should be 2.5V (since I'm not sending anything through the DAC) which, being half of 5V, should correspond to a 16 bit byte of 1000000000000000 and the third byte should be the same configuration register I sent originally. That, of course, is not what I got and I'm not sure why.



As you can probably tell, there are some pretty basic fundamental stuff I don't really understand and I am just trying to interpret the datasheet as correctly as I can. So is my interpretation of the system correct and is there something wrong with my code/connections or is my interpretation of the system incorrect and I should in fact be expecting "0 21 16" as my ADC values. Please let me know if there is any other information that needs to be known but any help in letting me understand my system would be greatly appreciated.










share|improve this question























  • You are using the MCP3426, with a fixed I2C address - I can't see in the datasheet where it specifies the fixed address?

    – jfowkes
    Nov 26 '18 at 11:14











  • Ah, based on this answer on the microchip forums:microchip.com/forums/m643488.aspx, you should be using address 0xD0 for the device. Try that and see what you get.

    – jfowkes
    Nov 26 '18 at 11:19













  • I tried that address and it still gives me the same output ): Ah well, gotta keep trying I guess.

    – lwang94
    Nov 26 '18 at 17:15














1












1








1








I am trying to communicate to a MCP3426 ADC chip attached to an arduino shield using the I2C serial protocol and with little experience in...well anything there are quite a bunch of questions I have. First let me explain the system.



Currently, I have the MCP3426A1-E-S/N chip (datasheet found here: https://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf) attached to a PCB that is connected to an arduino UNO using header pins. Vdd and Vss are connected to the 5V arduino power supply and GND respectively. Only one channel is being used with the positive input connected to an MCP4725 DAC and the negative input connected to a 2.5V reference voltage. Right now, I am simply trying to see if I can read a signal from the ADC without necessarily sending a signal through the DAC. This is the code I have written:



#include <Wire.h>

void setup(void) {
Serial.begin(9600);
Wire.begin();
}

void loop(void) {
int adcValueRead = 0;
int adcValueRead1 =0;
int adcValueRead2=0;

//address of MCP3426A1-E/SN corresponding to 0b1101010
Wire.beginTransmission(0x6A);

//configuration register corresponding to 0b10001000 which is a one-shot
//conversion in channel 1 and a 16 bit resolution
Wire.write(0x88);

delay(500);

//requestion 3 bytes from the MCP3426 address
Wire.requestFrom(0x6A, 3);
adcValueRead= Wire.read();
adcValueRead1=Wire.read();
adcValueRead2=Wire.read();


Serial.print("tADC Value: ");
Serial.print(adcValueRead);
Serial.print(" ");
Serial.print(adcValueRead1);
Serial.print(" ");
Serial.print(adcValueRead2);

Serial.print('n');

}


When I open the serial monitor the value that I get is:



ADC Value 0 21 16


So I have several questions, first of which being whether I correctly interpreted the datasheet and 0x6A is in fact the address and 0x88 is the correct configuration register for what I want. The relevant parts of the datasheet I believe can be found here:



address byte(datasheet pg. 20) and configuration resgister (datasheet pg. 18)



Now if I am interpreting the datasheet correctly, after the conversion I should be expecting three 8 bit bytes, with the first two being the voltage value in 16 bits and the third byte being the configuration register. So knowing that, I would expect my program to return



ADC Value 128 0 136


The reason I believe this is because the voltage difference between the two inputs should be 2.5V (since I'm not sending anything through the DAC) which, being half of 5V, should correspond to a 16 bit byte of 1000000000000000 and the third byte should be the same configuration register I sent originally. That, of course, is not what I got and I'm not sure why.



As you can probably tell, there are some pretty basic fundamental stuff I don't really understand and I am just trying to interpret the datasheet as correctly as I can. So is my interpretation of the system correct and is there something wrong with my code/connections or is my interpretation of the system incorrect and I should in fact be expecting "0 21 16" as my ADC values. Please let me know if there is any other information that needs to be known but any help in letting me understand my system would be greatly appreciated.










share|improve this question














I am trying to communicate to a MCP3426 ADC chip attached to an arduino shield using the I2C serial protocol and with little experience in...well anything there are quite a bunch of questions I have. First let me explain the system.



Currently, I have the MCP3426A1-E-S/N chip (datasheet found here: https://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf) attached to a PCB that is connected to an arduino UNO using header pins. Vdd and Vss are connected to the 5V arduino power supply and GND respectively. Only one channel is being used with the positive input connected to an MCP4725 DAC and the negative input connected to a 2.5V reference voltage. Right now, I am simply trying to see if I can read a signal from the ADC without necessarily sending a signal through the DAC. This is the code I have written:



#include <Wire.h>

void setup(void) {
Serial.begin(9600);
Wire.begin();
}

void loop(void) {
int adcValueRead = 0;
int adcValueRead1 =0;
int adcValueRead2=0;

//address of MCP3426A1-E/SN corresponding to 0b1101010
Wire.beginTransmission(0x6A);

//configuration register corresponding to 0b10001000 which is a one-shot
//conversion in channel 1 and a 16 bit resolution
Wire.write(0x88);

delay(500);

//requestion 3 bytes from the MCP3426 address
Wire.requestFrom(0x6A, 3);
adcValueRead= Wire.read();
adcValueRead1=Wire.read();
adcValueRead2=Wire.read();


Serial.print("tADC Value: ");
Serial.print(adcValueRead);
Serial.print(" ");
Serial.print(adcValueRead1);
Serial.print(" ");
Serial.print(adcValueRead2);

Serial.print('n');

}


When I open the serial monitor the value that I get is:



ADC Value 0 21 16


So I have several questions, first of which being whether I correctly interpreted the datasheet and 0x6A is in fact the address and 0x88 is the correct configuration register for what I want. The relevant parts of the datasheet I believe can be found here:



address byte(datasheet pg. 20) and configuration resgister (datasheet pg. 18)



Now if I am interpreting the datasheet correctly, after the conversion I should be expecting three 8 bit bytes, with the first two being the voltage value in 16 bits and the third byte being the configuration register. So knowing that, I would expect my program to return



ADC Value 128 0 136


The reason I believe this is because the voltage difference between the two inputs should be 2.5V (since I'm not sending anything through the DAC) which, being half of 5V, should correspond to a 16 bit byte of 1000000000000000 and the third byte should be the same configuration register I sent originally. That, of course, is not what I got and I'm not sure why.



As you can probably tell, there are some pretty basic fundamental stuff I don't really understand and I am just trying to interpret the datasheet as correctly as I can. So is my interpretation of the system correct and is there something wrong with my code/connections or is my interpretation of the system incorrect and I should in fact be expecting "0 21 16" as my ADC values. Please let me know if there is any other information that needs to be known but any help in letting me understand my system would be greatly appreciated.







arduino i2c






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 20:25









lwang94lwang94

112




112













  • You are using the MCP3426, with a fixed I2C address - I can't see in the datasheet where it specifies the fixed address?

    – jfowkes
    Nov 26 '18 at 11:14











  • Ah, based on this answer on the microchip forums:microchip.com/forums/m643488.aspx, you should be using address 0xD0 for the device. Try that and see what you get.

    – jfowkes
    Nov 26 '18 at 11:19













  • I tried that address and it still gives me the same output ): Ah well, gotta keep trying I guess.

    – lwang94
    Nov 26 '18 at 17:15



















  • You are using the MCP3426, with a fixed I2C address - I can't see in the datasheet where it specifies the fixed address?

    – jfowkes
    Nov 26 '18 at 11:14











  • Ah, based on this answer on the microchip forums:microchip.com/forums/m643488.aspx, you should be using address 0xD0 for the device. Try that and see what you get.

    – jfowkes
    Nov 26 '18 at 11:19













  • I tried that address and it still gives me the same output ): Ah well, gotta keep trying I guess.

    – lwang94
    Nov 26 '18 at 17:15

















You are using the MCP3426, with a fixed I2C address - I can't see in the datasheet where it specifies the fixed address?

– jfowkes
Nov 26 '18 at 11:14





You are using the MCP3426, with a fixed I2C address - I can't see in the datasheet where it specifies the fixed address?

– jfowkes
Nov 26 '18 at 11:14













Ah, based on this answer on the microchip forums:microchip.com/forums/m643488.aspx, you should be using address 0xD0 for the device. Try that and see what you get.

– jfowkes
Nov 26 '18 at 11:19







Ah, based on this answer on the microchip forums:microchip.com/forums/m643488.aspx, you should be using address 0xD0 for the device. Try that and see what you get.

– jfowkes
Nov 26 '18 at 11:19















I tried that address and it still gives me the same output ): Ah well, gotta keep trying I guess.

– lwang94
Nov 26 '18 at 17:15





I tried that address and it still gives me the same output ): Ah well, gotta keep trying I guess.

– lwang94
Nov 26 '18 at 17:15












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462065%2fcommunicating-to-mcp3426-adc-chip-using-i2c-and-arduino%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462065%2fcommunicating-to-mcp3426-adc-chip-using-i2c-and-arduino%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings