Shown is a circuit to control a stepper motor, which has a step of 1 degree +5 v
ID: 3349462 • Letter: S
Question
Shown is a circuit to control a stepper motor, which has a step of 1 degree +5 volts Stepper motor coils (4) RI R2 To turn Clockwise the coils have to be energized from right to left. The Motor is controlled with a PIC microcontroller and a C-language program. The program sends signals from the microcontroller to ports DO, D1, D2 and D3 to energize the coils. DO is the least significant bit and D7 is the most significant bit and D4,D5, D6 and D7 are not used. a) Finish the program below used to control the stepper motor so that it rotates continuously in the counter clockwise direction in full step mode. b) What are the changes to introduce in order to rotate clockwise and half the speed. c) Rewrite the program below so that the motor rotates one full rotation (360 degrees) in the clockwise direction followed by 180 degrees in the counter clockwise direction and repeats these two sequences indefinitely #include void main(void) unsigned char i, k; TRISD while.) PORTD- for(k-0; kExplanation / Answer
Code for Counter Clockwise Full Speed
---------------------------------------------------------
#include <pl8cxxx.h>
void main( void)
{
unsigned char i, k;
TRlSD = 0x0F;
while(1)
{
PORTD = 0x0a;
for(k=0; k<200; k++);
PORTD = 0x09;
for(k=0; k<200; k++);
PORTD = 0x05;
for(k=0; k<200; k++):
PORTD = 0x06;
for(k=0: k<200; k++);
}
}
-----------------------------------------------------------------
Clockwise at half speed
---------------------------------------------------------
#include <pl8cxxx.h>
void main( void)
{
unsigned char i, k;
TRlSD = 0x0F;
while(1)
{
PORTD = 0x05;
for(k=0; k<200; k++);
PORTD = 0x01;
for(k=0; k<200; k++);
PORTD = 0x06;
for(k=0; k<200; k++):
PORTD = 0x0E;
for(k=0; k<200; k++);
PORTD = 0x0A;
for(k=0; k<200; k++);
PORTD = 0x0B;
for(k=0; k<200; k++):
PORTD = 0x09;
for(k=0: k<200; k++);
PORTD = 0x0d;
for(k=0: k<200; k++);
}
}
-----------------------------------------------------------------
Code to roate motor in 360 clockwise and 180 anticlockwise
----------------------------------------------
---------------------------------------------------------
#include <pl8cxxx.h>
void main( void)
{
unsigned char i, k,x;
TRlSD = 0x0F;
while(1)
{
for (x=0;x<48;x++)
{
PORTD = 0x0a;
for(k=0; k<200; k++);
}
for(x=0;x<24;x++)
{
PORTD = 0x0b;
for(k=0; k<200; k++);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.