- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please tell me how to make capsense program.
It would be helpful if you could get the whole project if you like.
I currently have the following issues
Suddenly, the capacitance sensor does not read the value.
I don't know if it's a hardware problem or a software problem.
This time, we would like you to look at the software you created and give us your suggestions.
As a possible situation, I think that the cause is operating in a loop faster than the scan time of the sensor.
Solved! Go to Solution.
- Tags:
- capsense[v6.0]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I learned how to use CapSense (v7.0) at
So attached is the version using CapSnse (v7.0) instead of CapSense CSD (v2.60).
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
The issue is not due to the loop time being faster than scan time. CapSense_IsBusy() will only return 0 when scan is completed. The problem seems to be due to the variable cnt.
You are checking for a condition
if(cnt == 0)
and proceeding only if it is true. However, after the first iteration, cnt is set to 1 and is never cleared again. Therefore, the condition is never TRUE again.
Please try fixing this and checking the performance. In case there is still a performance issue, you can just try running
if(CapSense_NOT_BUSY == CapSense_IsBusy())
{
CapSense_ProcessAllWidgets();
#ifdef EZI2C
CapSense_RunTuner();
#endif
CapSense_ScanAllWidgets();
}
without any other conditions and check the tuner. This will help us understand if there is any issue in the hardware.
Best regards
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply AH_96!
The function of “CY_ISR (SysTick_Handler)” is called as an interrupt every 1 ms (SysTick_Config (CYDEV_BCLK__SYSCLK__HZ / 1000);).
Therefore, even if cnt becomes 1, cnt becomes 0 again because "if (cnt> 0) {cnt--;}" is performed in the function.
The symptom of this time is that when the power is turned on, the sensor value is not updated as it is 0. The recall was very low and could not be confirmed with the tuner. It may be because it is a self-made PCB board.
Sometimes it didn't work before. At that time, the project used UART and CAPSENSE. When power was turned on, the UART was outputting a waveform, and only capsense did not respond. The solution was to connect CMOD to the wrong IO pin and reconnect it to the regular p4_2 in the documentation. In this case, I think the possibility is low because we are connecting to p4_2.
If this source code is looped with delay instead of CNT description, is there any mistake in the description of the capsense code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can check the hardware performance by a simple scan-process flow and observe the CapSense graph in Tuner. Please try running th I2C Tuner code example. This will help us confirm if this is a hardware issue.
If possible, please share the schematic and layout of the design so that we can take a look.
Best regards
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As I'm not very familiar with CapSense component, I tried using CapSense CSD component using CY8CKIT-044.
The schematic
main.c
===========================
#include "project.h"
#include "stdio.h"
#define USE_TUNER 0
#define USE_UART 1
volatile int pit_flag = 0 ;
volatile uint16_t tick_count = 0 ;
#define NUM_PUSH_BUTTON 6
#define NUM_TOUCH_BUTTON 9
uint8_t push_button[NUM_PUSH_BUTTON] = { 0u } ;
uint8_t touch_button[NUM_TOUCH_BUTTON] = { 0u } ;
uint8_t push_button_id[NUM_PUSH_BUTTON] = {
CapSense_PUSH1__BTN,
CapSense_PUSH2__BTN,
CapSense_PUSH3__BTN,
CapSense_PUSH4__BTN,
CapSense_PUSH5__BTN,
CapSense_PUSH6__BTN
} ;
uint8_t touch_button_id[NUM_TOUCH_BUTTON] = {
CapSense_T1__BTN,
CapSense_T2__BTN,
CapSense_T3__BTN,
CapSense_T4__BTN,
CapSense_T5__BTN,
CapSense_T6__BTN,
CapSense_T7__BTN,
CapSense_T8__BTN,
CapSense_T9__BTN,
} ;
#if USE_UART
#define STR_LEN 64
char str[STR_LEN+1] ;
void print(char *str)
{
UART_UartPutString(str) ;
}
void cls(void)
{
print("\033c") ; /* reset */
CyDelay(20) ;
print("\033[2J") ; /* clear screen */
CyDelay(20) ;
}
void splash(void)
{
cls() ;
print("CapSense 15 buttons test ") ;
snprintf(str, STR_LEN, "(%s %s)\n", __DATE__, __TIME__) ;
print(str) ;
}
void dump_push_button(void)
{
int i ;
for (i = 0 ; i < NUM_PUSH_BUTTON ; i++ ) {
if (push_button) {
print("B") ;
} else {
print("-") ;
}
}
}
void dump_touch_button(void)
{
int i ;
for (i = 0 ; i < NUM_TOUCH_BUTTON ; i++ ) {
if (touch_button) {
print("T") ;
} else {
print("-") ;
}
}
}
void report(void)
{
dump_push_button() ;
dump_touch_button() ;
print("\n") ;
}
#endif
CY_ISR(tick_isr)
{
tick_count++ ;
if (tick_count >= 1000) {
pit_flag = 1 ;
tick_count = 0 ;
}
}
void init_hardware(void)
{
CyGlobalIntEnable;
CySysTickStart() ;
CySysTickSetCallback(0, tick_isr) ;
CapSense_Start() ;
#if USE_TUNER
SCB_Start() ;
CapSense_TunerStart() ;
#endif
#if USE_UART
UART_Start() ;
splash() ;
#endif
CapSense_InitializeAllBaselines() ;
CapSense_ScanEnabledWidgets() ;
}
uint16_t check_push_button(void)
{
uint16_t num_pushed = 0 ;
int i ;
for (i = 0 ; i < NUM_PUSH_BUTTON ; i++ ) {
if (CapSense_CheckIsWidgetActive(push_button_id)) {
push_button = 1 ;
num_pushed++ ;
} else {
push_button = 0 ;
}
}
return(num_pushed) ;
}
uint16_t check_touch_button(void)
{
uint16_t num_touched = 0 ;
int i ;
for (i = 0 ; i < NUM_TOUCH_BUTTON ; i++ ) {
if (CapSense_CheckIsWidgetActive(touch_button_id)) {
touch_button = 1 ;
num_touched++ ;
} else {
touch_button = 0 ;
}
}
return(num_touched) ;
}
int main(void)
{
init_hardware() ;
for(;;) {
if (!CapSense_IsBusy()) {
check_push_button() ;
check_touch_button() ;
#if USE_TUNER
CapSense_TunerComm() ;
#endif
CapSense_UpdateEnabledBaselines() ;
CapSense_ScanEnabledWidgets() ;
}
if (pit_flag) {
#if USE_UART
report() ;
#endif
pit_flag = 0 ;
}
}
}
===========================
TeraTerm log
If you define USE_TUNER 1 then you can start CapSense Tuner
CapSense Tuner
I hope this can be a little hint for you.
moto
P.S. I also read, type and speak Japanese 😉
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I learned how to use CapSense (v7.0) at
So attached is the version using CapSnse (v7.0) instead of CapSense CSD (v2.60).
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Motoo Tanaka様
返信ありがとうございました。
頂いたプロジェクト参考にさせていただきます。
また、DWRのpinsから設定できる物のうちNameの隣に黄色で表示されるものがあります。
そちらは、何か動作に支障をきたす場合がありますでしょうか。
例えば、読み取るのに時間がかかるなど。
Motoo Tanaka
Thank you for your reply.
I will use it as a reference for your project.
Some of the items that can be set from DWR pins are displayed in yellow next to Name.
Is there anything that might interfere with the operation?
For example, it takes time to read.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please refer to AN88619 PSoC 4 Hardware Design Considerations
Page 11
I think that the green ones are "dedicated" pins, so using green ones are preferable but yellow ones are also usable.
AN88619 というアプリケーションノートに PSoC 4 のハードウェア設計上の考慮点が記載されているのですが、
Page 11 8 GPIO Pins によると、コンポーネントには固定(Fixed)ピンと専用(Dedicated)ピンというのがあり
専用ピンはそのピンを使用した場合に一番良い性能が得られるという記載になっています。
見た場所はどこか覚えていないのですが、CapSense の場合、専用ピンを使用するとコンポーネントとピンの配線が最短になり浮遊容量も最小になる(=感度が良くなる)ので、なるべく専用ピンを使用するようにとの記載があった気がします。
しかし、実際にピンが足りないような場合には黄色のピンでも機能はします。
moto