10 Replies Latest reply on Jul 1, 2015 9:38 AM by user_14586677

    5 Time Counters

    val.ojda

      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

        • 1. Re: 5 Time Counters
          user_1377889

          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
           

          • 2. Re: 5 Time Counters
            user_14586677

            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.

            • 3. Re: 5 Time Counters
              val.ojda

              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

              • 4. Re: 5 Time Counters
                user_14586677

                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.

                • 5. Re: 5 Time Counters
                  user_14586677

                  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.

                  • 6. Re: 5 Time Counters
                    val.ojda

                    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

                    • 7. Re: 5 Time Counters
                      user_14586677

                      Double clcik component and config its properties -

                         

                       

                         

                       

                         

                       

                         

                      Regards, Dana.

                      • 8. Re: 5 Time Counters
                        val.ojda

                        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

                        • 9. Re: 5 Time Counters
                          user_14586677

                          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.

                          • 10. Re: 5 Time Counters
                            user_14586677

                            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.