All Exams Test series for 1 year @ ₹349 only
Question

A stepper motor has the following specifications:

Step angle: 2°

Steps per revolution: 180

No. of rotor teeth: 45

Movement per 4-step sequence: 8°

The following program will rotate a motor by how many degrees?

          ORG     0000H

            MOV     A, # 66H

            MOV     RO. #32

BACK: RR        A

            MOV     PI, A

            ACALL  DELAY

            DJNZ    RO, BACK

            END

The correct answer is

64°

Understanding Stepper Motor Control and Rotation from Code

This problem asks us to determine the total rotation of a stepper motor based on its specifications and a given program code snippet written for a microcontroller like the 8051. Stepper motors move in discrete steps, and the amount of rotation depends on the number of steps taken and the step angle.

Analyzing Stepper Motor Specifications

We are given the following specifications for the stepper motor:

  • Step angle: \(2^\circ\)
  • Steps per revolution: 180
  • No. of rotor teeth: 45
  • Movement per 4-step sequence: \(8^\circ\)

Let's quickly verify these. The step angle is \(2^\circ\). If there are 180 steps per revolution, the total rotation for 180 steps is \(180 \times 2^\circ = 360^\circ\), which is a full revolution. The movement per 4-step sequence is given as \(8^\circ\), which is consistent with \(4 \text{ steps} \times 2^\circ/\text{step} = 8^\circ\). The number of rotor teeth (45) relates to the motor's physical construction; for a typical 4-phase stepper motor, the step angle is \(360^\circ / (\text{Number of phases} \times \text{Number of rotor teeth})\). If it's a 4-phase motor, \(360^\circ / (4 \times 45) = 360^\circ / 180 = 2^\circ\), which matches the given step angle.

Analyzing the Microcontroller Program

The provided code snippet is as follows:

ORG     0000H
MOV     A, # 66H
MOV     RO, #32
BACK: RR       A
    MOV     PI, A
    ACALL   DELAY
    DJNZ    RO, BACK
END

Let's break down the relevant instructions for determining the motor's rotation:

  • ORG 0000H: This sets the starting address of the code. It doesn't affect the logic of rotation calculation.
  • MOV A, #66H: This instruction loads the Accumulator (A) register with the hexadecimal value 66H. In binary, 66H is 0110 0110B. This binary pattern is likely the initial drive pattern for the stepper motor phases.
  • MOV R0, #32: This instruction loads register R0 with the decimal value 32. R0 will be used as a loop counter.
  • BACK: RR A: This is the start of a loop. The RR A instruction rotates the bits in the Accumulator A one position to the right. The bit that was in the least significant position (bit 0) moves to the most significant position (bit 7). This instruction is crucial because it generates the next sequence pattern needed to step the motor. Each execution of RR A followed by outputting the result typically corresponds to moving the motor by one step.
  • MOV P1, A: This instruction moves the current pattern from the Accumulator A to Port 1 (P1). Assuming the stepper motor driver circuitry is connected to Port 1, this instruction applies the generated pattern to the motor phases, causing it to take a step.
  • ACALL DELAY: This calls a subroutine named DELAY. This subroutine provides a pause, allowing time for the motor rotor to settle in its new step position before the next pattern is applied. The duration of the delay affects the motor speed but not the total number of steps taken.
  • DJNZ R0, BACK: This instruction Decrements R0 and Jumps to the label BACK if R0 is Not Zero. R0 was initialized to 32. The loop will execute the instructions between BACK: and DJNZ R0, BACK repeatedly. The loop continues as long as R0 is not zero after being decremented.
    • R0 starts at 32.
    • The loop body executes.
    • R0 is decremented to 31. Since it's not zero, jump to BACK.
    • ...
    • The loop body executes when R0 is 1.
    • R0 is decremented to 0. Since it's zero, the loop terminates, and the program continues after the DJNZ instruction.
    Therefore, the loop body executes exactly 32 times (for R0 values 32, 31, ..., 1).
  • END: This indicates the end of the program.

Calculating the Total Rotation

From the program analysis, we know the following:

  • The loop that drives the motor executes 32 times.
  • Each execution of the loop body (specifically the RR A and MOV P1, A sequence) causes the motor to take one step.
  • Therefore, the total number of steps taken by the motor is 32.

We are given that the stepper motor has a step angle of \(2^\circ\). To find the total rotation, we multiply the total number of steps by the step angle:

Total Rotation = Number of steps × Step angle

Total Rotation = \(32 \times 2^\circ\)

Total Rotation = \(64^\circ\)

The program rotates the stepper motor by a total of 64 degrees.

Revision Table: Stepper Motor Program Analysis

Program Section Instruction(s) Purpose Effect on Rotation
Initialization MOV A, #66H
MOV R0, #32
Set initial pattern, set loop counter Sets up for stepping
Loop Body RR A
MOV P1, A
ACALL DELAY
Generate next pattern, output pattern, wait Causes motor to take one step per iteration
Loop Control DJNZ R0, BACK Decrement counter, repeat loop if not zero Determines total number of steps (32)

Additional Information: Stepper Motor Driving and Microcontrollers

Stepper motors are often driven using specific phase sequences. For a common four-phase motor, sequences might involve energizing coils in full-step (one phase on or two phases on) or half-step modes. The initial value 66H (0110 0110B) suggests a pattern where bits 6 and 5 are high, and bits 2 and 1 are high. If these correspond to motor phases, rotating this pattern right using RR A would generate subsequent patterns in the sequence. For example:

  • Initial: 0110 0110B (66H)
  • After 1st RR A: 0011 0011B (33H)
  • After 2nd RR A: 1001 1001B (99H)
  • After 3rd RR A: 1100 1100B (CCH)
  • After 4th RR A: 0110 0110B (66H) - Back to the start of a 4-step sequence.

This 4-step sequence (66H, 33H, 99H, CCH) corresponds to a type of full-step drive or possibly a variation depending on how phases are mapped to bits. Each distinct pattern output to the motor causes it to advance by one step angle. The microcontroller provides the timing and sequencing signals (via Port 1 in this case) to the motor driver circuit, which handles the power switching for the motor coils.

The 8051 microcontroller's `DJNZ` instruction is a very efficient way to create a fixed loop delay or repeat a sequence of operations a set number of times, which is common in control applications like driving a stepper motor for a specific angle.

Was this answer helpful?

Important Questions from Microprocessors and Microcontrollers

  1. Cycle stealing mode of DMA operation involves

  2. The period of machine cycle of an 8051 system with crystal frequency 16 MHz is

  3. Which of the following instructions will move the contents of register 3 to the accumulator ?

  4. In 8086, which instruction at the end of a sub-routine takes the execution back to the main program?

  5. Which one of the following is not the feature of 8051?

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App