1 2 3 Previous Next 35 Replies Latest reply on Nov 20, 2018 10:59 AM by JoSi_3317786 Go to original post
      • 15. Re: HELP, with example of frequency measurement Error

        There is an interesting video from Hendrik Lipka:

        a higher resolution frequency counter

        • 16. Re: HELP, with example of frequency measurement Error

          Good morning, everybody,

          The first thing to thank you for your help, the truth is that I am learning many things with you, thank you.


          odissey1: You have reason but simple and fast it will be to obtain a good and stable frequency for the Psoc with a crystal of quartz or with an oscillator like the one that you have me for the following test I have mounted a crystal of 32.768Khz in the pins 15.2 and 15.3 and a 24Mhz crystal with its two 22pf capacitors on pins 15.0 and 15.1 I have redirected the Master_Clk and Xtal_32Khz signals to their respective output pins I have measured them with the frequency meter and the 24Mhz gave exact and the clock 32.770Khz but it may be the fault of my meter which is not very precise .... Well what I mean is that it seems that the frequencies are fine.



          Evgeniy Pavlov: thank you very much for that example looks very good project, I had seen it on youtube but did not have the project, now I have modified it for the 5LP and tested it with the additions of the crystals as in the original project, but I have not been able to measure any frequency nor get any signal at the output of the DAC, the only thing I see is the image and I do not know why, I measured the main frequency of 24Mhz and 32.77Khz and are correct, proposals are accepted ....



          • 17. Re: HELP, with example of frequency measurement Error

            Let me remind you: this is an old project there is not in it    isr_xxx_StartEx(...)

            You will have to repeat the additions to the interrupt text for PSoC5 by copying from PSoC3 files

            isr_InputOverflow.c       CY_ISR(isr_InputOverflow_Interrupt)  {...here..}

            isr_RefOverflow.c         CY_ISR(isr_RefOverflow_Interrupt)    {...here..}

            isr_InputStop.c         CY_ISR(isr_InputStop_Interrupt)

            at the beginning of these files add:

            extern int status;

            • 18. Re: HELP, with example of frequency measurement Error

              As the author of that project: you need to be careful with the hardware project. This was written for PSoC5, not 5LP, and the 5LP (and newer versions of Creator) are more strict. You will get some warnings about timing / sync problems, so you need sync block at the right places.

              I should look into this and upload the current version of this, it seems to be a looked-after project.

              The '1001' in the output means 'STATUS_REF_OVERFLOW' which means 'input frequency too low'. So at least 'isr_RefOverflow.c' is still correct, and this event gets triggered.

              • 19. Re: HELP, with example of frequency measurement Error



                Evgeniy Pavlov: yes , if I believe that I have modified all the files of the interruptions as in the example.


                user_78878863: Thank you for your important help, I find a very interesting project by how you measure the frequency using reciprocal counter, here attached what I could modify of your project to make it work the truth is that the part that interests me is the frequency meter, all help will be well received do you know with what accuracy and resolucion works your project?

                You use two crystals one of 24Mhz and another one for the clock of 32.768Khz this last one I believe that you don't use it in the frequency meter, isn't it?



                • 20. Re: HELP, with example of frequency measurement Error

                  The precision of a reciprocal counter is: input_frequency / reference_counter_period. So for 1kHz, and a 16bit counter, its 1000/65536=0.015Hz.

                  The 32kHz crystal is only used for a test signal, its not needed for the counter as such 8IIRC). But when this crystal is missing you have no test signal.

                  • 21. Re: HELP, with example of frequency measurement Error

                    using the example that user_342122993 has uploaded and with the modification of the XTAL_24Mhz, that has suggested me odissey1 that is to say using an external crystal with two capacitors of 22pf and adjusting the oscillators of the Psoc I have obtained much more stability in the measure of frequency and a resolution of +-1Hz up to 6Khz what has improved much with respect to using it without external oscillator, the only thing is that I don't know how to show more precision in the measure so that I can show xxx.x with an accuarycy of +-0.2Hz


                    user_78878863ok, If I cut it in half, I get twice as much precision.?


                    Thanks you.

                    • 22. Re: HELP, with example of frequency measurement Error

                      What do you mean with "cut in half"?

                      For a reciprocal counter, the precision is always a percentage of the frequency (so the absolute value in Hz changes). To get higher precision, increase the period of the counters (counters with more bits)

                      For a gate-based frequency counter, its always a fixed value in Hz (but its ratio to the input frequency changes), and it depends. To increase the precision, make the gate time higher.

                      • 23. Re: HELP, with example of frequency measurement Error


                        I mean if 1000/65536 = 0.015Hz then 500/65536= 0.0076Hz?

                        Thanks you.

                        • 24. Re: HELP, with example of frequency measurement Error

                          Yes, thats what I meant to explain.

                          • 25. Re: HELP, with example of frequency measurement Error


                            I continue testing with the example of the frequency meter and now I have duplicated the circuit so that I can measure two independent frequencies "freq - rpm", and as you can see in the images exchanging the frequencies you can see that the second meter "rpm" is measuring wrong, and I see nothing wrong I tried with different priority and the same in the interruptions of the counters but without improvements, what I think is that the sprintf function and the printed output series are very slow and that makes the counter does not "count" correctly, I appreciate if you have any way to solve it.




                            • 26. Re: HELP, with example of frequency measurement Error

                              I added an updated project for the PSoC5LP to https://hendriklipka.de/hardware/freqcounter.html . It still targets the -050 kit, but it should be easy to target the -059 kit (or change the external reference clock to the internal one).

                              • 27. Re: HELP, with example of frequency measurement Error

                                Read the capture registers in the ISR. This should not actually make a difference (since the capture is a one-time event), but it might help. I had similar issues in the past where it seemed that the capture values changed afterwards.

                                (And if you do so, mark the variables holding the values as 'volatile')

                                • 28. Re: HELP, with example of frequency measurement Error


                                  Attached is demo project showing frequency measurement using custom 24-bit reciprocal counter. This is a draft version of component, provided as-is, no documentation, testing and debugging is required. To save resources design utilizes only one 24-bit Counter and a Timer. Frequency range as shown 8Hz - 12MHz, result accuracy ~10^6 in entire frequency range independent from polling time (limitations apply), which can be varied from 0.01 to 2.55 sec.


                                  Attached is a project with embedded component (FreqMeter). Project is build on CYKIT-059 board with external 24MHz XTAL oscillator attached. Project utilized additional custom components (DDS32 and QuadDec_SW) for test frequency generation, and KIT-059 library for annotation. These components are not required if external frequency source is available.



                                  P.S. Attached updated version (_02) and version with extra libraries stripped off (no signal generator).


                                  DDS32:  DDS24: 24-bit DDS arbitrary frequency generator component

                                  QuadDec_SW:  Quad Decoder with Button Switch component for rotary shaft encoders

                                  KIT-059:  Annotation library for CY8CKIT-059 Prototyping Kit


                                  Frequency meter_2x_1a.png

                                  Frequency meter_2x_5a.png

                                  Frequency meter_2x_4a.png

                                  Frequency meter_2x_4b.pngFrequency meter_2x_3a.png

                                  • 29. Re: HELP, with example of frequency measurement Error

                                    Hello user_78878863

                                    Thank you very much for devoting your time to spend your magnificent work to PSOC 5LP I have tested it and tell you that it works very well, but you need external signal generator for ijecto a frequency into a Ref_Clock pin, can i use a external crystal oscillator expl: 12Mhz and use Xtal frequency to input this pin? and REF_PERIOD is a 1/13000000.0 ? in ms seconds?, and thank you for your help, Thank you.


                                    Hello user_342122993

                                    I really have to say that I was impressed with your reciprocal frequency meter project and how well explained you have it, I have been able to test it right now, and it works well, plus the accuracy and resolution are excellent much better than I need, in short "excellent".

                                    The only problem I see is that if in freq1=400hz and I put a frequency lower than Freq2=600hz I see that the psoc does not give the data of Ferq1 until 15 or 20 Freq2 cycles, but if I keep Freq1 > Freq2 everything goes well, it is as if Freq2 had preference and that the priorities of the interruptions are at 7 all, maybe this is the reason?



                                    apart from this I am seeing the code FreqMeetr_1.c and I see that these at many levels above what I know of the Psoc .... which I am very happy to have people like you in this forum is a great help for beginners like me, just return to thank you for the time you are devoting to me, Thank you.



                                    I have a doubt, there is some function in Psoc to create a periodical task as for example to execute a function or to read a data of periodical form every x time without using hardware components and that is not blocking...