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.

[SOLVED] dsPIC33 2 PWM generate with 180 phase angles with equal duty need help

Status
Not open for further replies.
Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

I know the Mc Pwm works,
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

Maybe a problem with mikroC PRO dsPIC standard PWM library or Proteus. I guess it it mikroC PRO dsPIC library problem. I tested but not getting signals in Proteus. Will test it in hardware for a different dsPIC33.
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

i know Mc Pwm library work.

- - - Updated - - -

ok, many many thank's for try & reply.......
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

It works. I made the code using mikroC PRO dsPIC library functions. You try it first then I will give you my code.

See attached Proteus Simulation and Simulation Video.

It is very easy.

Hint: PPS.
 

Attachments

  • dsPIC33 Complementary PWM.rar
    1.3 MB · Views: 107
  • std pwm.png
    std pwm.png
    108.3 KB · Views: 97
Last edited:
  • Like
Reactions: Garyl

    Garyl

    Points: 2
    Helpful Answer Positive Rating
Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

Sorry for late reply, i see your video. can you share the code?
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

Any body have any sample code for push pull pwm topology in dsPIC33FJ series?
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

Here is the code. I gave you the hint about PPS (Peripheral Pin Select).

Remappable pins have to be used for standard PWM.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
unsigned int current_duty = 0;
unsigned int pwm_period = 0;
 
void main() {
 
    ADPCFG = 0xFFFF;
    TRISA = 0x00;
    TRISB = 0x00;
    TRISC = 0x00;
 
    PORTA = 0x00;
    PORTB = 0x00;
    PORTC = 0x00;
 
    LATA = 0x00;
    LATB = 0x00;
    LATC = 0x00;
 
    Delay_ms(200);
 
    Unlock_IOLOCK();
        PPS_Mapping(2, _OUTPUT, _OC1);
        PPS_Mapping(3, _OUTPUT, _OC2);
    Lock_IOLOCK();
  
    pwm_period = PWM_Init(5000, 1, 1, 2);
    pwm_period = PWM_Init(5000, 2, 1, 3);
 
    PWM_Set_Duty(pwm_period / 2, 1);
    PWM_Set_Duty(pwm_period / 2, 2);
      
    PWM_Start(1);
    Delay_us(250);
    PWM_Start(2);
 
    while(1) {
 
          for(current_duty = 0; current_duty < pwm_period; current_duty++) {
              PWM_Set_Duty(current_duty, 1);
              PWM_Set_Duty(current_duty, 2);
              Delay_ms(10);
          }
    }
}

 
  • Like
Reactions: Garyl

    Garyl

    Points: 2
    Helpful Answer Positive Rating
Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

Many many thank's. I already test your code. but it's not generate pwm on pwm pin & how i use this pwm which code you share as 16 bit resolution?
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

You can see in the circuit of #24 that RB2 and RB3 pins are used for standard PWM after remapping the _OC1 and OC2 pins.
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

As I precariously disclose that I already test it. But found a problem that when I change the frequency, the duty cycle range is change, if I increase frequency, the duty cycle range is decrease & vise versa. So I just want to know from you that as we see in MikroC for PIC, between 500 to 50,000 frequency range the duty cycle range is same which I already test, I need this criteria in MikroC for dsPIC. Is there any way? Also another matter is I goto dsPIC for 16 bit resolution in pwm for better perfection.
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

PWM resolution will change based on PWM frequency. Datasheet provides the formula for calculating PWM resolution.

The PWM Initialize function returns the max PWM duty that you can have for a PWM frequency.

Even in PIC the duty resolution will depend upon PWM frequency.
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

I am really lucky because at least I found some knowledge from you, I have no education background about this subject, just have a long work experience, this all are doing for first of my hobby & secondly if I provide an income way to few people by developing some product. Again thanks. But is there any way to generate 50 kHz on 16 bit resolution?
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

Hi,

Calculate it:

16 bit resolution means 2^16 = 65536 steps.
65536 x 50kHz means 3,276,800,000 = about 3.3GHz
3GHz counter frequency.
I doubt you can do this.

Klaus
 

Re: dsPIC33 2 PWM generate with 180 phase angle with equal duty need help

Yes, very very sorry. I not calculate this way. Thanks again.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top