MCDC04 ADC requires Repeated Start for I2C, All Registers filled w/ 0

We are using the MCDC04 ADC with the MTCSiCF color sensor and are testing things on a small sensor board.

When using the MCDC04 library we created, all registers are 0. I thought the problem was in our readFromRegister , but upon reviewing the MCDC04 datasheet, it looks like a repeated start is needed for the read function.

Here is the sketch we are using to test this library:

#include <stdlib.h>
#include <Wire.h>
#include "MCDC04.h"


MCDC04 MCDC04_1 = MCDC04(0x73);

void setup() 
{
  
  Serial.begin(9600);
  if (MCDC04_1.begin()) 
  {
    Serial.println("Found sensor");
  } 
  else 
  {
    Serial.println("No MCDC04 found ... check your connections");
    while (1);
  }
}

void loop() 
{
  uint16_t X, Y, Z;
  uint8_t testState;
  uint8_t testCREGL;
  
  MCDC04_SetConfig();
  delay(500);
  testState = MCDC04_1.GetState();
  Serial.println(testState,HEX);

  testCREGL = MCDC04_1.GetCREGL();
  Serial.println(testCREGL,HEX);
}

void MCDC04_SetConfig()
{
  MCDC04_1.SetState(0x02); //Configuration Mode Set
  MCDC04_1.SetCREGL(0x88); //Anodes Set and Input, Reference Current =  20 nA, Integration Time = 256 ms
  MCDC04_1.SetCREGH(0x08); 
  MCDC04_1.SetOPT(0x00);
  Serial.println("Configuration Set");
}

Below is the readFromRegister section from our .cpp

 uint8_t MCDC04::readFromRegister(uint8_t address)
{
	uint8_t received_data = 0;
	
	// Establish connection, select receipt address
	Wire.beginTransmission(i2c_address); //Device ID
	Wire.write(address); //Register Address
	//Wire.beginTransmission(i2c_address);
	//received_data = Wire.read(address);
	
	Wire.endTransmission();

	// Request one data byte
	Wire.requestFrom(i2c_address, (uint8_t)1);
	
	//Fill variables
	if(Wire.available())
	{
            received_data = Wire.read();
	}
	
	Wire.endTransmission();
	return received_data;
}

Here is an example of how it is referenced further in the .cpp:

void MCDC04::SetState(uint8_t _M) //Operational State
{
	writeToRegister(MCDC04_OSR, _M);
}

uint8_t MCDC04::GetState(void) //Operational State
{
	return readFromRegister(MCDC04_OSR);
}

I am very new to Arduino, and any suggestions would be much appreciated!

MTCS-INT-AB4 OEM Board.pdf (750 KB)

In your read function, try changing the first endTransmission to this:

Wire.endTransmission(false);

I don't think the second endTransmission later in the function is needed.

Hello,

That didn't change things, but I appreciate the input! When using the MCDC04_1.GetState(); and MCDC04_1.GetCREGL(); the serial monitor still shows 0's.

Going back a step, have you checked that the device is recognised using an I2C scanner like this one?

https://github.com/RobTillaart/Arduino/tree/master/sketches/MultiSpeedI2CScanner

Can you post a link to the library you are using.

The device is recognized; the scanner is showing 5 devices.

I've looked at the MCDC04 datasheet here:

http://www.mazet.de/de/produkte/jencolor/sensor-signal-verstaerker/item/download/410_479c8d23b92cb9feeff6ae743887fb0c.html

Section 5.6 says ...

The MCDC04 can operate only as slave with unique slave address 11101A1A0, with the two lower bits defined by the input pins A1, A0.

That means the 7-bit addresses are in the range 111 0100 to 111 0111, which is 0x74 to 0x77. Your code snippet had address 0x73.

We know it should be 0x74, but when this is the address it says no MCDC04 is found.

Please post the output of the I2C scanner, and also the code for the library you are using.

0x73 could be the address of one of the other devices on the the OEM board,