Frequency Counter, How to reduce UDB

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable
    Hi there,   
   
    I have implemented Frequency (RPM) measurement using ideas displayed on various thread by Dana. I have attached project. I have two issues now:   
   
        
   
    1.           I want to reduce the usage of UDB as I have four channels of RPM to be measured and many other function needs to implement. I think I will need extra space in UDB. How can I change Counter Block to fixed functions? I have tried it but it says :   
   
        
   
    Timer "\RPMCounter_1:CounterHW\" can only use one of the digital clock dividers or bus clock as the clock source.   
   
        
   
     2.       See in attached project I have used 12KHz clock to simulate RPM. I have connected external wire link from this RPM_Freq output (P0[6]) to RPMSig_1 input(P0[2]). For 12KHz it displays perfect values on LCD, but for 15KHz it displays ‘zero’ on LCD. If I try to give direct 15KHz on schematic page (as direct clock source internally in silicon, no external link). It perfectly displays Frequency and RPM. Do I missing something here? Will my development work when I connect actual RPM signal (0-50KHz)?   
0 Likes
8 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Some questions -

   

 

   

1) Given you want to measure 0 - 50 Khz (0 - 50 KRPM ?), what

   

resolution of the measurement do you want ?

   

2) Accuracy of measurement ?

   

3) Do you need to make 4 simultaneous measurments of RPM or could

   

you use a 4 channel mux and measure them sequentially ? If latter any

   

restrictions on latency of measurement ?

   

 

   

Regards, Dana.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Regarding the UDBs: you are using a 16-bit counter, which needs 2 UDBs AFAIR. Since all other components don't need to be duplicated,, this means you need 8 UDBs to count for 4 channels - and the PSoC5 has 24. So there should be room to spare.

   

For the routing error - the FF counter can just count clocks, it works that way (says even so in the data sheet).

   

Regarding your second question: The code is quite difficult to follow with all these states. Mayb reduce the RPM_Convert_Process function into a simple loop that waits until the counter has captured (FIFO not empty) and then calculates the resulting RPM directly. Having done that you can directly display the value on the LCD.

   

Even better: use an ISR to read the capture value which is triggered by a capture event.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Thank Dana and Hli for reply.

   

 

   

Dana, I think 16 Bits with 5Hz for Gate frequency will do the work for me and that is what I have tested with my application.

   

 

   

As of now 4 simultaneous measurement is required, so I will use separate counters and as hli said it will consume only 8 UDBs (I have tested with four 32 bit counters previously that is why I was out of UDB I think). But if four 16 bit counter will not serve purpose then I will definitely consider MUX.

   

 

   

Hli, for your confusion, sorry. Now I have taken bob’s example from this thread:

   

 

   

http://www.cypress.com/?app=forum&id=2232&rID=59444

   

 

   

and modified according to my Hardware.

   

 

   

Now see, schematic page “Measure”, I have made RPM_Out (P0[6]) and RPMSig_1 (P0[2]). I have made a wire link between this two pin on kit “CY8CKIT-050”. See on schematic page “Clocks”, Clock_3 = 15KHz. Now if I program kit, it shows 0 Hz on screen. Now if I connect direct wire on schematic page “Measure”, and delete the pins and program on kit it shows 15000 Hz.

   

 

   

Got it? Please help me with that. Thanks in advance

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

There is confusion regarding the function of HW connection on a pin, hopefully

   

this will illuminate why your schematic wired connection not working -

   

 

   

 

   

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Thanks Dana for the reply, and sorry for the confusing posts of mine. I think Hardware connection setting is fine. Here I am attaching a picture, hoping that it will make my issue clearer to you.

   

Case 1)

   

RPM frequency is generated 12 KHz, Routed to PIN P0[6], through a external wire(jumper) connected to PIN P0[2]. Result working fine

   

Case 2)

   

RPM frequency is generated 15 KHz, Routed to PIN P0[6], through a external wire(jumper) connected to PIN P0[2]. Result working not OK.

   

Case 3)

   

RPM frequency is generated 15 KHz, directly connected on schematic with Frequency Counter. Result working not OK.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You mentioned you wanted to minimize UDBs, this project measures PW as well

   

as period (therefore frequency) and uses a fixed function counter.

   

 

   

 

   

 

   

0 Likes
Anonymous
Not applicable

Thanks dana for the point. But I got confused. If you have some link or project related to that, I would request you to share it. Thanks again.

0 Likes
Anonymous
Not applicable

Hi

   

As I sees that the two issue I facing is different from one another so I think I should create second thread for second issue.

   

Here is the link for the second issue of "external link" problem.

   

 

   

http://www.cypress.com/?app=forum&id=2233&rID=108493

0 Likes