Discussion in "PIC Microcontroller Discussion" started by    Max    Oct 27, 2014.
Mon Oct 27 2014, 07:00 pm
#1
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 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.
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
Max

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

EdwardFew
Mon Mar 18 2024, 01:14 pm
EmeryPah
Mon Mar 18 2024, 11:51 am
RobertMax
Sun Mar 17 2024, 10:22 pm
DanielJar
Fri Mar 15 2024, 06:52 pm
Tuzaimecor
Fri Mar 15 2024, 02:32 am
PromotionFoode
Thu Mar 14 2024, 08:11 pm
EdwardGeawn
Sun Mar 10 2024, 12:24 pm
ZacharyShado
Sat Mar 09 2024, 10:04 am