Help me read registers AD7151!

Hi all.

All the examples will not work! How to read the registers AD7151 ?

First you need to post how you have wired it up and what code you have tried. Then we can see what is wrong. For starters is the I2C connected to analogue 4 & 5 not digital 4 & 5. Have you got pull up resistors, to what voltage and what value?

This is a 3V3 device have you connected it up to 5V? Are you using a 3V3 arduino or is it a 5V one. If a 5V one have you got a voltage converter in the I2C lines?

  1. Code:
#include <Wire.h>

#define SLAVEWRT 0x48
#define SLAVERD 0x48

void setup()
{
Wire.begin();
Serial.begin(9600);
Wire.beginTransmission(SLAVEWRT);
Wire.send(0x0B);                  // SETUP REGISTER
Wire.send(0x0B);
Wire.endTransmission();
delay(4);
Wire.beginTransmission(SLAVEWRT);
Wire.send(0x0F);                  // CONFIG REGISTER
Wire.send(0x19);
Wire.endTransmission();
delay(4);
Wire.beginTransmission(SLAVEWRT);
Wire.send(0x10);                   //POWER TIMER
Wire.send(0x00);
Wire.endTransmission();
delay(4);
Wire.beginTransmission(SLAVEWRT);
Wire.send(0x11);                     // CAPDAC REGISTER
Wire.send(0x00);
Wire.endTransmission();
delay(4);
Wire.beginTransmission(SLAVEWRT);
Wire.send(0x09);                      //SENSETIVITY REGISTER
Wire.send(0x08);
Wire.endTransmission();
delay(4);
}

void loop()
{
Wire.beginTransmission(SLAVERD);
Wire.send(0x17);                      // chip id register
Wire.endTransmission();
Wire.requestFrom(SLAVERD,1);   
while(Wire.available())
{
char c = Wire.receive();
Serial.print(c, DEC);
Serial.print(",");

}
Serial.println();
}
  1. connected to analogue 4 & 5 !

  2. pull up resistors 4.7 Kom on 3v3.

  3. Are you using a 3V3 arduino? - yes!

  4. chip works OUT on LED

  5. twi.h - TWI/I2C library for Wiring & Arduino:

#ifndef TWI_FREQ
#define TWI_FREQ 400000L
#endif

  1. In terminal:

~ ~ ~ ~ ~ ~

:-[ sorry for poor English!

First of all until you get it going then use the 100KHz mode. I have had I2C chips that won't work at 400KHz even though the specification says it should.

  1. chip works OUT on LED

Not sure what you mean by this.

The code look fine, what are you seeing as a result of the request for the chip ID? Have you tried looking at the four bytes of serial number?

The serial printout doesn't match your sketch. Are you sure it is compiled for the type of board you're using?

It looks like you have a baudrate mismacth. One possible cause for this is if you compile for 16MHz, but run the board at 8Mhz.

Why the board run at 8Mhz ? Arduino Nano v.4 Atmega168!

The serial printout doesn't match your sketch

True you are asking it to print out a HEX value and it is printing out ASCII values. The printed output will only contain the numbers 0 to 9 and letters A to F. See:- http://arduino.cc/en/Serial/Print

It looks like you have the baud rate set at 9600 in both units so it is a bit of a puzzle.

the board run at 8Mhz ? Arduino Nano v.4 Atmega168!

Looks like it is not got the right software in it for the 8MHz and you are getting the wrong baud rate. try doubling the baud rate in the sketch.

Why the board run at 8Mhz ? Arduino Nano v.4 Atmega168!

You told as above that you have a 3V3 device and they typically run at 8Mhz.

Try to compile it for the Mini pro, 168, 8Mhz board. If this does not work (proper output), you may have to add a new entry to "boards.txt" to get it right.

Yes!!!! - compile it for the Mini pro, 168, 8Mhz board :

It seems as if you still have a baudrate issue (assuming baudrate setting is the same in your sketch and in the IDE) - however not as bad as the first attempt.

Could it be running at 12MHz? You need to find this out for sure either by reading the Mhz value off the crystal on your board or check with those you bought it from.

If it is 12MHz, you need to change the cpu frequency parameter in the Arduino boards.txt file for the board you choose.

I suggest you forget about the I2C part for the moment and just write a sketch that outputs the hex numbers 0 to F. Then you know what you should be seeing and you can compare it with what you are seeing.

Thank you all for your attention!

The problem in the levels of signals: AD7151 3,3v - my arduino 5V ! :'(

This problem Hardware!

Advise where to buy Arduino 3.3V