2 Replies Latest reply on Mar 31, 2017 9:11 PM by esh1916_1917076

    PSoC 4 Vary PWM Duty Cycle

    esh1916_1917076

      Hello,

         

      I'm fairly new to Cypress products, and I'm trying to utilize the Cy8CKIT-0420-BLE Pioneer Kit for a project I'm working on. I have a few questions that might cut down my learning curve. I've looked into some forum posts already, but from what I've discovered so far, I'm not 100% satisfied I'm able to continue the project from where I currently am. I'm working on a wireless user interface in order to condition a PWM signal for a servo motor. The servo motor itself has its own controller which is definitely the simplest solution; however, it's out of my team's budget to try to use. Thankfully, the motor allows for a custom interface, as long as the input control signal meets a few specifications (voltage, frequency, etc. -- all met by the output capabilities of both the CY8C4247LQI-BL483 and CYBL10563-56LQXI devices).

         

      What I'm trying to accomplish:

         

      - 2 BLE devices:

         

      1) User-side - Uses a slide potentiometer connected to an ADC in order to control speed. BLE connection to Motor-side.

         

      2) Motor-side - Takes data from User-side and conditions the duty cycle of an output PWM signal in order to control motor speed.

         

       

         

      I'm not looking for a complete solution from someone, but rather I'm hoping to find some answers or advice on these questions:

         

      - Using PSoC Creator 4.0, I should be able to configure the input from the slide potentiometer to any ADC pin (assuming proper electrical specs and pin mappings -- obviously not inputting the signal into an LED pin -- are met), correct?

         

      - What method might be simplest to implement varying the duty cycle for the output PWM? I'm trying to have more resolution than the binary duty cycle states I seem to find with an oscilloscope for the 100 Projects in 100 Days project #47 Accelerometer Controlled Car: http://www.cypress.com/blog/100-projects-100-days/project-047-psoc-4-ble-accelerometer-controlled-car

         

      Any advice, suggestions, links to more relevant forums where these sort of questions have already been answered, or even critiques on forum etiquette here (this is my first post) would all be greatly appreciated!

         

       

         

      Thanks,

         

      Eric

        • 1. Re: PSoC 4 Vary PWM Duty Cycle
          user_1377889

          Welcome in the forum, Eric.

             

          You probably have got a PWM 1ms to 2 ms interface. There is a usual repetition rate of 20ms of that signal. So set the PWM period to 20ms and vary the PWM's compare value accordingly. Best practice is to update at TC in an interrupt handler.

             

          Your ADC setup thoughts are quite ok, You may trigger an ADC reading with a free-running timer or convert continuously.

             

          Some of the IO pins might be connected to bypass caps, look for that and don't use those. Look into your kit's schematic.

             

           

             

          Bob

          • 2. Re: PSoC 4 Vary PWM Duty Cycle
            esh1916_1917076

            Hello Bob,

               

             

               

            Thanks for the help on your first post! I've been able to demonstrate proof of concept on the use of a slide potentiometer to an ADC, varying the duty cycle of the PWM through the ISR, and I've even combined the two concepts, and I can watch the duty cycle change in real time on an oscillosocope while I fiddle with the slide potentiometer.

               

             

               

            All that's left for me now is to figure out how to "package" the values from the ADC and send it via BLE to the other microcontroller and "unpackage" that data. Still working through some of the examples that Cypress has provided, so I'm uncertain exactly what question I need to ask next to further my understanding.

               

             

               

            Thanks for your help so far!

               

            Eric