MPR121 Auto-Calibration time

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPR121 Auto-Calibration time

Jump to solution
2,815 Views
Janosch
Contributor II

Hello guys,

i'm just starting using the MPR121, and so far i am highly fascinated.

However i am experiencing a startup time for the auto-calibration, that i would love to see a little lower. I am using 8 channels (0-7), and from power-up it takes the MPR121 around 5-8 seconds to settle. In the debugger of my processor i see the baseline values (0x1E through 0x25) settling towards the decimal values from ~24 to ~39, and when they are settled, touches are recognized nicely.

Is this normal behaviour? Is there any way to speed up the auto-calibration?

If i wouldn't want to use auto-calibration, what steps would i need to do to manually calibrate the MPR121?

Would it be good practice to store the settled baseline values in flash memory, and use them to initialize the MPR121 at startup? I have also noticed, that when i use defuined baseline values at startup, the auto-calibration will only correct them upwards. I.e., when i preset a channel with baseline=30, where ~24 would be the value at which the calibration would settle, then this value stays at 30 and false touches are recognized.

I'd be glad to hear some of our insights to that startup topic.

Thanks a lot,

Janos

Labels (1)
Tags (2)
1 Solution
1,282 Views
reyes
NXP TechSupport
NXP TechSupport

Hi Janos,

You can use something like the code below, this code is used to tracking big baseline change when just after power on.

Please let me know if it works to accelerate the initialization and auto-calibration.

#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

View solution in original post

2 Replies
1,283 Views
reyes
NXP TechSupport
NXP TechSupport

Hi Janos,

You can use something like the code below, this code is used to tracking big baseline change when just after power on.

Please let me know if it works to accelerate the initialization and auto-calibration.

#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

1,282 Views
Janosch
Contributor II

Dear Jose,

it took me some time to get back to the touch sensor, meanwhile i brought the rest of the system into operation.

Thank you so much for your solution. It works PERFECTLY. From about 3 seconds it now only ... almost _nothing_ until the baseline is settled! This is awesome.

I will now have to dig in deep into the MPRs configuration possibilities, because i have quite challenging things to achieve with this sensor. Thanks for now for this one!

Cheers

Janos

0 Kudos