cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

andycheng
New Contributor II

Hello, we are making a device that would turn on for 30 seconds every 5 minutes, and detect if a subject left the seat.  The proximity example works great if the device is always on.  However, if the state is not changed (subject leave the seat, or sitting down) during the 30 seconds, nothing is detected since the baseline is set when it is turned on. 

Is there a way of setting the baseline manually?  I understand the baseline will change base on the environment, however, the huge change when the subject sits on the device or leaves the seat should be no problem. (hopefully) 

 

0 Likes
1 Solution
BragadeeshV
Moderator
Moderator

Hi @andycheng ,

When you say the device is turned ON for 30 seconds, do you mean that the device is powered off (VDD is cut) during the rest of the time? Therefore, if a person is already sitting on the seat when the device turned ON, the baseline is set with the person and seat and it can't detect if the person actually leaves the seat? Is my understanding correct?

If this is the issue, you can workaround this by storing the baseline value in the flash (such a EEPROM region) and every time the device comes out of reset, you can force this baseline to the actual baseline of the sensor by modifying the data structure directly. Please check the capsense_registermap.h that tells you the exact variable to modify.

BragadeeshV_1-1616087166058.png

Note: If Self Test library is enabled, then bslnInv (baseline Inverted) value should also be manually updated with ~bsln for proper operation.

 

 

Regards,
Bragadeesh

View solution in original post

0 Likes
4 Replies
BragadeeshV
Moderator
Moderator

Hi @andycheng ,

When you say the device is turned ON for 30 seconds, do you mean that the device is powered off (VDD is cut) during the rest of the time? Therefore, if a person is already sitting on the seat when the device turned ON, the baseline is set with the person and seat and it can't detect if the person actually leaves the seat? Is my understanding correct?

If this is the issue, you can workaround this by storing the baseline value in the flash (such a EEPROM region) and every time the device comes out of reset, you can force this baseline to the actual baseline of the sensor by modifying the data structure directly. Please check the capsense_registermap.h that tells you the exact variable to modify.

BragadeeshV_1-1616087166058.png

Note: If Self Test library is enabled, then bslnInv (baseline Inverted) value should also be manually updated with ~bsln for proper operation.

 

 

Regards,
Bragadeesh

View solution in original post

0 Likes
andycheng
New Contributor II

Hi Bragadeesh,

Thank you!!!! This seems to be the solution!  You've got what I want to do 100% correct. 

I couldn't find the parameters and later found out I was using CapSense_CSD instead.  Changed to use CapSense component and everything makes sense. 

Still figuring out why changing the BSLN value makes no differences in RAW count, figuring out.   

Thanks,

Andy

 

 

0 Likes
BragadeeshV
Moderator
Moderator

Hi @andycheng ,

Remember to turn OFF auto-calibration to avoid the raw counts from getting recalibrated every time the device comes out of reset. To detect the presence even after reset, the baseline should not be recalibrated again. To do this, first turn on auto-calibration and note down the IDAC gain, Mod IDAC and Comp IDAC values (use tuner GUI to see these values). Then, turn off auto calibration, force these values into the component and reprogram the device. This ensures that raw counts are not recalibrated.

Still figuring out why changing the BSLN value makes no differences in RAW count, figuring out.   

I'm not sure if I understand this. Why will the rawcounts change if you force baseline?

Raw counts is a digital form of the present sensor Cp and Baseline (software param) is the raw counts when there is not touch (or person). For example, when there is no person, rawcounts = 1000 and when a person sits the rawcounts = 1200. Here baseline is 1000. If the person is still there in the seat when the device comes out of reset, the raw counts would still be 1200 (since auto calibration is disabled, other wise it will go back to 1000 - assume 1000 is 85 % of maxcount).  Now, you have to read the baseline value from flash and force the new baseline value in the data structure, ie 1000.

You should also be aware of the maximum number of read / write cycles from the flash. Please check datasheet for details. Can you try to implement some low power mode such as deep sleep or hibernate to save power instead of cutting off the supply totally? 

Also, note that the baseline value has to be updated based on the environment conditions as well. You need to monitor the raw counts level and make a call if you have to perform a recalibration and store the new baseline value in the flash.

Regards,
Bragadeesh
0 Likes
andycheng
New Contributor II

Hi Bragadeesh,

 

Thank you again for your reply.  I think everything I described was due to a series of things I have done / not done.  I was actually playing around with too many settings at the same time, and this is why I had strange results.  I had the IDAC re-calibrate setting switched on, and also I changed the modulator clock frequency, modulator IDAC and the gain at the same time. 

I think instead of changing the baseline etc (which I confirm have no effect on the raw count) I would use the raw count instead.  I completely understand the raw count would be affected by the weather etc, but instead of sending out the yes/no data to the server wirelessly, I am going to send out the raw count instead.  This way I can actually see what kind of numbers most sensors would have when no one is around. 

You are completely right that I am also worrying about the read/write cycles.  Using the approach of sending out raw count seems to take the need for flash away.  Currently, my numbers would range from 0xa570 +- 0x80 (with a human body) to around 0x8000 +- 0x80 without a human on it, which seems to be a pretty good margin. 

Thank you for your help, I now understand the system much more.


Andy