Q No.1: application on PIC 16F887 microcontroller Write a program using MikroBas
ID: 2250258 • Letter: Q
Question
Q No.1: application on PIC 16F887 microcontroller Write a program using MikroBasic Pro to develop the following The four windings terminals (WI-W4) of a bipolar stepper motor are connected to RBO-RB3 respectively of 16F887 through suitable driving circuits. The microcontroller rotates the stepper motor clock-wise using the pulses given below starting from W1 to W4. And it rotates the motor anti-clock-wise using the same pulses but in reverse order ie. starting from W4 to WI. Wi W2 W3 W4 0 0 0 0 0 0 0 0 0 0 A switch SI is connected RA2. If SI is OFF, the program will rotate the motor clock-wise. And if S1 is ON, the program will rotate the motor anti-clock-wise. The time delay between sending each control pulse (step) is 0.2 seconds for both directions. Program should be keep on working in the same mannerExplanation / Answer
Bipolar motor is interfaced with PIC Microcontroller in order to make the motor move in full steps or in half steps. For this purpose,a motor driver ic is also required which is used to drive the motor. Drivers like L293D or ULN2003 can be used.
According to the output table presented above in the question,the motor is driven very slowly by energising only one stator electromagnet at a time. This is mainly done in places were required torque is less while it consumes very low power.
PROGRAM:-
void main()
{
CMCON=0x07;//this is for turning the comparators off
ADCON1=0x06;//this is for turning off the A/D converters.
TRISA=0;//here port A is set as the output port as switch is connected to RA2.
PORTA=0x0F;
do
{
PORTA=0a00000001;
Delay_ms(0.2);
PORTA=0a00000010;
Delay_ms(0.2);
PORTA=0a00000100;
Delay_ms(0.2);
PORTA=0a00001000;
Delay_ms(0.2);//these are required to give a small delay of 0.2ms to rotate the motor clockwise and anticlockwise.
}
while(1);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.