5 Time Counters

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

cross mob
Anonymous
Not applicable

Hi

   

I have CY8CKIT PSoC 5LP KIT and I want to measure time between 6 signals that coming on 6 different pins.

   

First signal is TR. When TR happened (rising edge) 5 time counters start.

   

When MP1 happened (rising edge) first counter stop.

   

When MP2 happened (rising edge) counter 2 stop.

   

All same to MP5.

   

After 100 ms send 5 time values ( number in ms) to COM Port (RS232).

   

If I have 2 TR before MP that counter send message AAAAAAAA.

   

If MP don't happened 100 ms after TR that counter send message CCCCCCCC.

   

I am new to PSoC and don't have C code experience.

   

Can somebody help me with this?

   

Thanks

   

Val

0 Likes
10 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum and in the fascinating world of PSoCs!

   

We here usually do not solve your programming problems, you'll have to learn C-language for yourself.

   

Setting up a timer and following your given rules is not so difficult. A Counter has got the choice of a "Capture" that saves the current counted value, an enable input will ensure that counts occur only while that input is logic High.

   

When you get stuck you may post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file, we will have a look at and comment.



Bob
 

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Questions -

   

 

   

1) Range of time values you want to measure ?

   

2) Resolution of time values to be measured ?

   

3) Accuracy of time values to be measured.

   

 

   

The C required for this rather simple. Google "C Language Training" there are

   

many videos/courses you can take.

   

 

   

PSOC Creator training -

   

 

   

www.cypress.com/

   

 

   

    

   

         

   

 

   

C Book attached for reference.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Thanks

   

I will check files that you send.

   

As your questions go:

   

1. Each timer 100 mS MAX

   

2. Resolution 0.1 mS

   

3. Accuracy 0.1 mS

   

Thanks

   

again

   

Val

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

Something like this might do it -

   

 

   

   

 

   

TR enables them all to start counting. When MPn occurs a capture of that timer is made and an interrupt

   

occurs so you can save its value to its respective channel timer variable. When last timer event occurs

   

you reset all with control reg RestartAll and com out the results.

   

 

   

Regards, Dana.

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

You can also envision doing this with one timer. TR starts it, each time an MPn occurs

   

you do a capture/save and subtract the previous saved value captured to get the clocks

   

from MPn-1 to Mpn.

   

 

   

Just a thought.

0 Likes
Anonymous
Not applicable

Hi Dana

   

When I try to do what you send me, I can't.

   

How to make "Timer" like yours?

   

When I take "Timer" it's have only "clock" and "reset". Don't have "enable" and "capture" in "fix mode".

   

Thanks

   

Val

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

Double clcik component and config its properties -

   

 

   

   

 

   

Regards, Dana.

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

Hi

   

This is what I did so far.

   

I need to send each interupt to COM Port (RS232) and to reset after 300 mS.

   

I will try example of simple COM Port, but how to add each interupt to COM Port?

   

Thanks

   

Val

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

In the components catalog view there is a system folder,

   

in that is an ISR component.

   

 

   

You can create a C ISR for each ISR by doing the following -

   

 

   

    

   

          

   

http://www.cypress.com/?rID=38267     AN54460 - PSoC® 3, PSoC 4, and PSoC 5LP Interrupts

   

 

   

 

   

    

   

          

   

CY_ISR_PROTO(MyIntFunc);      // Prototype declaration

   

then

   

CY_ISR(MyIntFunc)                         // Interrupt function definition

   

{

   

// Place code here

   

}

   

 

   

In  initialization part of the program

   

 

   

isr_StartEX(MyIntFunc);               // Start Interrupt with my handler

   

 

   

CY_ISR-macro have a look into the "System Reference Guide" under Help -> Documentation..

   

 

   

Regards, Dana.

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

Keep in mind I showed you the brute force way of doing the design, using a timer

   

for each channel, but I do think 1 32 bit timer would do the job with successive

   

reads each time an event occurs. And subtracting prior reading to get event to

   

event counts.

   

 

   

In case you run out of HW resources.

   

 

   

Regards, Dana.

0 Likes