Pages: [1]   Go Down
Author Topic: PCF8591 using A/D and D/A  (Read 846 times)
0 Members and 1 Guest are viewing this topic.
Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31393
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to use the PCF8591's D/A output and then read all four analogue inputs.
However, I am reading back the D/A's output value as one of the inputs, the one for channel 0. I have tried auto increment and individual reads. Sometimes the input on channel 0 is being transferred to the analogue output.
The data sheet says that the D/A's register is borrowed during A/D. Has any one got a sequence of I2C commands that would get the two converters working independent at the same time?
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Based on your experience I'd expect that you already do so, but it's worth asking because you didn't specify yet: Are you setting bit 6 in every control byte sent to the device? My guess would be this setup:

Code:
byte get_value(byte input_no, byte da_value) {
  Wire.beginTransmission(DEVICE_ADDR);
  Wire.write(0x44 | input_no);
  Wire.write(da_value);
  Wire.endTransmission();
  Wire.requestFrom(DEVICE_ADDR, 2);
  if (Wire.available()) {
    byte oldres = Wire.read();
  }
  if (Wire.available()) {
    byte val = Wire.read();
    return val;
  }
  return 0;
}

This way you're ignoring the result code of the previous conversion run and just reading the current value of the analog input.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31393
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Are you setting bit 6 in every control byte sent to the device?
Yes, that is the output enable bit, thanks. If you don't set it then the output pin is high impedance.

In fact when outputting a ramp just to the D/A the ramp also appears on the analogue input A0. By grounding the A0 input or sending it to the supply you can actually stop the ramp and send the analogue output high or low.
There seems to be some sort of coupling between the two. I have reluctantly orders another chip to check if this one is damaged in any way as I have had it a few years an it has been in several boards. Maybe the input multiplexer is shot?
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did I understand that correctly: Applying a voltage to A0 input changes the value of the Vout pin? It's not that you read just a wrong value for A0, you're actually changing the output value?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31393
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
you're actually changing the output value?
Yes that is right.
And the ramp is coming out of the A0 input as well.

Apart from that everything else works fine. Putting bit 6 of the control to zero allows me to read all the input channels independently and the value of the analogue output is controllable it is just this interaction when you are using both converters that has me a bit puzzled.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31393
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I got a new chip and that behaves just the same. So a piece of useful knowledge gained, when using the D/A on this chip the A/D channel 0 input can not be used. It doesn't say that in the data sheet, maybe it should.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8437
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes that's a bit of a gotcha. Worth a mention I would have thought.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Pages: [1]   Go Up
Jump to: