cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

New Contributor II

Hello, 

   

I am trying to increase the resolution of my Capsense Slider PWM project from 0-255 to 0-1024. The Capsense component is working correctly to the new set maximum centroid value(1024),  however my PWM output is being truncated at 255. Verfied on an oscilloscope, I cannot get anything more than 25% duty cycle. 

   

I have been messing around with it for hours and feel like I am just missing something silly. Would you be so kind as to look over my project. I have attached the workspace bundle. 

   

 

   

 

   

Thank you, 

   

Adam

0 Likes
Reply
3 Replies
Esteemed Contributor II

Welcome in the forum, Adam!

   

You compare the newPosition (which you forgot to declare in the function header as uint16) with CapSense_CENTROID_MAXIMUM which is a constant of 255. So you'll never exceed that value.

   

 

   

Happy coding

   

Bob

0 Likes
Reply
New Contributor II

Ok, got it, thank you Bob.

   

Modified section below. 

   

 

   

void handleSliderPositionUpdate(uint16 newPosition) {
    /*If finger is detected on the slider*/
    if((newPosition != CapSense_SLIDER_NO_TOUCH) && (newPosition <= CapSense_LINEARSLIDER0_X_RESOLUTION)) {
        /* Write slider position to PWM output compare register*/
        PWM_WriteCompare(sliderPos);
        bool pinStatus = (sliderPos >= 30) ? 1 : 0;
        Pin_ENABLE_Write(pinStatus);
    }
}

0 Likes
Reply
Esteemed Contributor II

Looks a lot better now 😉

   

 

   

Bob

0 Likes
Reply