I'm using AD5258 digitalpot, but my arduino cannot control it, and my program always freeze at Wire.endTransmission();[Which means the program stuck there
#include <Wire.h>
int dt = 1000;
byte val = 0;
int led =13;
boolean ledOn=LOW;
void setup()
{
pinMode(led,OUTPUT);
Wire.begin();
Serial.begin(9600);
}
void loop()
{
Wire.beginTransmission(0x18);
Serial.println("1");
Wire.write(byte(0x00));
Serial.println("2");
Wire.write(val);
Serial.println("3");
Wire.endTransmission();
Serial.println("4");
ledOn=!ledOn;
digitalWrite(led,ledOn);
Serial.print(" sent - ");
Serial.println(val,HEX);
val++;
if(val == 64)
{
val = 0;
}
delay(dt);
}
}
My code is quite simple, I just want to use arduino to control digitalpot so as to supply a specific voltage. I need ur help~~ Thx a lot~
Palliser, for the byte error = Wire.endTransmission(); , I got nothing, everytime when comes to Wire.endTransmission(); will just stuck there, also the Scanner return nothing.
I'm first time using arduino, I guess is it because my connection? First time design my own circuit and do the project, really stuck here, I CHECKED all the datasheets alr still cannot find out can someone also help me to check the AD5258 datasheet?~~ pls =( =( I stuck two weeks alr~~~
gybmage:
Palliser, for the byte error = Wire.endTransmission(); , I got nothing, everytime when comes to Wire.endTransmission(); will just stuck there, also the Scanner return nothing.
The question is byte error = Wire.endTransmission(); , there is a Wire.endTransmission(), it never return anything and stuck there so anything below Wire.endTransmission(); cannot work
Something New(***): I tried a new AD5258 Digitalpot using I2C Scanner and it turned out that the address is 0x18, but after I upload my own program, I then tried to scan the address again, it keeps scanning~. So I want to ask is it because I broke the DIgitalpot IC????
Thanks for the screendump of the i2c_scanner. That might happen if A4 is shortcut to A5, or if one of them is shortcut to GND or 5V.
First we test the hardware.
Can you disconnect any I2C device.
Measure A4 and A5, they should be 5V (because of the pullup resistors of 10k).
Test if they are shortcut to GND or 5V or to each other.
Run the i2c_scanner (without any I2C device), it doesn't find something, but does the scanner run ?
If the scanner doesn't run, there must be a problem in the hardware or the ATmega chip is broken.
Thx Peter I take out the device and test, they are not shortcut to +5V OR GND, and the scanner shows well. I think my circuit is not properly designed, forgive me my English not well, I went through the datasheets many times but still not quite understand some of the parts, is it because I missed some important part that I should't set up like this???
You installed a new AD5258 in your breadboard and the I2C scanner found the device at 0x18.
You upload your sketch and when executed it gets stuck in the Wire.write---Wire.endTransmission portion of your code.
You scan again for the AD5258 and and the I2C scanner shows "Scanning.." like in the image in your post #7. QQ??20140723111829.png
but does not finish. It does not find the device or show no devices, but just stops and says Scanning.
Hi cattledog. Yes, and everything before Wire.endTransmission(); still can run, but only the program after it cannot run. I guess my circuit may broke the digitalpot chip.