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.

clock for stepper motor

Status
Not open for further replies.

Marc72

Newbie level 1
Newbie level 1
Joined
Apr 1, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,291
Hello

I m trying to turn my stepper motor with a pic16F877A + l297 + l298 with this code but what i get at PORTC.2 is the led blinking
and the motor is not turning so i affect the 4 output of the motor into some LED to see the signal but the 4 LED are taking the same signal like the clock,

thanks for your help

--------------------------------

void main()
{
unsigned char dc ;

TRISC = 0 ; // set PORTC as output
PORTC = 0 ; // clear PORTC

/*
* configure CCP module as 4000 Hz PWM output
*/
PR2 = 0x0F ; //7c
T2CON = 0b00000101 ;
CCP1CON = 0b00001100 ; //CCPR1L
CCP2CON = 0b00111100 ; // FF
PORTC.B1=1; //Enable
PORTC.B3=1; //CW




for(;;) // forever
{
/*
* PWM resolution is 10 bits
* don't use last 2 less significant bits CCPxCON,
* so only CCPRxL have to be touched to change duty cycle
*/
for(dc = 0 ; dc < 128 ; dc++)
{
CCPR1L = dc ;
CCPR2L = 128 - dc ;
Delay_ms(1) ;
}
for(dc = 127 ; dc > 0 ; dc--)
{
CCPR1L = dc ;
CCPR2L = 128 - dc ;
Delay_ms(1) ;
}
}
}
--------------------------------
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top