Here is my version of the quadrature decoder with a button switch custom component (QudDec_SW), which was designed for interfacing of rotary shaft encoders to PSoC4 and PSoC5. It has been created out of necessity to save hardware resources in projects with limited or exhausted UDB/PLD space. The stock PSoC5 QuadDec component with hardware debouncer are consuming three Datapath cells per single encoder, which is too much for a device which remains idle for most of the time.
The QuadDec_SW component is implemented entirely in software, without using any UDB resources. It is sufficient for hand-operated rotary shaft encoders for non-critical operations such as scrolling menu or updating parameters.
The QuadDec_SW component has several options
Returns position and direction of rotation.
Optional 8-bit, 16-bit, 32-bit, single or double position range.
Optional button switch with debouncing.
Optional increment step size.
Optional range limits.
Uses interrupt or polling technique.
Attached archive contains component library, several demo projects for PSoC5 and PSoC4, a component datasheet, Application Note and algorithm description paper. Please read installation instructions in the readme.txt. Since the Community Components forum is no longer exists, it is being posted here, PSoC5 forum, as the most relevant place to be.
The component provided as-is, no liabilities. It is free to use and modify.
YouTube demo: using QuadDec_SW with DDS24 signal generator
YouTube demo: using QuadDec_SW for PLL tune-up
P.S. In case if only buttons events (w/debouncing) are needed, another simple component is available (ButtonSw32)
Message was edited by: odissey1 Scroll down for v0.1 of the component.
Thank you, Bob.
Writing documentation actually helped with concept and debug, but ate
Sorry to say that Community Components forum is gone, being diluted into
the Software forum. I miss it a lot. There should be some repository for
custom code, please mention it to Cypress if you have a chance.
On Sep 20, 2017 1:09 AM, "user_1377889" <firstname.lastname@example.org>
This is awesome, and exactly what was was looking for, but I'm getting a couple of errors trying your interrupt example out on the PSOC 4200 BLE in the Notice List.
And here is what the component layout looks like:
The screenshots suggest that you opened and running library project instead
of demo. To run ISR demo, open encoder_isr_ex1.cywrk project.
See readme file for installation instructions. In short, unzip all files
provided in same folder. Check that unzipped folder structure is same as
shown in readme.txt.
On Oct 1, 2017 9:40 AM, "dturney_1462731" <email@example.com>
This is awesome! It makes many of the issues with Quad Encoders for this type of application MUCH easier.
I'm currently trying to use this in a project with a 4 Line LCD. It is working pretty well except that I get some "extra lines" of characters when the menu is scrolled down to the last menu item. Any hints on how to deal with this? i.e. The two actual LCD menu items are displayed on lines 0 and 1, so I'd like to blank out lines 2 and 3.
Many thanks for posting!!
In the char LCD demo, a 2x16 LCD was used for prototyping. For 4-row LCD, try to update LCD_menu.c:
//const uint8 NumRows = 2; // this is for 2x16 LCD:
const uint8 NumRows = 4; //
Thanks. I did try that, however, I still get some residual text in the bottom two lines.
I added an "LCD_ClearDisplay();" call after in the Update_Menu() function.... just before the "uint8 row;" line, which cleaned things up a bit... but I still get a few leftovers.
It still works very well to change menu items though... and it's way further along now than my first attempt.
I will take a look, but I have no 2004 (4x20) char LCD at hands to test the code.
Try to update next lines also,
const uint8 NumRows = 4; // this is for 4x20 LCD:
char buf; //LCD output buf
if (menu_idx>lcd_idx+3) lcd_idx=menu_idx-3; else // past bottom line, 3==(NumRows-1)
if (menu_idx<lcd_idx) lcd_idx=menu_idx; // above top line