Folks,
I'm using MPR121's for a large musical instrument. the whole instrument is made up of 6 different keyboard structures each with an MPR121 and an Arduino Mega.. all in all it works quite well. The issue I'm having is with the autocalibration routines. At startup, I use the MPR121 autocalibrate to automatically set the operating point for each of the 'keys' . Generally it works great. and all 6 keyboards come up wiht all 11 keys on each working. . Occasionally, however one or two of the units will come with 1-3 keys that are not working.. I can always clear the condition by doing a full power on reset a time or two, but that's inconvenience. Any idea why I'm getting this flaky behavior ? Could I have the thresholds set wrong or something ? Thanks for any quick help.. This thing goes on the road in 2 weeks !
-jc
I've attached a copy of the MPR121 register settings I'm using..
Original Attachment has been moved to: BIG_mpr121_settings.txt.zip
Hi,
I think that it’s possible that the problem its timing related (it’s possible that you are not running at the 400 kHz needed for the MPR121).
But you can find a code example for the MPR121 using the ATmega328 on the link below, I would recommend you to test your MPR121 using the code on this link:
https://www.sparkfun.com/products/9695
Or you can test it using our suggested initialization code:
#define TouchThre 10 //15//30//10
#define ReleaThre 6 //8//25//8
void MPR121_init(void)
{
//Reset MPR121 if not reset correctly
IIC_ByteWrite(0x80,0x63); //Soft reset
IIC_ByteWrite(0x5E,0x00); //Stop mode
//touch pad baseline filter
//rising
IIC_ByteWrite(0x2B,0x01); // MAX HALF DELTA Rising
IIC_ByteWrite(0x2C,0x01); // NOISE HALF DELTA Rising
IIC_ByteWrite(0x2D,0x0E); // NOISE COUNT LIMIT Rising
IIC_ByteWrite(0x2E,0x00); // DELAY LIMIT Rising
//falling
IIC_ByteWrite(0x2F,0x01); // MAX HALF DELTA Falling
IIC_ByteWrite(0x30,0x05); // NOISE HALF DELTA Falling
IIC_ByteWrite(0x31,0x01); // NOISE COUNT LIMIT Falling
IIC_ByteWrite(0x32,0x00); // DELAY LIMIT Falling
//touched
IIC_ByteWrite(0x33,0x00); // Noise half delta touched
IIC_ByteWrite(0x34,0x00); // Noise counts touched
IIC_ByteWrite(0x35,0x00); // Filter delay touched
//Touch pad threshold
IIC_ByteWrite(0x41,TouchThre); // ELE0 TOUCH THRESHOLD
IIC_ByteWrite(0x42,ReleaThre); // ELE0 RELEASE THRESHOLD
IIC_ByteWrite(0x43,TouchThre); // ELE1 TOUCH THRESHOLD
IIC_ByteWrite(0x44,ReleaThre); // ELE1 RELEASE THRESHOLD
IIC_ByteWrite(0x45,TouchThre); // ELE2 TOUCH THRESHOLD
IIC_ByteWrite(0x46,ReleaThre); // ELE2 RELEASE THRESHOLD
IIC_ByteWrite(0x47,TouchThre); // ELE3 TOUCH THRESHOLD
IIC_ByteWrite(0x48,ReleaThre); // ELE3 RELEASE THRESHOLD
IIC_ByteWrite(0x49,TouchThre); // ELE4 TOUCH THRESHOLD
IIC_ByteWrite(0x4A,ReleaThre); // ELE4 RELEASE THRESHOLD
IIC_ByteWrite(0x4B,TouchThre); // ELE5 TOUCH THRESHOLD
IIC_ByteWrite(0x4C,ReleaThre); // ELE5 RELEASE THRESHOLD
IIC_ByteWrite(0x4D,TouchThre); // ELE6 TOUCH THRESHOLD
IIC_ByteWrite(0x4E,ReleaThre); // ELE6 RELEASE THRESHOLD
IIC_ByteWrite(0x4F,TouchThre); // ELE7 TOUCH THRESHOLD
IIC_ByteWrite(0x50,ReleaThre); // ELE7 RELEASE THRESHOLD
IIC_ByteWrite(0x51,TouchThre); // ELE8 TOUCH THRESHOLD
IIC_ByteWrite(0x52,ReleaThre); // ELE8 RELEASE THRESHOLD
IIC_ByteWrite(0x53,TouchThre); // ELE9 TOUCH THRESHOLD
IIC_ByteWrite(0x54,ReleaThre); // ELE9 RELEASE THRESHOLD
IIC_ByteWrite(0x55,TouchThre); // ELE10 TOUCH THRESHOLD
IIC_ByteWrite(0x56,ReleaThre); // ELE10 RELEASE THRESHOLD
IIC_ByteWrite(0x57,TouchThre); // ELE11 TOUCH THRESHOLD
IIC_ByteWrite(0x58,ReleaThre); // ELE11 RELEASE THRESHOLD
//touch /release debounce
IIC_ByteWrite(0x5B,0x00);
// response time = SFI(10) X ESI(8ms) = 80ms
IIC_ByteWrite(0x5D,0x13);
//FFI=18
IIC_ByteWrite(0x5C,0x80);
//Auto configuration
IIC_ByteWrite(0x7B,0x8F);
// charge to 70% of Vdd , high sensitivity
IIC_ByteWrite(0x7D,0xE4);
IIC_ByteWrite(0x7E,0x94);
IIC_ByteWrite(0x7F,0xCD);
// 12 electrodes enabled
IIC_ByteWrite(0x5E,0xCC);
}
Regards,
Jose