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.

HELP!! Control dc motor speed with PIC16F877a using hi-tech

Status
Not open for further replies.

jun86dia

Newbie level 5
Joined
Jun 2, 2008
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
here is my codes.Pls do try it .. and tell me where is the problem occured.
PROblem is whenever i input 1 to RB0, CCP1 able to generate pulse for 3 or 4 cycles only.then there isnt any pulse anymore.pls help..thankz in advance!

Code:
#include <htc.h>
#include <pic.h>
#include <stdio.h>
#include 	"delay.h"
#include <math.h>


void main(void)
{
	//initialisation
	TRISB = 0xff;
	TRISC = 0x00;
	PORTB = 0x00;
	PORTC = 0x00;


while(1)
{
	//PORTB0 = 1;
	T2CON = 0b00000100;
	CCP1CON = 0b00001100;
	PR2 = 255;
	
	

switch (PORTB)
{
case 0b00000001:{
CCPR1L = 127;

break;
}
default:
{
CCPR1L = 200;

break;
}
}
}
}
Code:
 

Re: HELP!! Control dc motor speed with PIC16F877a using hi-t

Hi jun86dia,
Are you sure that RB0 is continuously made high?
If not, then according to the code, the CCPR1L register value is changed and
thus you may not be getting the proper output.
Also you can remove the initializations (T2CON, CCP2CON,...) from the while loop. There is no need to initialize them always. You can do it once before entering the while loop.

Regards,
vhn
 

Re: HELP!! Control dc motor speed with PIC16F877a using hi-t

hey vhn,
well,it is continuously RB0 input is High.
from my code, if the RB0 input is high for certain period, thn by default the CPPR1L
will be 200.however, the output was LOW.
what do you think ?
Btw thankz for the info..i'll edit the while loop..=)

-jun-

Added after 3 minutes:

hey vhn,
thankz ... now it works .. after removing the initializations (T2CON, CCP2CON,...) from the while loop.
Appreciate your help =)

-jun-
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top