Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mcp 3462 with Arduino Zero definition-question not issue! #16

Open
beyondblood opened this issue Apr 18, 2024 · 6 comments
Open

mcp 3462 with Arduino Zero definition-question not issue! #16

beyondblood opened this issue Apr 18, 2024 · 6 comments

Comments

@beyondblood
Copy link

Not really an issue, more of a question so apologies...

I'm attempting to read from channel 0 in mux mode but having issues even entering the setup and loop sections. I'm assuming it's something to do with my mcp definition since I've tested the println function and it seems to work. I'm using an Arduino Zero which is SAMD21. I added a lot of print statements to try and figure out where the program is/isn't making it to. If I go by these statements, the setup and loop aren't being read. Assuming that I've done something really dumb since I'm quite new to this.

MCP3462 mcp(10); //the problem?

void setup() {
Serial.begin(115200);
while (!Serial)
;
Serial.println(FILE);
if (!mcp.begin()) {
Serial.println("failed to initialize MCP");
while (1)
;
}
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on default analog channel:
int32_t adcdata = mcp.analogRead(MCP_CH0);

// Convert the analog reading
double voltage = adcdata * mcp.getReference() / mcp.getMaxValue();
Serial.println("converted voltage");

// print out the value you read:
Serial.println("voltage: ");
Serial.print(voltage, 10);
Serial.println("printed voltage");

// pause program for one second
delay(1000);
}

@nerdyscout
Copy link
Owner

do you use a pullup resistor at pin /IRQ ?

@beyondblood
Copy link
Author

Yes, I've got a pullup at IRQ going to 3.3V. I was thinking maybe my problem was with settings as I have the master clock floating as I wanted to use the internal clock. Attached is pic of my hardware config. Thanks again!

MCP3462_Schematic

@nerdyscout
Copy link
Owner

he pull-up value can be equal to 100-200k for a weak pull-up using the typical clock frequency datasheet, page 31

beside that I am relatively sure your problem is because of my code... sorry. which exact commit are you on?

does your code still freeze if you remove int32_t adcdata = mcp.analogRead(MCP_CH0); ??

if so: there is a while loop inside which is not working, I have seen other people fail here

    while (!_status.dr) {
      _status = read(&adcdata);
    }

please read #5 (comment) there this issue was already discussed.

@beyondblood
Copy link
Author

Hi and thanks for responding! I've changed out my resistor for a 100k, so thank you for that catch. When I comment out int32_t adcdata = mcp.analogRead(MCP_CH0); the loop starts printing/working again, which is strange. I'm new to all this so I've downloaded the files from the 'examples' section and the main files, not sure which commit. I'm thinking it's something to do with my definition MCP3462 mcp(10);

@nerdyscout
Copy link
Owner

as just proven the definition of mcp() is fine, problem is the readAnalog() function.
I am sorry but I can not give any further support.

@beyondblood
Copy link
Author

no worries! Thank you for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants