Assembler Developer

Moderators: None (Apply to moderate this forum)
Number of threads: 1030
Number of posts: 1826

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
need some help. motorola 68k and M68230 PI/T (parallel interface/timer Posted by blankk on 12 Dec 2008 at 5:29 AM
theres an exercise i have for uni, controlling a DC motor with the motorola 68k and 68230 PI/T.

i wonder if anyone could help me. i actually have the code but i cant understand whats it does exactly in some parts. so if anyone has any experience it would be very appreciated. i first need to know if anyone could help before i post the long explanation of the whole thing and how it works.
Report
Re: need some help. Posted by freelance star on 15 Dec 2008 at 2:39 AM
: theres an exercise i have for uni, controlling a DC motor with the
: motorola 68k and 68230 PI/T.
:
: i wonder if anyone could help me. i actually have the code but i
: cant understand whats it does exactly in some parts. so if anyone
: has any experience it would be very appreciated. i first need to
: know if anyone could help before i post the long explanation of the
: whole thing and how it works.
:
Yes post the portion of code which you are unable to understand.
Hire Freelance Programmer | Hire Web Designer
Report
Re: need some help. Posted by blankk on 15 Dec 2008 at 10:09 AM
heres the exercise.
http://rapidshare.com/files/173581170/mclab8.pdf.html
page 2.


description (page 2):

the DC motor can reach 8000rpm. The polarity of the voltage given to the motor that makes it turn clockwise or the other way, is chosen by the K1 relay.
The activation of the motor for clockwise (or reverse) movement is chosen from the PB6 and PB7 pins of PortB, which are codified from U4.
When d6(PB6)=1 and d7(PB7)=0 the motor turns clockwise.
When d6(PB6)=0 and d7(PB7)=1 the motor turns on the left.
The other 2 combinations will stop the motor.
In order to decodify and bring any output of U4 in logic '0', U4 must first be enabled, by putting the switch SW2B on the 'MOTOR' position. This will bring logic '0' in the pin 1 of U4 (in any other case the pin will 'climb' to +5V through the 4.7kOhm resistance)

Any combination of d6 and d7 (PORTB) that starts the motor, will bring logic '0' on pin 9 of U4. This results, through the high voltage of pin 15 of U3 and the relay K1, to ground one side of the motor and start its movement.
The combination that starts the motor (d6=0 and d7=1) will bring in logic '0' the pin 5 of U4. This will enable relay K1 through pin 16 of U3, it will reverse its contacts and the polarity of the supplier of the motor resulting a change in its rotation.

While the motor rotates, its propeller moves through a source of infra-red ray (D1) and an infra-red ray detector (D2). The change in the current that passes through the detector is enough to bring pin 1 of U5B in logic '1' that will give a signal, 3 times per rotation in the line PA4 of PORT A. This happens when SW4A is in position 'SPEED ON', which connects the output of pin 2 of U5 with the line PA4 of PORT A.

The exercise asks to:
Write a program the will move the motor with the speed determined from the pins d0-d3 of PORT A. The motors speed can be between 1000-7000 rpm.

The code is in page 5 of the pdf file.
Its all good till the line of the code (in the main program) that prompts in the GETRPM subroutine, but I don't quite understand the subroutine.

INIT____MOVEA.L___#$800001,A0_____; Starting address of PI/T
________MOVE.B____#$80,$C(A0)
________MOVE.B____#$00,$4(A0)_____; make port A input
________MOVE.B____#$80,$E(A0)
________MOVE.B____#$FF,$6(A0)_____; make port B output
SPEED__MOVE.B____$10(A0),D2______; move the state of port A on D2
________ANDI.B____#$0F,D2_________; Take only d0-d3 pins that determine the speed
________MOVE.L____#1000,D3________;
________MULS______D3,D2___________; D2=D3*D2 (decimal of the pins (0-7)* 1000 for the speed of the motor (1000 to 7000 rpm)
________BSR_______GETRPM__________; Branch to subroutine GETRPM
________ANDI.B____#$EF,$12(A0)____; d4=0
________CMP.W_____D0,D2___________;
________BLS_______SPEED3__________;
________MOVE.B____#$81,$12(A0)____;
________BRA_______SPEED4__________;
SPEED3_MOVE.B____#$2,$12(A0)_____;
SPEED4_BRA_______SPEED___________;


GETRPM_MOVE.W____#$800,D1________; D1=$800 (2048 DECIMAL)
RPM1___SUB.W_____#1,D1___________; D1=D1-1
________BEQ_______RPM4____________; IF Z=1 GO TO RPM4 ELSE CONTINUE
________BTST______#4,$10(A0)______; check D4 of port A
________BNE_______RPM1____________; if Z=0 go to RPM1 else continue
RPM2___SUBI.W____#1,D1___________; d1=d1-1
________BEQ_______RPM4____________;
________BTST______#4,$10(A0)______;
________BEQ_______RPM2____________; might be BNE ???
________MOVE.W____#0,D1___________;
RPM3___ADDI.W____#1,D1___________;
________CMPI.W____#25000,D1_______;
________BGT_______RPM4____________;
________BTST______#4,$10(A0)______;
________BNE_______RPM3____________;
________MOVE.L____#75000,D0_______;
________DIVU______D1,D0___________;
________RTS_______________________;

RPM4___MOVE.W____#0,D0___________;
________RTS_______________________;
________END_______________________;


It seems that the subroutine is used for the detector of the infra-red ray, so it can read the speed, but how exactly is this done?
It does 3 checks. The source of the infra-red ray, gives a signal, 3 times per rotation.. I cant understand why the subroutine starts by putting on D1 $800 and how it continues.


BTW, the code might be wrong or missing some lines.






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.