Other Parts Discussed in Thread: ADS1115,
Hello. I am having trouble with the ADC module that we made using the ADS112C04 chip. Attached is the schematic and PCB design of the said module. It is inspired from the ADS1115 module with the addition of diodes to prevent the input voltage from going beyond the limits (-0.3v and 5.3v).
The module was able to communicate with the microcontroller (ESP32 module) as validated through running Wire.beginTransmission(address). However, as added more commands (ie reset, start, rreg and wreg), the IC begins to not work properly and would eventually smoke. Attached is the code used. The target is to perform continuous conversion at 2ksps using the internal reference voltage.
#include <Wire.h> int address=0x40; int decimalResolution=6; int interruptPin = 36; int initialTime=0; int nowTime=0; volatile bool rdy=false; void setup() { Serial.begin(115200); pinMode(interruptPin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(interruptPin), adsReady, FALLING); Wire.begin(); if(ADS_begin()){ Serial.println("Iz alive! Iz alive"); } else{ Serial.println("Dedz"); } ADS_reset(); ADS_requestADC(); Serial.println(ADS_readRegister(address,0x20),BIN); Serial.println(ADS_readRegister(address,0x24),BIN); Serial.println(ADS_readRegister(address,0x28),BIN); Serial.println(ADS_readRegister(address,0x2C),BIN); ADS_start(); initialTime=micros(); Serial.println(ADS_readRegister(address,0x28),BIN); } void loop() { if (rdy == true) { rdy=false; int voltageRecord = ADS_readData(address); nowTime = micros(); int timeRecord = (nowTime - initialTime)/1000; String dataInstance=String(timeRecord,decimalResolution)+","+String(voltageRecord,decimalResolution); Serial.println(dataInstance); } } bool ADS_begin() { if (! ADS_isConnected()) return false; return true; } bool ADS_isConnected() { Wire.beginTransmission(address); return (Wire.endTransmission() == 0); } void ADS_start(){ Wire.beginTransmission(address); Wire.write((uint8_t)0x08); Wire.endTransmission(); } void ADS_reset(){ Wire.beginTransmission(address); Wire.write((uint8_t)0x06); Wire.endTransmission(); } void ADS_requestADC() { // write to register is needed in continuous mode as other flags can be changed uint16_t config_1 = 0x00; // bit 7-4 Input multiplexer config config_1 |= 0x00; // bit 3-1 Gain config_1 |= 0x00; // bit 0 PGA enable uint16_t config_2 = 0x40; // bit 7-5 Data rate config_2 |= 0x00; // bit 4 Opeating mode config_2 |= 0x08; // bit 3 conversion mode config_2 |= 0x00; // bit 2-1 voltage reference config_2 |= 0x00; // bit 0 temperature sensor mode Serial.println(ADS_writeRegister(address, config_1, config_2)); } bool ADS_writeRegister(uint8_t address, uint16_t config_1, uint16_t config_2) { Wire.beginTransmission(address); Wire.write((uint8_t)0x40); Wire.write((uint8_t)config_1); Wire.write((uint8_t)0x44); Wire.write((uint8_t)config_2); return (Wire.endTransmission() == 0); } int ADS_readRegister(uint8_t address,uint8_t reg_map) { uint16_t value=0; Wire.beginTransmission(address); Wire.write((uint8_t)reg_map); Wire.endTransmission(); Wire.requestFrom((int) address, 1); value=Wire.read(); return value; } int ADS_readData(uint8_t address) { uint16_t value=0; int rv=0; Wire.beginTransmission(address); Wire.write((uint8_t)0x10); Wire.endTransmission(); rv=Wire.requestFrom((int) address, 2); if (rv == 2) { value = Wire.read() << 8; value += Wire.read(); return value; } } void adsReady() { rdy = true; }
I am not sure whether this is a hardware or a software issue. Would like to know where we went wrong. However, I do suspect that this problem has something to do with the RESET command being called when the IC's reset pin is connected to VDD. The smoke seems to come from that pin. Would like to validate my suspicions before I fix the module.
Thank you very much.