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.

four pwm phase offset output with variable pwm frequency

Status
Not open for further replies.

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,807
Helped
1,810
Reputation
3,630
Reaction score
1,769
Trophy points
1,393
Location
USA
Activity points
58,934
I found a web site gives pwm generator with multiple phases output ,however it is supposed the pwm frequency is given , what should I modify the code so that any pwm frequency can input to the vhdl code ??

https://eewiki.net/pages/viewpage.action?pageId=20939345#PWMGenerator(VHDL)-PortDescriptions

I don't understand the question. A pwm frequency is not input into the design, a duty (cycle) and the clk (system clock) are used to determine the PWM frequency.

Maybe you want to change the period of the pwm pulses?

Code VHDL - [expand]
1
2
3
4
GENERIC(
       sys_clk         : INTEGER := 50_000_000; --system clock frequency in Hz
      pwm_freq        : INTEGER := 100_000;    --PWM switching frequency in Hz
      bits_resolution : INTEGER := 8;          --bits of resolution setting the duty cycle



The first three generics change that, by modifying the relationship between sys_clk and pwm_freq and the resolution of the duty cycle.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,300
Helped
14,233
Reputation
28,727
Reaction score
12,925
Trophy points
1,393
Location
Bochum, Germany
Activity points
279,672
It should work if you input the frequency as a period signal.
 

ads-ee

Super Moderator
Staff member
Joined
Sep 10, 2013
Messages
7,807
Helped
1,810
Reputation
3,630
Reaction score
1,769
Trophy points
1,393
Location
USA
Activity points
58,934
It should work if you input the frequency as a period signal.

The code already computes the PWM period.
Code:
CONSTANT  period     :  INTEGER := sys_clk/pwm_freq;   --number of clocks in one pwm period

So the OP doesn't have to modify any code to change it. They just need to set new values for the 3 generics to get the required resolution and period, based on their system clock.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,300
Helped
14,233
Reputation
28,727
Reaction score
12,925
Trophy points
1,393
Location
Bochum, Germany
Activity points
279,672
So the OP doesn't have to modify any code to change it. They just need to set new values for the 3 generics to get the required resolution and period, based on their system clock.
To make the period variable, it has to be changed from generic to signal, together with a respective width generic. Also a check for required minimal value may be suitable. But you don't need any structural changes of the design.
 

lgeorge123

Full Member level 2
Joined
Jun 13, 2004
Messages
131
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
Hong Kong
Activity points
1,415
With writing signal period : INTEGER := some constant , I can using this vhdl code to output any pwm frequency , thanks all of your help !!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top