I want to set 3 devices of the digital potentiometer MCP45HV51 to different values, but I have the Problem, that all three devices are set always to the same value.
My Hardware is ARDUINO MEGA2560 and 3 Chips from Microchip type MCP45HV51
( ww1.microchip.com/downloads/en/DeviceDoc/20005304A.pdf )
The addresses (A1;A0) are wired by hardware to 00 ; 10; 11. (0 = GND; 1= +5V)
/WLAT is wired to "low"
/SHDN is wired to "high"
Here is my code:
/* three MCP45HV51 Digitalpotentiometer on I2C */
#include <Wire.h>
void setup() {
Wire.begin();
//TWBR=200; //I2C Takt herabsetzen // used to slow down I2C
Wire.beginTransmission(B0111100); // transmit to device 00
// 7-bit address A0=low A1=low
Wire.write(byte(0x00)); // send instruction byte
Wire.write(0x40); // send value 0x40 byte
Wire.endTransmission(); // transmitting
// now all 3 Potentiometers have the value 0x40 --- why ???
Wire.beginTransmission(B0111110); // transmit to device 10
// 7-bit address is A0=low A1=high
Wire.write(byte(0x00)); // send instruction byte
Wire.write(0x80); // sends value 0x80 byte
Wire.endTransmission(); // transmitting
delay(200);
// now all 3 Potentiometers have the value 0x80 --- why ???
Wire.beginTransmission(B0111111); // transmit to device 11
// 7-bit address is A0=high A1=high
Wire.write(byte(0x00)); // sends instruction byte
Wire.write(0xd0); // sends value oxd0 byte
Wire.endTransmission(); // transmitting
delay(200);
// now all 3 Potentiometers have the value 0xd0 --- why ???
}
void loop()
{
}
What is wrong in my code ?? I think, I do not use a "general call"
The I2C lines are pulled up via 2k2 resitors.
There is no other device on the I2C-bus.
I`ve also tried to slow down the I2C bus, but no changes.
HELP - (it´s urgend)