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.

PIC 100% PWM Duty Cycle Problem in MikroC

Status
Not open for further replies.

M.Rehan

Full Member level 2
Joined
Feb 10, 2016
Messages
129
Helped
2
Reputation
66
Reaction score
33
Trophy points
28
Activity points
972
At 100% duty Cycle PIC is not giving always high signal
Why?

How to get rid of this fault?

Can I edit default existing PWM library in MikroC?

PIC Used : 18f4550
Tool: MikroC Pro for PIC


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void main() 
{
   TRISC = 0 ;     // set PORTC as output
   PORTC = 0 ;
   PWM2_Init(1000);
   PWM2_Set_Duty(200);
  while(1)
  {
     PWM2_Start();
     Delay_ms (1000);
     PWM2_Set_Duty(255);   // 100% Duty Cycle
     Delay_ms (10000);
   }
}





Capture.PNG


Capture1.PNG
 
Last edited:

Hi,

it may be that 100% is not possible with the setup.

0 = 0/256 duty cycle
1 = 1/256 duty cycle
...
255 = 255/256 duty cycle

Klaus
 

Hi,

they say: (percent x 255) * 100

and they say
0 = 0% (obviously)
127 = 50% (if so, then 254 should be 100%, or 50% should be (exactely: 127.50) they rounded down to 127)
192 = 75% (is so, then 256 should be 100%, or 75% should be (exactely: 191.25) they now rounded up to 192)

You see their informations are not consistent.

****
I know two cases:
* 0 to 255 means 0/256 to 255/256 duty cycle (0 % duty cycle possible. 100% not possible)
* 0 to 255 means 1/256 to 256/256 duty cycle (0 % duty cycle not possible. 100% possible)

Klaus

- - - Updated - - -

Added:
btw: if you want to drive a half bridge or full bridge N-CH power stage with bootstrap supply, then a 100% duty cycle is not allowed.
So it´s good to have 255/256 duty cycle.

Klaus
 
  • Like
Reactions: M.Rehan

    M.Rehan

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top