Hi all!
I'm wondering if anyone can help me out here...
That is the link to the data sheet for an 8 channel DAC from TI.
And here's the master_writer example, edited to try to send a value out of channel A.
#include <Wire.h>
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}
byte x = 255;
byte y = 255;
byte CA = 0x30;
void loop()
{
Wire.beginTransmission(0x91); // hex 91, b10010001 to select chip and write
Wire.write(CA); //CA byte, 0 for channel A, I think...
Wire.write(x); //MSDB
Wire.write(y); //LSDB
Wire.endTransmission(); // stop transmitting
delay(100);
}
it says you for each update, you need
start condition
command/access byte
most significant data byte
least significant data byte
the tables are 3/4 through the data sheet.
As far as I can tell, the address of the chip when the addr pin is grounded, is 1001001, or in hex 0x91
the command/access byte should be either all 0s, to write to channel A, or 00110000 which seems to be write and update channel A.
Am I missing something huge here? Very possible, this is my first encounter with i2c. Any help would be VERY appreciated!
cheers
When you specify the device address to beginTransmission you do not include the read/write bit. So, in bit format it is address b1001000 and in hex this is 0x48 (decimal 52). So, you would use Wire.beginTransmission(0x48);
Pete
Thanks Pete!
Is that the only issue that jumps out at you? I'm still not getting any output (haven't FULLY ruled out mechanical error...) and want to make sure I'm at least approaching it right.
How do you have the other pins wired up?
Pin 15, SDA, to arduino A4, and pin 16, SCK, to arduino A5.
Pin 2, addr0, is grounded, as is pin 14, gnd.
Pin 3 AVdd is connected to arduino's 5v, as is Vrefin.
thanks fellas
What about these:
pin 1, LDAC/
pin 9, Clear/
Do you have 4.7K pullups on SDA, SCL?
Table 1 seems to indicate you need 4 bytes - address, command, data, data
system
May 16, 2012, 12:38am
7
Pin 1 and 9 are not connected.
But success! It's working now. My pull-up resistors weren't going anywhere, forgot the 5v!
Should 1 and 9 be grounded or something?
Thanks dudes
#include <Wire.h>
double a = 0;
byte MSDB;
byte LSDB;
byte CA = 0x30; //command/access byte, 0x30 is to write and update channel a
void setup()
{
pinMode(2, INPUT);
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600);
}
void loop()
{
a = random(4096);
if(a > 4095)
a = a - 4095;
MSDB = a / 16;
LSDB = int(a) % 255;
Wire.beginTransmission(0x48); // hex 48, B1001000
Wire.write(CA); //CA byte
Wire.write(MSDB); //MSDB
Wire.write(LSDB); //LSDB
Wire.endTransmission();
delay(100);
}
I seem to be getting a lot of noise on the output, and I'm sure my code could be cleaned up a bit. Anyway thanks a ton
I suspect that the noise will clean up if you use the channel address, LDAC, & CS correctly to latch/hold the outputs while the input data stream is changing.
Noise on the output may be due to just putting out random data too:
a = random(4096);
Try creating a ramp up & down instead and see how that looks.