Write a program which uses 8 DIP switches on LAB PRO Board a

Write a program which uses 8 DIP switches on LAB PRO Board as 8 different speeds for motor. Each switch will run the dc motor at certain speed.

Please make your answer clear.

Vcc Protection CT Diode 4 Buffer 120 From P1.3 Fig.1 Circuit diagram

Solution

Port1 is input and port0 is output

The motor speed can be controlled by PWM signal fed to Darlington pair , more the duty cycle more is current and more the speed

Let total ON time = 256ms and D decides the duty cycle

There will be one switch closed at a time Each bit value is compared with 8 bit port value

CODE :

#include <reg51.h>

int x = 32;
unsigned char mydata[] = {0x01,0x02,0x04,0x08,0x0F,0x20,0x40,0x70};

void main(void)
{

unsigned char x = P0;

unsigned char D;
for (i=0;i<=8;i++)
{ if(mydata[i]==x)
D= i*x;
else
D=0;
}

while(x)
{ P1^3=1;
Delay(D);
P1^3=0;
Delay(256-D);
}


void Delay(unsigned int itime)
{for(i=0;i<=itime;i++)
for(j=0;j<=1275;j++)
}

}

Write a program which uses 8 DIP switches on LAB PRO Board as 8 different speeds for motor. Each switch will run the dc motor at certain speed. Please make your

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site