2 Replies Latest reply on Jan 9, 2019 5:02 PM by kathc_1245071

    how to read a PWM signal into a PSoC 4245

      I am trying to read a 1kHz PWM signal into the PSoC 4 and depending on the duty cycle I want to change state on two pins. (for now)

      On the PSoC 5 Discussion I found a thread that seems to come close to that I wanted to do so I took the posted project and tried to port it to work with the PSoC 4.

      Original thread.

      PWM measurement

       

      I was able to modify the project that it satisfies the compiler and does not throw any errors, however I am missing something as it appears the counter is not counting.

       

      I had to modify the design to use a UDP counter as FF is not supported. Also I had some trouble connecting a 100kHz clock directly to the count input, the compiler insisted I can not do that. Not sure why. So I added the DFF to satisfy the compiler.

       

      When debugging with break points in the interrupt code, I can see the code is executed but the values from the counter seem constant.

      counter settings.

      counter settings.bmp

       

      schematic.bmp

        • 1. Re: how to read a PWM signal into a PSoC 4245
          MoTa_728816

          Hi

          To challenge this, I wrote a couple of programs

          (1) PWM generator for CY8CKIT-044 (CY8C4247AZI-M485)

          Read compare value (0~999) from UART and generate 1kHz PWM with the compare value as duty.

          002-pwm_gen_sch.JPG

           

          (2) PWM measure for CY8CKIT-042 (CY8C4245AXI-483)

          Sample PWM pulse with 10kHz clock and show the count/duty on UART

          as well as when count is less than 1000 (10%?) light LED_B (Pin_1)

          if count is greater than 9000 (90%?) light LED_R (Pin_2)

          003-pwm_measure_sch.JPG

           

          After connecting two boards using GND and D3 pin (PWM_OUT and PWM_IN) I started (1) then (2).

          (1) starts with 500/1000 (~= 50%) then I entered 100, 950, 500, 100, each a few seconds appart

          000-pwm_gen.JPG

           

          The pwm measure (2) reported

           

          001-pwm_measure.JPG

           

          Since both boards are running asynchronously, the values are not exact, but IMHO reasonably close.

           

          moto

          • 2. Re: how to read a PWM signal into a PSoC 4245

            Hi,

             

            Thanks for offering some help, very much appreciated.

             

            Eventually I found my problem after sleeping over it. Turns out I had had a wrong counter setting and I had to include a Sync Element to sort out some random glitches. Now all good working great,