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.

PWM generating from PIC using mikroC !! help

Status
Not open for further replies.

thebenman

Newbie level 4
Newbie level 4
Joined
Mar 27, 2014
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
48
Hey,
I wanted to trigger mosfets using PWM from PIC 16F877A .The PWM is supposed to oscillate at 50Khz with the duty cycle of about 50 %.I want to draw four PWM signals from the PIC MCU that are apart from each other by 10 micro seconds.But i am unable to achieve the required duty cycle and frequency of operation.I am attaching the code below
Code:
void main() {

     TRISA = 0xFF;
     PORTA = 0x00;
     TRISB = 0x00;
     PORTB = 0x00;
     TRISC = 0x80;
     PORTC = 0x00;
     TRISD = 0x00;
     PORTD = 0x00;


     while(1) {

            PORTD = 0x0A;
          Delay_us(10);
            PORTD = 0x00;
          Delay_us(2);
            PORTD = 0x05;
          Delay_us(10);
            PORTD = 0x00;
          Delay_us(2);
     }
}
 

You should use CCP registers to generate PWM signals, bit banging isn't the greatest. The code you are showing appears to be setting the ports correctly for I/O. What is your delay structure or what compiler is this? What is the code outputting? How are you measuring it? How is the hardware setup?
 

Doesnt mikroC have a decent PWM library already built in?
Yes,i does have a CCP module ...but i am unable to obtain the desired output from that with the correct delay .I am attaching the schematic ..i basically want to drive the alternative mosfets with a delay of 10 micro seconds :)
 

Attachments

  • circuit.doc
    316 KB · Views: 106

I will look over the schematic shortly. One thing to keep in mind, rise and fall times of mosfets and the gate drivers. You are doing a time driven approach will you will have to keep in mind to not start the delay until the transistor is all the way on or off to avoid shoot through.

Schematic Notes:
1.) Your regulators have stabilizing capacitors right?
2.) Check the response time and delays of your optocouplers. Since this is a time based system this would affect your timing.
3.) Do the optocouplers support PWM (I assume it does) at the speed that you want?
4.) Did you probe your pin outputs to verify there is a real signal coming out?
5.) What is the current system operation? How is it working or not working?
 

I will look over the schematic shortly. One thing to keep in mind, rise and fall times of mosfets and the gate drivers. You are doing a time driven approach will you will have to keep in mind to not start the delay until the transistor is all the way on or off to avoid shoot through.

Schematic Notes:
1.) Your regulators have stabilizing capacitors right?
2.) Check the response time and delays of your optocouplers. Since this is a time based system this would affect your timing.
3.) Do the optocouplers support PWM (I assume it does) at the speed that you want?
4.) Did you probe your pin outputs to verify there is a real signal coming out?
5.) What is the current system operation? How is it working or not working?

The system is basically a voltage copier ,the circuits above subtracts the input voltages while the circuit above adds the input voltages .Yes the voltage regulators have caps connected .Yes the optocouplers does support PWM .When i measured using a CRO i did measure the pulses .The circuit works correctly at times but the MOSFET in the below circuit gets heated way too much.
 

My guess is that the heat means that the MOSFETs are running in linear mode (they don't have enough time/power to turn on and off all the way). How big are the gate limiting resistors for the mosfet? How much current can the gate's draw from the power supply? I would look at the rise and fall times to make sure that they are turning on and off all the way and do some calculations to make sure there is enough time for the gate to charge and discharge based on the switching frequency.
 

My guess is that the heat means that the MOSFETs are running in linear mode (they don't have enough time/power to turn on and off all the way). How big are the gate limiting resistors for the mosfet? How much current can the gate's draw from the power supply? I would look at the rise and fall times to make sure that they are turning on and off all the way and do some calculations to make sure there is enough time for the gate to charge and discharge based on the switching frequency.
I have connected a 1k resistor between the MOS Gate and the optocoupler and another 1k resistor between the PIC and optocoupler.I believe that the 1K resistor is a bit to high.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top