Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Speed Control Of Dc Motor

Status
Not open for further replies.
nelson_kh said:
yaya i use RC2 wrong type last time!!! but the motor still not turning! Y? i use PIC simulate to test and see the RC2 some time on sometime off!! how come.... it should keep 'on' to turn the motor!!

Is there any way you can monitor the output on RC2, eg oscilloscope? The output on RC2 should not be on all the time. It's pulses. So what you saw on PIC simulator may be what you suppose to see.

I think your seting is 2 Khz, 50% duty cycle pulses?
If you can confirm (with oscilloscope may be) there are pulses with 500uS period ( 2 Khz), 250uS on and 250uS off (50 % duty cycle) on RC2. then you know your program is working.

May be your setup on the motor driver is incorrect? May be the motor draws too much current? You have to isolate which part is not working.
Hope this helps.
 
ya i using a software call PIC simulator that can see the output and set the input to the PIC!!ya i get the RC2 on and off so it is correct!! but when i test to the motor driver and the motor, the motor not turning!! i think is my board problem!!
 
because you already set the output of RC2 to PWM mode at the beginning, so you will see it sometime is on and sometime is off. i think is your main broad got problem, design problem. you should fully understand how your motor driver circuit function and which pin you are chosing. Direct copy without understand is not a process of study.
since you are using the 20Mhz crystal, so in calculation the time will different. the duty cycle and the period is most important part in PWM. If setting is wrong, your motor ofcause cannot function and control speed.
 
antkids said:
because you already set the output of RC2 to PWM mode at the beginning, so you will see it sometime is on and sometime is off. i think is your main broad got problem, design problem. you should fully understand how your motor driver circuit function and which pin you are chosing. Direct copy without understand is not a process of study.
since you are using the 20Mhz crystal, so in calculation the time will different. the duty cycle and the period is most important part in PWM. If setting is wrong, your motor ofcause cannot function and control speed.

Ya i count the PWM, duty cycle,CCPR1L, and the period as well!!! i know which pin that i am using!! For the motor driver or h-bridge all is almost the same. Can find at anywebsite. Anyway thz 4 reply and i got 1 question do anyone know wat is the different of 2k pulse and 4k pulse that use to count the PR2?? What will effeted??
 
Wingmax i success control the speed and the direction alr!!! THZ alot!!! from the code below i cjust change the CCPR2L to max or min then can change the speed ler!!! but i still not understand wat the pulse for!! exp 4K pulse and 2K pulse!!! hope to hear from u!! thz!!

here is the code!!

#include <pic.h>
__CONFIG(WDTDIS & XT & UNPROTECT & BORDIS & LVPDIS);
#define XTAL 20000000 //crystal frequency- 20MHz
void setup ()
{
TRISB = 0xFF;
TRISC = 0x00;
PORTC = 0x00;
CCPR2L = 0x00;
CCP2CON = 0b00011100;
T2CON = 0b01111111;
PR2 = 0x9C;
}



void main ()
{
setup ();
if (RB7==1)
{
PORTC = 0b00010000;
CCPR2L = 0xff;
}
else
{
PORTC = 0b00100000;
CCPR2L = 0xff;
}
}
 
nelson_kh said:
Wingmax i success control the speed and the direction alr!!! THZ alot!!! from the code below i cjust change the CCPR2L to max or min then can change the speed ler!!! but i still not understand wat the pulse for!! exp 4K pulse and 2K pulse!!! hope to hear from u!! thz!!

here is the code!!

#include <pic.h>
__CONFIG(WDTDIS & XT & UNPROTECT & BORDIS & LVPDIS);
#define XTAL 20000000 //crystal frequency- 20MHz
void setup ()
{
TRISB = 0xFF;
TRISC = 0x00;
PORTC = 0x00;
CCPR2L = 0x00;
CCP2CON = 0b00011100;
T2CON = 0b01111111;
PR2 = 0x9C;
}

}

The pulses are for driving the motor.
CCPR2L is to set the duty cycle of the pulse, ie the pulse width. That's what's adjusting the speed. So what you did is adjusting the speed of min to max.
We normally choose a suitable frequency of the pulses for the motor so that it's not making annoying noise, or causing erratic function of the motor. We keep this frequency constant and adjust the motor speed by varying the pulse width of the pulses.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top