PSoC 16-Bit PWM generation C Language

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
        Hi all , i am working with PSoC 5LP. I have continious changable Analog Signals. I convert it to Digital with help of ADC. From this Result i want to generate PWM (Output1 Forwards, Output2 Ruckwards). All in 16-Bits. So i have range upto 65536. I have Analog Input 0,1 to 3,3v. So if i gave Input 1,6v than i have 50% Duty Cycle of generated PWM. PWM Basic Configuration: 16-Bit UDB PWM Mode: Two Outputs Period: 65535 CMP Value1: 32767 CMP Value2: 32676 CMP Type 1: Less CMP Type 2: Greater Dead Band: Disable Interrupt: None Clock with 12MHz freq. Here is the code. In ADC_Result i have 12-bit ADC result. From this result i want to generate 2 PWM Outputs. I know that i have to use WritePeriod(), WriteCompare(), WriteDeadtime() APIs. Code: int32 ADC_Result; uint16 i=0; int pwmValue, pulseWidth; int main() { // Start the components Sys_Init(); // CyGlobalIntEnable; // Uncomment this line to enable global interrupts. // Start Clock & PWM Clock_Start(); PWM_Start(); while(1) { pwmValue = ADC_Result // Which equation i have to use. PWM_WritePeriod(pwmValue); PWM_WriteCompare1(); } } I read the PWM datasheet & also check the Example PWM Programms but still i am much confsed for this following questions. 1. Need i Dead Band? 2. Which equation for converting ADC result into PWM? 3. Need i Interrupt/Global Interrupt ? Regards Shveta   
0 Likes
127 Replies
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable
        @Dana I try to Change the period value. PLs check my attached Project.   
0 Likes
Anonymous
Not applicable
        @Dana Give me ur Skype id. & tell me @ which time can me talk?   
0 Likes
Anonymous
Not applicable
        @Dana give me ur Skype id.   
0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I am going to suggest you start a new post with the following -

   

 

   

1) Detailed specs

   

2) Drawing of overall application, by block or schematic, what you are driving externally

   

3) All relationships, eg. expected waveform vs V, described in math

   

4) Detailed timing diagram of desired waveforms

   

 

   

Get a set of fresh eyes, better than mine, to take a look at your needs.

   

 

   

Regards, Dana

0 Likes
Anonymous
Not applicable

@shveta

   
    It would be better to give the complete specification/requirement of your whole project, as the solution of one part would need to change if that is not applicable with other parts that people don’t know. So it is basically going in circles.   
   
    However, it should also be noted that people here are willing to HELP you and point you the direction/approach to solve your problem, not to SOLVE the problem for you. And I remember that in another forum, a teacher found that the student is asking people to fix the program and gave a warning to the student.   
0 Likes
Anonymous
Not applicable
        @Dana I want to generate 1 PWM Signal with deadtime Input (A/D channel). PWM Clock freq. = 25 MHz Deadtime Value = 2 to 24 (0.5v to 3.25v) I am bit confuse that how can i get Ton & Toff, cloc k freq. How can i do this? pls help me.   
0 Likes
Anonymous
Not applicable
        @Dana My Project is for implementing H-Bridge MOSFET.   
0 Likes
Anonymous
Not applicable
        @Dana It was my mistake. Accually i Need only deadtime value as Input with vary Duty cycle, nothing is fixed. Now can upls help me for doing this. Regards Shveta   
0 Likes