8 Replies Latest reply on Jul 31, 2018 2:18 AM by ring

    PWM Setup Application Notes

    scott_2272156

      Are there there any application notes or other documentation explaining in more detail how to set up a PWM with right clock and other parameters to make for example a  accurate as possible 2.6MHz output from the PWM.  I searched the community and did not find any thing of this detail.  I know there are 8 bit and 16 bit resolutions on counts of 255 or 65535.  I also understand how the compare values relate to duty cycle.  Yet how does this all relate to prescalers and frequency.  One PWM has a prescaler the other does not ... anyway i would sure like to understand this better so i can make a 2.6MHz output from my PWM.

       

      Scott

        • 1. Re: PWM Setup Application Notes
          odissey1

          Scott,

          I will look into it in the afternoon.

          1. What board kit / processor do you have?

          2. What application of this 2.6MHz PWM? Do you need just a 2.6MHz clock without variable duty cycle?

          3. Can you afford a small jitter?

          /odissey1

          • 2. Re: PWM Setup Application Notes
            odissey1

            Scott,

            Attached is demo project showing 2.598 MHz PWM output. Project tested using KIT-042 (Pioneer board). Notice Clock_1 settings and that its actual output is non-periodic (fractional). The PWM is surprisingly stable, no jitter observed. Though with period of 8 there is not much PWM duty cycle adjustment.

            The second page of the project (disabled) shows example of direct output of the 2.600 MHz to the output pin (no PWM). Average frequency accuracy is better than with PWM, but output is jitiery.

            /odissey1

             

            PWM_2.6MHz_1a.png

            Clock_1_settings.png

            PWM_settings_1a.png

            PWM and clock_1 output.jpg

            • 3. Re: PWM Setup Application Notes
              scott_2272156

              My application is to make OOK communication signal for a project i am working on.  I want to send a 2.6MHz carrier signal and then use a trisate buffer to interupte the signal with a 38400 bps data signal.  This is the first time i have done this, but i believe the 2.6MHz signal can be a bit jittery and does not need to be to accurate.  I am a PSoC and C rookie so please for give me for all my questions.  I sure appreciate the help in learning though and love PSoC product.

               

              Scott

              • 4. Re: PWM Setup Application Notes
                scott_2272156

                I failed to tell you i am using a CY8CKIT-042 (Pioneer) and also CY8CKIT-043 (Prototype) to test my data system on.  Thank you for the examples I will test both of them and report back to let you know how i did.

                 

                FYI that CY8CKIT-043 is really cool, i just appreciate how it is so easy to get every pin!

                 

                Thanks

                Scott

                • 5. Re: PWM Setup Application Notes
                  scott_2272156

                  I tried as you suggested and i do see a bit of jitter on my scope of the 2.6Mhz signal.  Below is a shot of the setup i tried on my CY8CKIT-042.  The only problem i see is the output on my Buss pin out of the Tri-sate bufffer does not go low all the time when it should.  I attached a shot of my Scope showing the Carrier output and the Buss line.  The TX line is sending two bits of data and when the TX input goes low the Buss should also be low and it randomly switches.  I dont know if this is because the Carrier output is a bit jittery or maybe i am no using the Tri-State Buff right.  Anyway any thoughts for me?

                   

                   

                  • 6. Re: PWM Setup Application Notes
                    odissey1

                    Scott,

                    From the picture, I believe that the buffer and PWM clocks are not synchronized, so buffer kinda takes a "snapshot" of the last PWM state, which is random. Also it seems that the output pin is not loaded and slowly discharges (buffer in Hi-Z). One possible solution is to use AND gate instead of the buffer (and output pin in Strong Drive mode).

                     

                    Carrier stability usually is important factor for receiver S/N. It is my guess that you don't really need a PWM, but some stable clock. I will think about that. If you have time, can you elaborate:

                     

                    1). Why specific 2.6MHz carrier, e.g. 2.4MHz will show no jitter (2.4MHz = 48MHz / 20)? Is this related to UART frequency, e.g. 38.4kHz x 68 = 2.611 MHz?

                     

                    2). Jitter. Did you run my project on your board? Does it show a jitter? (I don't see it).

                     

                    /odissey1

                    • 7. Re: PWM Setup Application Notes
                      scott_2272156

                      You are right I do not need a PWM to modifying duty cycle.  I chose a PWM because thats what i started with ... poor choice.  I am very new to this PWM and Timer applications in a micro-controllers.  As far as 2.6MHz vs 2.4MHz is not an issue.  I modeled my circuit in LTspice with a 2.6MHz carrier with a 32KHz data rate.  I can easily adjust my demodulation components to 2.4Mhz.   I  just need to make sure when the TX line goes low the carrier signal is deactivated properly each time and not random so my data will be accurate.

                       

                      When you say use an AND gate do mean on the output of my Tri-State buffer?

                       

                      Ans 1> So i missed the detail about sync of the UART and the Carrier.  I wanted to be able to send my Buss data back to the RX of a UART so i could see and trouble shoot on my PC. I just changed my UART to 38.4kHz from 32kHz without really understanding the implications. In my case I would like to run a standard UART output of 38.4KHz so i can use Tera Term or the like to review my data to see if my Buss is working properly in my product.  Do i need to use a UART and Timer with the same clock to do this properly?

                       

                      So i should run the Carrier at 2.611MHz?  Why do you multiply 38.4kHz by 68 to come up with 2.611Mhz?  Confused by this?

                       

                      Ans 2> Yes i did .... and i did see a fair amount of jitter ... I also saw the same in my attempt.

                       

                      Thank again

                      Scott

                      • 8. Re: PWM Setup Application Notes
                        ring

                        After running the scott't project, I also don't get any jitter.

                        Can you attached the jitter screenshot ?