I decided to create a tutorial on various design strategies of reading multiple digital inputs (up to 16) and calculating each frequency.
Although intended to help students and those new to embedded processing, it can be used by anyone for the attached example projects and as a refresher.
I've attached a workspace with 8 projects each implementing different methods in different combinations. Each project is an improvement on the previous one.
Here are the different methods used:
I've also attached a document describing each of the 8 projects with:
The document includes Appendices about:
Requirements:
Target Hardware:
The example code is free to be used and modified for your own projects.
Enjoy!
Len
Hi Len,
Thank you for sharing your example project with the community.
Best regards,
Hari
Dear Len-san,
Nice Work!
It requires a lot of jumper wires (@ @)
Coincidentally, yesterday, my new 4ch oscilloscope which I ordered this week arrived.
So your project got to be the first signal(s) I viewed with my new oscilloscope 😉
Ch1: UART_TX
Ch2: Stim1 - PC_1
Ch3: Stim2 - PC_2
Ch4: Stim3 - PC_3
As PC3 (P3[2]) has a bypass cap attached on the CY8CKIT-059,
the slow edge of ch4 shows that both your project and my oscilloscope are working OK.
Best Regards,
13-Dec-2020
Motoo Tanaka
Motoo-san,
Thank you.
You are correct. You can connect as many inputs as you want.
If you want to reduce the external wires, 6 of the 8 projects have an additional schematic page that is currently disabled.
This disabled page internally routes the stimuli to the inputs without need of external connections.
To use the disabled page, you need to first disable the page with the pins. Next enable the 0 pins page. It will give some warnings. Answer "OK". Rebuild the project and ... viola! All the inputs will have stimuli. Although the input pins are eliminated, the stimuli is still routed to the output pins.
It appears you compiled Project#1 using Polling strategy. CPU utilization: Scan = 99%. Highly inaccurate results at higher frequency inputs.
Spoiler Alert: Projects #8 has the best performance. CPU utilization: DMA = 0.05% ISR=0.0% Task = 4.8% The application can have 95.1% CPU cycles available.
It also provided the best measurement performance even for high frequencies.
Len
Dear Len-san,
So, this morning I connected all 16 Stims to PC_1 ~ PC_16 and tried the #8 project.
Yes, the accuracy of higher frequencies seem to be much better now.
Best Regards,
14-Dec-2020
Motoo Tanaka