- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We are using CY8C4025LQI-S412.
We are using PWM for controlling backlight LED Intensity but for 100% and 0% duty cycle we STOP PWM and using GPIO to control LED ON OFF state.
we are putting CPU in sleep mode in between capsense scan in active mode for 30ms using CySysPmSleep(); when LED PWM is running and if LED PWM not running we are using CySysPmDeepSleep() to put device in deepsleep mode for 30ms.
if put in sleep, capsense touch response is not good I have to put finger on button for little more time. But in case we used deepsleep capsense sensing of button working very smooth and responsive.
Can any one review code and suggest possible reason behind it.
complete workspace code is attached in post,
if(false == isPWMRunning)
{
/* Put the device to deep sleep after each CapSense scan */
EnterDeepSleepMode();
}
else
{
/* Put the device to sleep after each CapSense scan */
EnterSleepMode();
}
Regards,
Hardik Harpal
Solved! Go to Solution.
- Tags:
- capsense[v6.0]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AH_96 wrote:
Sleep mode is not expected to cause such behaviour.
You are right. Stupid of me ,I did not checked UART Debug LOG. Key Press detected every time on UART LOG with sleep mode but Buzzer not playing by I2C master. I need to find why this happens. If I2C communication fails these could be reason but let me check as Buzzer played by I2C master(key not detetcted by it) working properly if I put device in Deep Sleep and not working if put in sleep mode so there should not be code logic issue but something else probably. Let me find out.
Edited: If I use sleep mode instead of deep sleep in PSOC4 in between scan, On I2C master side It receives I2C error. In sleep mode I can run SCB block right?
I am not calling SCB sleep and wakeup in EnterSleepMode() this resolved issue.
SCB_Wakeup();
SCB_Sleep();
Thanks for your support.
In mean time can you help me with one more issue/query I have,
If there is proximity present (RFID card at 14 mm parallel to keypad) in front of keypad and upon timeout If I call for Look For Touch mode
/* Set up ganged sensor for scanning */
/* Configure slider widget before scanning */
CapSense_CSDSetupWidgetExt(CapSense_PROXIMITY0_WDGT_ID, CapSense_PROXIMITY0_SNS0_ID);
/* Set the watchdog timer match value */
ConfigureWdt(gst_KeypadParameter.mu16_LFTScanTimeMS);
/* Set mode to look-for-touch */
scanMode = LOOK_FOR_TOUCH;
After this if I remove card form there and place again after few seconds at same distance card proxy is not detected I removed card again placed again after some time this time 10 mm close to keypad than also proxy is not detected. If I place just 3-5 mm than it detects proxy after that If remove card before calling above code(setting keypad in look for touch mode) than next time I I place card at 14 mm it detects proxy.
This happens every time, In short every time If there is proxy present and I put device in Look for touch mode and than card removed, proxy detects only by placing card very near to keypad. But in case of proxy is not present and I put device in Look for touch mode next time whenever I put card in front of keypad it It detects fine at 14 mm or more for every time.
So My question, Is below function do not update baseline for proximity sensor in Look for touch mode in firmware?.
CapSense_CSDScanExt();
CapSense_ProcessWidget(CapSense_PROXIMITY0_WDGT_ID);
CapSense_IsWidgetActive(CapSense_PROXIMITY0_WDGT_ID);
Is my flow in code related to capsense is right? All function I called related to capsense in code is the best way to achieve following out come:
What I tried to do in sleep scan for proxy(by ganged all sensor as proxy sensor) detection and after proxy detection scan all sensor and after operation complete (Required number of key pressed(LED OFF Command by i2c master)) or on timeout again go back to sleep and scan for proxy. Use possible lowest current consumption.
If there is any suggestion regarding capsense related code let me know.
Regards,
Hardik Harpal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Can you run the project by interchanging the Deepsleep and sleep function? That is, change the code to
if(false == isPWMRunning)
{
/* Put the device to deep sleep after each CapSense scan */
EnterSleepMode();
}
else
{
/* Put the device to sleep after each CapSense scan */
EnterDeepSleepMode();
}
so that we can confirm if the response is slower due to the wakeup source or if the issue is with CapSense. Kindly try this out and let us know the response rate of CapSense.
Thanks,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok I will do that in morning.
But for your reference, before submitting issue I ran one test in that PWM was not running as dutycycle was hardcoded to 100% and in my code there is logic to save current it stops pwm if running and instead of using pwm for 100% and 0% I am using gpio High/Low and in that case I am using EnterDeepSleepMode() as isPWMRunning will be set to false upon stoping pwm. But for testing I commented out bellow code
if(false == isPWMRunning)
{
/* Put the device to deep sleep after each CapSense scan */
EnterSleepMode();
}
else
{
/* Put the device to sleep after each CapSense scan */
EnterDeepSleepMode();
}
And in place of above code I called
EnterSleepMode();
In this case capsense touch sensing got sluggish. And note that in this case PWM was stop as i explained above.
For further testing I set LED PWM duty cycle to 50% so the pwm will run but I commented EnterSleepMode();
if(false == isPWMRunning)
{
/* Put the device to deep sleep after each CapSense scan */
// EnterSleepMode();
}
else
{
/* Put the device to sleep after each CapSense scan */
EnterDeepSleepMode();
}
So there was no sleep between two scan In that I observed fast response and there was no sluggish
Response on touch.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you told I did test
// if(false == isPWMRunning)
// {
// /* Put the device to deep sleep after each CapSense scan */
// EnterDeepSleepMode();
// }
// else
// {
// /* Put the device to sleep after each CapSense scan */
// EnterSleepMode();
// }
if(false == isPWMRunning)
{
/* Put the device to sleep after each CapSense scan */
EnterSleepMode();
}
else
{
/* Put the device to deep sleep after each CapSense scan */
EnterDeepSleepMode();
}
In this case capsense is working properly as expected responsive but as you know In this case we entering deepsleep so LED PWM stops after that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Yes, you are right. When device enters deep sleep, all hardware blocks are also powered down. Can you please let me know how much response time difference you are observing?
And as I understand, if PWM is enabled and device is put into sleep mode, the performance is getting affected. However, WDT is the wakeup source in both cases.
Can you also add the line to make the scan mode active after the low power mode to confirm if the scanmode is affecting the performance?
That is, after,
else
{
if(false == isPWMRunning)
{
/* Put the device to deep sleep after each CapSense scan */
EnterDeepSleepMode();
}
else
{
/* Put the device to sleep after each CapSense scan */
EnterSleepMode();
}
}
add
/* Set mode to active mode */
scanMode = ACTIVE;
This will ensure that all the sensors are scanned after the device exits low power mode.
Thanks,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for reply.
I added,
/* Set mode to active mode */
scanMode = ACTIVE;
but result was same sluggish you can see in attached in videos.
Regarding response time see attached video
1) LED_PWM_DUTYCYCLE_50_Working_With_Long_And_Hard_Press_But_Not_Acceptable.
LED PWM DUTYCYCLE 50 Working With Long And Hard Press But Not Acceptable - YouTube
2) LED_PWM_DUTYCYCLE_50_Not_Working_With_Normal_Touch.
LED PWM DUTYCYCLE 50 Not Working With Normal Touch - YouTube
3) LED_PWM_DUTYCYCLE_100_Working_Ok.
LED PWM DUTYCYCLE 100 Working Ok - YouTube
For video 1) and 2):
SR_BlueLED_Write(g_I2CBuffer[CMD_DATA_INDEX_0]); is replaced by bellow code so LED duty cycle written by I2C Master will be always set to 50% and PWM will be used to drive LED.
if(g_I2CBuffer[CMD_DATA_INDEX_0] > 0)
{
g_I2CBuffer[CMD_DATA_INDEX_0] = 50;
}
else
{
g_I2CBuffer[CMD_DATA_INDEX_0] = 0;
}
SR_BlueLED_Write(g_I2CBuffer[CMD_DATA_INDEX_0]);
For video 3):
SR_BlueLED_Write(g_I2CBuffer[CMD_DATA_INDEX_0]); is replaced by bellow code so LED duty cycle written by I2C Master will be always set to 100% and PWM will not be used to drive LED.
if(g_I2CBuffer[CMD_DATA_INDEX_0] > 0)
{
g_I2CBuffer[CMD_DATA_INDEX_0] = 100;
}
else
{
g_I2CBuffer[CMD_DATA_INDEX_0] = 0;
}
SR_BlueLED_Write(g_I2CBuffer[CMD_DATA_INDEX_0]);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AH_96 wrote:
And as I understand, if PWM is enabled and device is put into sleep mode, the performance is getting affected. However, WDT is the wakeup source in both cases.
If I use Duty cycle 100% so that PWM will be not used so as per my code EnterDeepSleepMode(); should be called but instead I called EnterSleepMode() for test.In this situation PWM will be disabled but device will use EnterSleepMode() then also it affects capsense performance. So no issue related to PWM but Sleep and Deep sleep mode difference changes outcome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you try a simple code with a single button and just the low power modes so that we can confirm this? Sleep mode is not expected to cause such behavior.
You can also toggle a pin at the start of CapSense_ScanAllWidgets (after entering the low power mode) to make sure that the sensors are getting scanned appropriately. If the pin does not toggle, it means that the firmware is lagging and it isn't the CapSense that is causing this issue. This would help us debug better.
Thanks,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AH_96 wrote:
Sleep mode is not expected to cause such behaviour.
You are right. Stupid of me ,I did not checked UART Debug LOG. Key Press detected every time on UART LOG with sleep mode but Buzzer not playing by I2C master. I need to find why this happens. If I2C communication fails these could be reason but let me check as Buzzer played by I2C master(key not detetcted by it) working properly if I put device in Deep Sleep and not working if put in sleep mode so there should not be code logic issue but something else probably. Let me find out.
Edited: If I use sleep mode instead of deep sleep in PSOC4 in between scan, On I2C master side It receives I2C error. In sleep mode I can run SCB block right?
I am not calling SCB sleep and wakeup in EnterSleepMode() this resolved issue.
SCB_Wakeup();
SCB_Sleep();
Thanks for your support.
In mean time can you help me with one more issue/query I have,
If there is proximity present (RFID card at 14 mm parallel to keypad) in front of keypad and upon timeout If I call for Look For Touch mode
/* Set up ganged sensor for scanning */
/* Configure slider widget before scanning */
CapSense_CSDSetupWidgetExt(CapSense_PROXIMITY0_WDGT_ID, CapSense_PROXIMITY0_SNS0_ID);
/* Set the watchdog timer match value */
ConfigureWdt(gst_KeypadParameter.mu16_LFTScanTimeMS);
/* Set mode to look-for-touch */
scanMode = LOOK_FOR_TOUCH;
After this if I remove card form there and place again after few seconds at same distance card proxy is not detected I removed card again placed again after some time this time 10 mm close to keypad than also proxy is not detected. If I place just 3-5 mm than it detects proxy after that If remove card before calling above code(setting keypad in look for touch mode) than next time I I place card at 14 mm it detects proxy.
This happens every time, In short every time If there is proxy present and I put device in Look for touch mode and than card removed, proxy detects only by placing card very near to keypad. But in case of proxy is not present and I put device in Look for touch mode next time whenever I put card in front of keypad it It detects fine at 14 mm or more for every time.
So My question, Is below function do not update baseline for proximity sensor in Look for touch mode in firmware?.
CapSense_CSDScanExt();
CapSense_ProcessWidget(CapSense_PROXIMITY0_WDGT_ID);
CapSense_IsWidgetActive(CapSense_PROXIMITY0_WDGT_ID);
Is my flow in code related to capsense is right? All function I called related to capsense in code is the best way to achieve following out come:
What I tried to do in sleep scan for proxy(by ganged all sensor as proxy sensor) detection and after proxy detection scan all sensor and after operation complete (Required number of key pressed(LED OFF Command by i2c master)) or on timeout again go back to sleep and scan for proxy. Use possible lowest current consumption.
If there is any suggestion regarding capsense related code let me know.
Regards,
Hardik Harpal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi user_284076
The code flow is correct. You are moving to LOOK_FOR_TOUCH mode, mode where proximity is active by ganging all buttons, if there are no sensors active for certain duration.
And if there is any activity found, you are moving to ACTIVE mode that scans all the sensors separately to detect a touch.
Again, this seems strange. Buttons ganged together must be able to sense at the distance of 14 mm. Can you run CapSense tuner in your board to see the raw counts reported by the proximity sensor in both cases? This will give us more insight as to why there is low sensitivity.
As long as you are placing it after the timeout dictated by the Debounce number, proximity sensor should scan it at 14 mm.
Please let me know if you are facing the issue if you place it after a certain amount of time. That is, after the state moves to LOOK_FOR_TOUCH mode.
Thanks,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can anyone look at this issue or can give me some suggestion where should I look for first to resolve this.