×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Anyone please correct my code and complete the 2 missing routines

Anyone please correct my code and complete the 2 missing routines

Anyone please correct my code and complete the 2 missing routines

(OP)
Hello. Can anyone out there please correct my 45,90,180,270 and -45,-90,-180,-270 conversion routines and complete the 2 missing routines. I will be in a greatful appreciation.Here is my code:






                   org 0000h
 
                   jmp MAIN
 
                   org 0100h
 
MAIN:              CALL ROLLSTOP
 
                   mov p3,#11111111b


START:             jb p3.0,FORWARD                       ;PIN 3.0 IS ON - forward
 
                   jnb p3.0,REVERSE                      ;PIN 3.0 IS OFF - reverse
 
                   jmp start
 
FORWARD:           MOV A,#98                             ;WAIT 1sec TO START RUNNING
 
                   CALL WAITS
 
                   CALL INITFORWARD                      ;SET MOTOR IN FORWARD MOTION
 
                   CALL WAITS

                   CALL FORWARDSHAFT

                   CALL WAITS
 
                   CALL ROLLSTOP
 
                   jmp start                             ; ß---clockwise

 
                                                         ;SET MOTOR IN REVERSE MOTION
 
REVERSE:           MOV A,#98                             ;WAIT 1sec TO START RUNNING

 
                   CALL WAITS
 
                   CALL INITREV
 
                   CALL WAITS
                   
                   CALL REVERSESHAFT
 
                   CALL ROLLSTOP

                   jmp start                             ; ß---counterclockwise
 
WAITS:             MOV R2, A                             ;FULL WAITS (SHORT) IS APPR.2 sec
 
WAIT2:             DJNZ R0,WAIT2
 
                   MOV R0, #00000011B

                   DJNZ R1, WAIT2

                   RET
 
PAUSE:             MOV A, #49                            ;PAUSE 1/2sec AFTER MOVING

                   CALL WAITS
 
                   RET
 
                                                         ;SET FORWARD MOTION
INITFORWARD:                                             ;The unipolar stepper motor begins in motion ( Phase 1)
                   MOV P1,#00000001B ;1
 
                   CALL PAUSE
 
                   MOV P1,#00000010B ;2
 
                   CALL PAUSE
 
                   MOV P1,#00000100B ;4
 
                   CALL PAUSE
 
                   MOV P1,#00001000B ;8
 
                   CALL PAUSE

 
                   RET
 
                             ;SET REVERSE MOTION
INITREV:                                                 ;The unip. step. motor begins its backw. motion ( Phase 2)
                   MOV P1,#00001000B ;8
 
                   CALL PAUSE
 
                   MOV P1,#00000100B ;4
 
                   CALL PAUSE
 
                   MOV P1,#00000010B ;2

                   CALL PAUSE
 
                   MOV P1,#00000001B ;1
 
                   CALL PAUSE
 
                   RET





FORWARDSHAFT:                                             ;Turn  shaft in  certain  positions  during FORWARD  movement

                   MOV P1,#00010001B                     ;Turn it 45 degrees.
                 
                   CALL WAITS
                   
                   MOV P1,#10000010B                     ;Turn it 90 degrees.

                   CALL WAITS

                   MOV P1,#00001001B                     ;Turn it 180 degrees.

                   CALL WAITS

                   MOV P1,#01000010B                     ;Turn it 270 degrees.

                   CALL WAITS

                   LJMP START

                   RET

REVERSESHAFT:                                            ;Turn  shaft in  certain  positions  during  REVERSE  movement

                   MOV P1,#01000010B                     ;Turn it  -270  degrees
                   
                   CALL WAITS
                  
                   MOV P1,#00001001B                     ;Turn it  -180  degrees

                   CALL WAITS

                   MOV P1,#10000010B                     ;Turn it  -90   degrees

                   CALL WAITS                       

                   MOV P1,#00010001B                     ;Turn it  -45   degrees

                   CALL WAITS

                   LJMP START

                   RET
                   




;FASTROUTINE:                                            ;Maximum speed  to  the  UNIPOLAR STEPPER


;SLOWROUTINE:                                            ;Minimum speed  to  the  UNIPOLAR STEPPER


                   
                     
ROLLSTOP:          MOV P1,#00000000B                     ;TURN OFF MOTOR
                   RET
                   END
                       




Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close