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.

16f877a CCP (PWM) issue

Status
Not open for further replies.

sysysy

Member level 3
Joined
Nov 11, 2010
Messages
56
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Activity points
1,801
From the datasheet,

There are 2 ccp which are ccp1 and ccp2 multiplexed with pin C1 and C2.

May i know if we generate PWM from that and use it for in other pin such as portB pin? If not, that mean only PWM that we can use?

*(I am doing dc motor project now, taught to use PWM to control variety motor speed)

Thanks.


Regards,

sysysy
 

The PWM comes out on pins RC1 and RC2.
You can't change that.
PortB pins have other functions.
 
  • Like
Reactions: Porte

    Porte

    Points: 2
    Helpful Answer Positive Rating
May i know if i wanna use more than 2 pwm, then what should i do?
 

HI friend

If you want to use mote than 2 pwm,
Then i suggest you PIC18F4431 Microcontroller,
I have use this controller since last three year.

It has
==> Two Capture/Compare/PWM (CCP) modules:
==> Up to 8 Channel POWER CONTROL PWM MODULE:

Its Application like:
• Three-phase and Single-phase AC Induction Motors
• Switched Reluctance Motors
• Brushless DC (BLDC) Motors
• Uninterruptible Power Supplies (UPS)
• Multiple DC Brush Motors

Hope this is help you.
Shyam
INDIA
 
  • Like
Reactions: sysysy

    sysysy

    Points: 2
    Helpful Answer Positive Rating
no actually you can do PWM at any port you want..I use PROTON IDE...BASIC language..i can use any port to be PWM port..
 

Hi,
You can use the CCP module's PWM function only for the assigned pins, ie, CCP1 and CCP2 and on no other pin. If you use compare module and set up the PWM yourself, you can use it for any pin. Same goes if you use software PWM.
However, remember using the CCP module's PWM function you can only use the assigned pins.
Okay, as for more than 2 PWMs, it depends. If you have only 1 time base and many duty cycles, then it's very easy. However, if you need PWM at different frequencies, things get tricky. You can use the PIC stated above. If you can use AVR, then try with ATMEGA48 which has 6 PWM ie 3 timers with 2 compare on each.
You can also use coding to make use of the different timers and make your own time base and frequency, although this can be slightly touch and confusing, eg. reloading the timers every interrupt and constantly changing compare match values, etc.

Hope this helps.
Tahmid.
 
DC motor + L298

Hi, thx for u all for the suggestion.

Actually, i learn the PWM becoz i wanna control the motor speed.
Today i juz construct my DC motor and the driver( L298 ), but i my motor not working,

From the datasheet,
it say that juz make the h-bridge ( l298 ) enable pin high, make 1 input pin high and 1 input pin low, then the motor will run.

But it does not work, my question is can i juz simply set this in my program to make it run?

Code:
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)

#include "LCD.C"

void main() 
{

   lcd_init();
   lcd_putc("\fMotor Testing");
      
   output_high(PIN_A2);    //Enable pin
   output_high(PIN_A0);    //input_1
   output_low(PIN_A1);     //input_2       

   while(1);

}

Or any suggestion? sorry, i am really new to all of this.

thanks alot. :)

regards,

sysysy
 

Hi,
You haven't set the direction of pins A2, A0 and A1. You also have to make them digital.

Code:
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)

#include "LCD.C"

void main() 
{

   lcd_init();
   lcd_putc("\fMotor Testing");
   PORTA = 0; //Clear whatever's in PORTA by default
   ADCON1 = 7;   //Disable ADC
   TRISA = 0; //Make PORTA output
      
   output_high(PIN_A2);    //Enable pin
   output_high(PIN_A0);    //input_1
   output_low(PIN_A1);     //input_2       

   while(1);

}

Hope this helps.
Tahmid.
 

Thanks for the reply.

In order to test with program the PIC,

may i know can i direct connect the enable pin and 1 of the input pin to the 5V vdd and another input to ground?
Does this logic same with the logic that what i do inside my program? set high and set low?

becoz so far i wish to know is it my hardware( h-bridge ic and motor) work or not since i not familiar with software control yet.
hope this work and allow me can proceed to my software control part.
 

Thanks for the reply.

In order to test with program the PIC,

may i know can i direct connect the enable pin and 1 of the input pin to the 5V vdd and another input to ground?
Does this logic same with the logic that what i do inside my program? set high and set low?

becoz so far i wish to know is it my hardware( h-bridge ic and motor) work or not since i not familiar with software control yet.
hope this work and allow me can proceed to my software control part.

I really didn't get what you meant, but it would certainly help if you can upload the schematic so that we see if there's a hardware problem.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top