









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The use and control of stepper motors, discussing stepper motor energizing patterns, creating quasi-continuous motion, and sequential accessing of stored patterns. It also illustrates loading a single-precision variable into a double precision register and automatic incrementation/decrementation of the addressing pointer. An example from a microcontrollers course.
Typology: Study notes
1 / 17
This page cannot be seen from the preview
Don't miss anything!
This example has the following objectives: Review the use and control of stepper motors. Discuss the stepper motor energizing patterns, 1- and 2-phase energizing types, full- and half- step motion. Introduce the concept of creating quasi-continuous motion through a sequence of steps Introduce the concept of sequential accessing a finite set of stored patterns through index addressing with a continuously updating pointer. Illustrate a method to ‘load’ a single-precision (2-hex) variable into a double precision (4-hex) register. Introduce the concept of automatic incrementation/decrementation of the addressing pointer with a programmable step size Discuss the reset actions to be taken when the pointer hits the ‘ceiling’ or ‘floor’. 8 - pin input connector Controller board Stepper motor Figure 1 Stepper motor and its controller board. Control signals to the controller board are sent through the 8-pin input connector.
This program is to be used for stepper motor control (Figure 1). A stepper motor is controlled by sending a binary pattern to its controller board. Eight distinct binary patterns are recognized by the stepper motor controller board in your lab. They are given in Table 1 as sequences S0 – S7. The
stepper motor has four distinct coils, and a 1 in the energizing pattern signifies that the corresponding coil is energized. Note that in the even sequences (S0, S2, S4, S6) only one bit in the energizing pattern is set. This indicates that only one out of the four stepper-motor coils (1 phase) is energized. On the other hand, in the odd sequences (S1, S3, S5, S7), two bit are set, i.e., two coils (2 phases) are energized. The sequences with two coils energized are labeled full step , while those with only one coil energized are labeled half step. Table 1 Stepper motor energizing patterns and their 2-hex equivalent value Sequence Energizing pattern 8-bit 2-hex equivalence Phase energizing type Step type S0 1000 $08 1 phase Half step S1 1001 $09 2 phase Full step S2 0001 $01 1 phase Half step S3 0101 $05 2 phase Full step S4 0100 $04 1 phase Half step S5 0110 $06 2 phase Full step S6 0010 $02 1 phase Half step S7 1010 $0A 2 phase Full step When these patterns are hit in increasing order, one after the other, the motion is called ‘half speed forward’. If only the odd sequences are hit, i.e., every second pattern is hit, the motion is ‘full speed forward’. If the patterns are hit in decreasing order, the motion is, respectively, ‘half-speed backward’ and ‘full speed backward’ (Table 2). Table 2 Stepper motor speed definitions Step Start Full speed forward +2 Even pattern Half speed forward +1 Anywhere Half-speed backward -1 Anywhere Full speed backward -2 Even pattern To control a stepper motor, a parallel port is used to send 8-bit pattern to the stepper-motor control board. Note the pin assignment: MSB LSB N/A N/A N/A N/A
(white)
(green)
(gray)
(yellow) The program illustrates the sequentially access to memory locations using a memory pointer:
Define variables START Load POINTER to accB Add STEP SWI Load $0000 into Y Add accB to Y (acc B contains the value of POINTER) S0 1 byte S1 1 byte S2 1 byte S3 1 byte S4 1 byte S5 1 byte S6 1 byte S7 1 byte STEP 1 byte POINTER 1 byte Big-picture Flowchart (^) Flowchart Details Initialize Below ceiling? Reset to floor Y N Reset to ceiling Y N LABEL0^ Call S/R STEP_SR RTS STEP_SR BRA LABEL LABEL Above floor? Store new value of POINTER Load new sequence code into accA using Y Send sequeuce code from accA to Port B Put POINTER into Y POINTER 7? 0 POINTER? POINTER= POINTER= X=REGBAS S0=$ S1=$ S2=$ S3=$ S4=$ S5=$ S6=$ S7=$0a STEP=$ POINTER=$ Code
Open THRSim11. Close the Commands window. View CPU registers AND memory list. Open and assemble Ex_Step.asm. Set breakpoint at SWI. Reset registers. Press the RESET button. Set standard labels (Label/Set Standard Labels). Set breakpoint at LABEL0 and at SWI. Arrange windows for maximum benefit: Your screen should look like this:
a) Put STEP=$01. This should make the program go forward in increments of one (half-speed forward). Your screen should look like this:
b) Step through the program. Notice that the program goes directly to the subroutine STEP_SR. The following events happen: The current value of the variable POINTER (POINTER=$00) is loaded into accB. The value of variable STEP (STEP=$01) is added to accB. The result is accB = $ The value in accB is compared with the ceiling (i.e., perform accB-$07). The result of the comparison is a negative number. Hence, the condition code bit N is set (observe N=1 on the simulator status bar, and bit 3 = 1 in CC register). Your screen looks like this:
At branch BGE LABEL4, the branch condition is met (since N=0) and the program branches to LABEL4. The value of accB is stored as the new value of POINTER (observe POINTER at memory location $0009 having the value $01) At this stage, the value of POINTER must be loaded into index register Y. To achieve this, the value $0000 is loaded in index register Y. Then, the index register Y and the accB (containing the current value of POINTER) are added. (This convoluted way of doing things was needed because there is no simple way to load the single precision variable, POINTER, into the double precision register Y.) Your screen looks like this:
The value of the memory where the POINTER points to is now loaded into accA. This is achieved using index addressing with Y as the index register and $00 as the offset (i.e., LDAA $00,Y). In our case, POINTER=$01, hence the memory location $0001 is loaded. This is the step S1, which has the value S1=$09. Hence, you should see the value $09 in accA (i.e., A $09 in CPU registers). Finally, the pattern S1, which was loaded in accA, is sent to Port B. This will make the stepper motor go to the position corresponding to pattern S1. Your program looks like this: c) Let your program perform another loop and observe that the POINTER and the value in Port B have reached the next sequence pattern, S2=$01. Your screen should look like this:
e) In the next loop, the program should hit the ceiling and return to the floor. Perform this loop manually, to verify the logic. At the end of the loop, observe that the POINTER and the value in Port B have come back to the first sequence pattern, S0=$08. Your screen should look like this:
Press RESET button. Run initialization. Put the value $02 into the variable STEP and $07 into variable POINTER. Repeat the pattern of observations covered before. You will see that only the odd patterns (S1, S3, S5, S7) are being hit. According to Table 1, these patterns correspond to 2- phase energizing of the stepper motor (full steps). Satisfy yourself that you fully understand the logic of the program and that you have fully observed how the program is generating a full-speed forward motion.
Put the value $ff into the variable STEP and repeat the pattern of observations covered before. You will see all the patterns (S0--S7) being hit, but in reverse order (S1, S0, S7, S6, S5, S4, S3, S2, S1 …). Satisfy yourself that you fully understand the logic of the program and that you have fully observed how the program is generating a half-speed backward motion.
Put the value $fe into the variable STEP and repeat the pattern of observations covered before. You will see that only the odd patterns are being hit, and that they are hit in reverse order (S1, S7, S5, S3, S1, …). Satisfy yourself that you fully understand the logic of the program and that you have fully observed how the program is generating a full-speed backward motion.
(This page is left intentionally blank)