I now want to connect four MPR121 sensor boards to the PCF8575 breakoutboard. (Sparkfun)
Without the PCF8575, the mpr121 code worked perfect. (http://code.bildr.org/download/1010.zip) However with the PCF8575 board I need to alter the addressing within the code. The SDA and SCL lines of the MPR121 boards I have connected to the PCF8575 board. See image. (http://forum.bildr.org/download/file.php?id=174)
The MPR121 (http://www.freescale.com/files/sensors/doc/data_sheet/MPR121.pdf) is a I2C capacitive touch sensor chip and the PCF8575 (http://www.ti.com/lit/ds/symlink/pcf8575.pdf) is a I2C to 16 GPIO expander (did you notice the links? Should have been added by you!). Both can be at the I2C at the same time and I don't see why the MPR121 has to be connected over the PCF8575, it won't work the way you're doing it. You can connect 4 MPR121 directly to the I2C by selecting the address with different connections of the ADDR pin.
BTW: you should use external pull-ups for the I2C (4k7).
Thanks for your response and my excuses for not adding the links.
What I will do is change the addresses of the boards by shorting the ADD to a different pin.
However to change the address of the chip (by shorting ADD to a different pin), I have to open the jumper first. How do I open the jumper? Which trace should be cut?
On the bottom of the breakout you have two solder pads with a thin connection between them. Cut that through (it connects ADD to GND) for the three modules you want to change the address for. Then connect the pin with Vcc, SCL or SDA (for the three versions).
Also the modules have pull-ups for the I2C installed. Cut these (also on the bottom aside the pins) for all but one module (or all if you install pull-ups yourself).
I cut the connection between the solder pads. (ADD to GND) Then connected the pin with Vcc, SCL or SDA (for the different versions). I tested each of the boards and this seems to work fine.
I have not yet cut the pull-ups for the I2C installed. Is this really necessary? If so, are these the four shorter lines which have the little whole at the end of it? Or the three which are longer and move to the side of the board?
If so, are these the four shorter lines which have the little whole at the end of it? Or the three which are longer and move to the side of the board?
On the bottom of the module you have four pairs of solder pads, each connected with a thin line of copper. One is the connection of the ADD to GND, the others are the pull-ups of SCL, SDA and INT. Cut the copper line for SDA and SCL.
I have not yet cut the pull-ups for the I2C installed. Is this really necessary?
On a I2C bus you should have the pull-up resistors only once per bus. The modules have 10k pull-ups, the Arduino internal pull-up is about the same value. Together that results in a total of 2k pull-up resistor for each line. That results in a current the active bus device has to sink that is over the I2C specification. That means the device may be harmed by the bus operation. Although I don't think that the small over-limit current destroys one of your devices, it's better to do it right, isn't it?
However, when I try to use the code (attachment) to address and read all of the four sensors, it doesn't work. Even if I only attach one sensor using this code, it will not work. Any suggestions what can be wrong?
I am now however facing a different problem.
For some reason the serial communication between Arduino and Max sometimes seems to miss some data.
This results in sensors staying high, even though they are not touched anymore.
Therefore I would like to alter the arduino code, so the status for each sensor get continuously updated.
For example every 40ms the output of every sensor gets printed. How should I alter the code to print the data continuously?
That's correct.
I would prefer the data to be send continuously.
However, that would probably give an information overload as the data will be transported to Max/MSP, and the serial object has some trouble receiving all the data.
So I'll be more than happy with every 40ms.
Wouldn't it make more sense to pass 0, 1, 2, and 3 to the function?
Shouldn't the function argument know, by having a meaningful name for the argument, whether the value is a pin number or an array index or the temperature in London last week?
}else{
Ican'treadcodethatcontainsstufflikethis. In my opinion, NOTHING follows the } on the same line, except at the end of a do/while statement (which I never use).