element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Smarter Life
  • Challenges & Projects
  • Design Challenges
  • Smarter Life
  • More
  • Cancel
Smarter Life
Documents PSoC4 Smarter Life Challenge - DAS Project :Example 3 LED Dimming (PWM based)
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: bose
  • Date Created: 4 Nov 2013 12:31 PM Date Created
  • Last Updated Last Updated: 17 Dec 2014 3:55 AM
  • Views 437 views
  • Likes 2 likes
  • Comments 1 comment
Related
Recommended

PSoC4 Smarter Life Challenge - DAS Project :Example 3 LED Dimming (PWM based)

This example show how to perform LED dimming using PWM module for Cypress PSoC 4 Pioneer Kit.

 

Here is the Application Schematics:

image

image

This example uses the PWM block in a timed configuration to produce the dimming effect on the LED.

 

The PWM module { PWM (TCPWM mode) [v1.0] }configuration is as shown below:

image

In the code one needs to vary the Compare factor for the PWM to generate a DC average output that would lead to dimming of the led.

Ideally a capacitor is needed to produce the DC averge but since the LED load is not significant, its possible to directly generate the dimming on the pin connected LED.

Here is the code for this example:

#include <project.h>
int main()
{
     uint32 i = 0; //Used as a Counter
     uint32 op = 0; //Used to define which operation is being currently performed : 0-additions 1-subtractions
     // Start the PWM generation
     PWM_1_Start();
     for(;;)
     {
          CyDelay(5); //Cycle Delay
          // Process the Counter Operation
          if(op == 0)
               i += 10;       
          else
               i -= 10;
          // Change the PWM duty cycle value as per the Counter
          PWM_1_WriteCompare(i);
          // Handle Counter overflow
          if(i>=1000)
          {
               op = 1; // Start Decrementing as max value has already reached
          }
          else if(i<=1)
          {
               op = 0; // Start Incrementing as Min value has already reached
               CyDelay(800); // Delay to keep the LED off for more time
          }
     }
}

 

After building and loading this code the Green LED on the Pioneer Kit would show the dimming effect.

Its important to note here that this dimming would show up some visible blink and may also cause EMI/EMC or RFI issues in case the output is used to control LED drivers.

The better solution would be use the PrISM module to generate precise dimming without flicker or emission issues.

  • psoc4
  • examples
  • smarter
  • das_project
  • smarter_life
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply
  • mcb1
    mcb1 over 10 years ago

    Nice clear instruction.

     

    Thanks for adding it. (not sure how i missed it earlier)

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube