is it possible to use PIC16F877 to control various speed of the motor? If possible, can you show me how to use c programming to configure in such a way.
There are different types of motor, a DC motor and AC motor. In digital electronics we don't ussually use of AC motor. what we use is the DC motor. In DC motor there is only 2 polarity like what you showed in the picture, of course the polarity of DC motor is North and South. The Red and Black of the wire of what you showed is the wire connected to the armature.
/****************************************************************
The variable timer_value holds the count between two consecutive timer interrupts.
This is the desired time (sec) between interrupts divided by
the time period of each timer count.
E.g. in this program, TIMER1 is configured so that each count = 1.6 uS,
so timer_value of 60000 will give an interrupt period of 96 mS.
****************************************************************/
//int timer_value=0xEA60; //decimal 60000.
/**********************************************************************
Declare functions to be used in the main program, i.e.
void DelayUs(int count)
void initialize_IO_ports(void)
void wait()
**********************************************************************/
//Put the body of all these functions here, before isr() and main().
void DelayUs(int count)
{
int i;
int j;
for(i=0;i<count;i++)
{
for(j=0;j<5000000;j++);
//This for loop has 5 NOPs & wastes 1 uS for our PIC clock frequency of 20MHz.
}
}
void wait()
{
char i;
for(i=0;i<100;i++)
{
RD1 = 0;
DelayUs(100);
}
}
void initialize_IO_ports(void)
{
//set the digital IO ports as per requirement.
TRISB = 0xFF ; //portB as input.
TRISD = 0x00 ; //portD as output.
//clear the output ports at the beginning.
PORTD = 0x00 ; //clear portD.
}
There are different types of motor, a DC motor and AC motor. In digital electronics we don't ussually use of AC motor. what we use is the DC motor. In DC motor there is only 2 polarity like what you showed in the picture, of course the polarity of DC motor is North and South. The Red and Black of the wire of what you showed is the wire connected to the armature.