Show Posts
Pages: 1 ... 5 6 [7]
91  Using Arduino / Networking, Protocols, and Devices / Re: I2C trouble with the MPR084 on: March 08, 2011, 11:50:47 pm
Can you post the code you are using?  Make sure the address you are using matches the address of the IC with address line.  Can you post a schematic also so we can see if you have it wired up correctly?  

Here is a picture of my schematic.
http://flic.kr/p/9oYkDp

As I'm a working/family man, I have yet to check some of the other suggestions in these replies. I have yet to procure a USB<->Serial cable to read the output of my Arduino.

Thanks, I appreciate the attention to this problem.  I will certainly post my code when I get this figured out.
92  Using Arduino / Networking, Protocols, and Devices / Re: I2C trouble with the MPR084 on: March 06, 2011, 11:25:37 pm
I notice that the Wire.requestFrom() function actually requires the address as one of its arguments, but I don't think I want to do that again because it's not part of the data flow as specified by the MPR084. 

Look at page 8 of their spec. The address is part of reading, that's normal for I2C. You send the slave address with the read bit set, then the requestFrom clocks out the data bytes, as required.

You're right, but the question is:  How does it work with Arduino's Wire library?  That's what I don't know.  The example that I have shows the sequence as:  Slave Address, Command, Slave Address, Data (see http://www2.neufeld.newton.ks.us/images/electronics/2008/05/26/PCA9535-figure-8.png).  And that's what the receive code that I have found does.  But I don't want to do that, p.8 of the data sheet says that reading the MPR084 proceeds like this, in a nutshell:  Slave Address, Command, Data.

...In your example at www.gammon.com.au, say under "Request Response" about 3/4 through the page, I see that you do your sendCommand() this way:
Code:
Wire.beginTransmission (SLAVE_ADDRESS);
  Wire.send (cmd);
  Wire.endTransmission ();
 
  Wire.requestFrom (SLAVE_ADDRESS, responseSize); 

...my interpretation is that the beginTransmission / send / endTransmission will actually send the Slave Address and the Command onto the wire.  Now the MPR084 will send data.  But the requestFrom requires the Slave Address, which would also fit into the scheme shown at http://www2.neufeld.newton.ks.us/images/electronics/2008/05/26/PCA9535-figure-8.png - It appears to me that the Slave Address will then be sent out onto the wire. But I don't want to send it again, because the MPR084 should be sending at this point, so what would I do?  How to just receive the data at this point, without addressing further?

Well I have been out all day today and I have to go to bed so I will send the schematic and my code asap.  Thanks for your attention.
93  Using Arduino / Networking, Protocols, and Devices / Re: I2C trouble with the MPR084 on: March 06, 2011, 08:16:38 am
Thanks, Nick!  I'll look into it.  It sounds like exactly what I need!
- the Gnome
94  Using Arduino / Networking, Protocols, and Devices / I2C trouble with the MPR084 on: March 06, 2011, 12:57:06 am
Hello,
I'm trying to talk to the MPR084 using my Arduino Duemilanove.  I've got the level shifting figured out (I believe), but I'm not getting any response from the MPR084.  I have tried 2 of the chips with the same results.

Part of my problem is that I don't really understand exactly what the TWI subroutines do.  That is, where is the 1:1 correspondence between the TWI commands and the i2c communication?  When does the data start flowing during a write?  How about during a read?  The abstraction (Wire library) of the physical underlying process (i2c data stream) is not well documented, and I am having trouble gluing them together.

For example, one of the first Google hits for examples is http://www.neufeld.newton.ks.us/electronics/?p=241.  When reading i2c data, he recommends doing
Code:
  //  Send input register address
  Wire.beginTransmission(address); Wire.send(REGISTER_INPUT); Wire.endTransmission();
  //  Connect to device and request two bytes
  Wire.beginTransmission(address); Wire.requestFrom(address, 2); // 2 bytes.
  if (Wire.available()) { data = Wire.receive(); } ; Wire.endTransmission();

...Because the documentation for his device shows that in order to read his chip, it requires:  Slave Address, then Command Byte, then Slave Address again, then the Arduino receives the data bytes as specified.

But for the MPR084, to read it you do:  Slave Address, then Command Byte, then receive the n data bytes.

I notice that the Wire.requestFrom() function actually requires the address as one of its arguments, but I don't think I want to do that again because it's not part of the data flow as specified by the MPR084.  What I think I need to do is something roughly like:
Code:
beginTransmission(address); endTransmission(address); //without sending any data...
receiveFrom(REGISTER_INPUT, 1); // to receive 1 byte from the register I'm interested in
store=receive();

...but I've tried it and it didn't work.  Any suggestions would be appreciated.  Thanks for any help.
-Mike Schwager
Pages: 1 ... 5 6 [7]