- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks a lot better now 😉
Bob