Original design thread HERE.
Attached is a (partial) circuit diagram of what I have in place, this hooks up to a Raspberry Pi via the top-left header which I'll summarise:
From the RPi header (P1 bottom-left, P2 top-left, P3 2nd-from-bottom-left):
* P1 is 3V3 supply for the AD7998 (centre)
* P3+5 are SDA/SCL
* P7 is CONVST pin on the AD7998
* P9 is GND
* P11 goes to a 330R, then to the base of a BC548
* P13+15 are irrelevant
* P17 is 3V3 supply (Same supply as P1) for the BC548
Now, if I throw a 59K resistor between V+ (BC548 emitter) and any pin on that ADC header I get this inconsistent output from my program (below), but if I have all the pins open circuit then the reading is a solid 1.6 volts (Half Vref?)
I'm confused.
Source:
Attached is a (partial) circuit diagram of what I have in place, this hooks up to a Raspberry Pi via the top-left header which I'll summarise:
From the RPi header (P1 bottom-left, P2 top-left, P3 2nd-from-bottom-left):
* P1 is 3V3 supply for the AD7998 (centre)
* P3+5 are SDA/SCL
* P7 is CONVST pin on the AD7998
* P9 is GND
* P11 goes to a 330R, then to the base of a BC548
* P13+15 are irrelevant
* P17 is 3V3 supply (Same supply as P1) for the BC548
Now, if I throw a 59K resistor between V+ (BC548 emitter) and any pin on that ADC header I get this inconsistent output from my program (below), but if I have all the pins open circuit then the reading is a solid 1.6 volts (Half Vref?)
I'm confused.
Rich (BB code):
Channel 00 = 3.299194 (Alert = 0, 0x0FFF)
Channel 01 = 3.299194 (Alert = 1, 0x1FFF)
Channel 02 = 0.000000 (Alert = 1, 0x2000)
Channel 03 = 0.000000 (Alert = 0, 0x3000)
Channel 04 = 0.000000 (Alert = 1, 0x4000)
Channel 05 = 0.011279 (Alert = 1, 0x500E)
Channel 06 = 0.448755 (Alert = 0, 0x622D)
Channel 07 = 3.299194 (Alert = 0, 0x7FFF)
Channel 00 = 3.299194 (Alert = 0, 0x0FFF)
Channel 01 = 3.299194 (Alert = 0, 0x1FFF)
Channel 02 = 3.299194 (Alert = 1, 0x2FFF)
Channel 03 = 3.299194 (Alert = 0, 0x3FFF)
Channel 04 = 3.299194 (Alert = 1, 0x4FFF)
Channel 05 = 3.299194 (Alert = 1, 0x5FFF)
Channel 06 = 0.000000 (Alert = 0, 0x6000)
Channel 07 = 0.000000 (Alert = 0, 0x7000)
Channel 00 = 3.299194 (Alert = 0, 0x0FFF)
Channel 01 = 3.299194 (Alert = 1, 0x1FFF)
Channel 02 = 3.299194 (Alert = 1, 0x2FFF)
Channel 03 = 3.299194 (Alert = 0, 0x3FFF)
Channel 04 = 3.299194 (Alert = 1, 0x4FFF)
Channel 05 = 3.299194 (Alert = 1, 0x5FFF)
Channel 06 = 3.299194 (Alert = 0, 0x6FFF)
Channel 07 = 2.274390 (Alert = 0, 0x7B07)
Channel 00 = 3.299194 (Alert = 0, 0x0FFF)
Channel 01 = 3.299194 (Alert = 0, 0x1FFF)
Channel 02 = 3.299194 (Alert = 1, 0x2FFF)
Channel 03 = 0.000000 (Alert = 0, 0x3000)
Channel 04 = 0.000000 (Alert = 1, 0x4000)
Channel 05 = 0.000000 (Alert = 1, 0x5000)
Channel 06 = 0.001611 (Alert = 0, 0x6002)
Channel 07 = 2.145483 (Alert = 0, 0x7A67)
Rich (BB code):
for (int i = 0; i < 8; i++) {
// Channel is masked as 0b0CCC 0000
// Read Single flag is 0b1000 0000
channel = (i << AD799X_CHANNEL_SHIFT)
| AD7997_8_READ_SINGLE;
// Write command
if (write(m_i2c,&channel,1) != 1) {
printf("Failed to write to the i2c bus: %s\n",
strerror(errno));
}
// Wait 5uS
delay_us(5);
// Read from device, format is:
// ACCC DDDD DDDD DDDD
// Where:
// A = alarm
// C[3] = channel
// D[12] = voltage
if (read(m_i2c,buf,2) != 2) {
printf("Failed to read from the i2c bus: %s\n",
strerror(errno));
} else {
// Dump it
data = (float)((buf[0] & 0b00001111) << 8) + buf[1];
data = (data / 4096.0f) * 3.3f;
channel = ((buf[0] & 0b01110000) >> 4);
printf("Channel %02d = %04f (Alert = %d, 0x%02X%02X)\n",
channel, data, (buf[(i<<1) + 0] & 0x80) ? 1 : 0,
buf[0], buf[1]);
}
}
Attachments
-
99 KB Views: 42