Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Master - Slave PWM generation

Status
Not open for further replies.

Max.Otto11

Newbie level 6
Newbie level 6
Joined
Oct 13, 2014
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
180
Hello all,
As per my project requirment i want to generate 2-PWM Outputs.
PWM-1 (Master)start first than after sometime PWM-2(Slave) starts. How can i do this?

Regards
Max
 

Hi,

How can i do this?
use two pushbutton. Press the one, then after "sometimes" press the other.
AND your PWM signal with the pushbutton signal.


If you are not stisfied with my solution... provide more information.

Hardware, software, glue logic, ucontroller, CPLD, ASIC, FPGA???
what is "sometime"? n PWM cycles?, software controlled, fixed value of ms?

Klaus
 

Thanks klaus,

For that i have to give PWM period value from given input.

I have Analog Input from 0 to 3,3v. From ADC i get answer into uint16 ("ADC_Result" in code).

Now i want to divide this result to get PWM Period time.

if Input 0,2v then PWM_Period = 149...this value increses with upto 3,3 v.

Last value for PWM_Period = 479.

how can i do this?
Code:
uint16 ADC_Max=65535;
uint16 ADC_Min=0;

uint16 ADC_Result1;
uint16 Period1;

int main()
{       
	int32 ADC_Result;
	float Comp_Val; //,CMP;
	
         // Start the components 
	Sys_Init(); 	
	
    while(1)
    {			
		ADC_DelSig_StartConvert();  // Start the ADC conversion
		
        if(ADC_DelSig_IsEndConversion(ADC_DelSig_RETURN_STATUS)) // Check ADC EOC flag
        {
            ADC_Result = ADC_DelSig_GetResult32(); // Get Result
			
			// Limit the result to 0..65535
			if(ADC_Result < ADC_Min)	 ADC_Result = 0;	
			if(ADC_Result > ADC_Max)	    ADC_Result = 65535;
			
			// Display ADC result in mVolts on LCD
			ADC_Result1 =  ADC_DelSig_CountsTo_mVolts((uint16)ADC_Result);
			
                                          LCD_Position(1u, 0u);				
			LCD_PrintDecUint16(ADC_Result1); 
			CyDelay(1000);	
			
			
			if (ADC_Result >= 206)
				Period1 = 149; // like this
			
				
        }
    }
}
 

Hi

if understand right:
* 0...0.2V input = 0..3972 ADC_result: PWM OFF
* 0.2V ... 3.3V input = 3973...65535: PWM 149...479

I´m not familiar with C...
If ADC_result < 3972 switch PWM OFF, goto END
else {
# (now you get values 0...61563)
# this represents PWM values of 149...479 (difference = 330)
# 330/61563 = 0.00536
multiply with 0.00536 (to get values 0..330)
add 149 (to get 149...479)
set PWM }

:END

*******
Instead of subtract and then add, you can optimize mathematics

Klaus
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top