Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Moved] need help explaining code. line by line

Status
Not open for further replies.

eeec

Newbie level 4
Newbie level 4
Joined
Jan 21, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,355
encoder = ra
out = rb.1
direction = rb.0
flash = rb.5


temp = 0Ch
counter = 0Dh
old = 0Eh
new = 0Fh
flag = 1Fh
armed = 1Eh

device pic16c54,rc_osc,wdt_off,protect_on
reset start


org 0

start mov !rb,#00100000b Why is there an exclamation mark?
mov !ra,#255
mov counter,#128
clrb out

mov old, encoder
and old, #00000011b loop
jb flash,test
call check_encoder


flashing cje counter,#128,loop
jb flag,timeout

mov OPTION,#00000111b
mov RTCC,#248
setb flag

timeout mov w,RTCC
jz drive
jmp loop


drive clrb flag
jb out,lower
setb out
clrb armed
jmp cont

lower clrb out
setb armed

cont cja counter,#128,down
clrb direction
snb armed
inc counter
jmp try_done


down setb direction
snb armed
dec counter

try_done cjne counter,#128,loop
clrb flag
jmp loop



check_encoder mov new, encoder
and new, #00000011b
mov temp, new
xor temp, old
jz :return
clc

rl old
xor old, new

jb old.1, :up
:down dec counter
skip

:up inc counter
mov old,new
:return ret

test mov counter,#129
jmp flashing





------------------------------------------------------------------------------------------
END
-------------------------------------------------------------------------------------------
can someone explain these code to me? especially the one in bold?

anyone can help me? thanks a million
i have to explain it to my supervisor but i don't know how. attachment for the 2 files.
 

Attachments

  • Desktop.rar
    3.2 KB · Views: 79

Hi,


The file in the attached .rar is a proper Pic16C54 servo motor program with notation.

Seems the # code shown has been doctored, by placing the Device Pic16C54 into it.
Assume it is really something like AVR Assembly doing the similar servo motor control.. ?
 

Ok. let's start this all over again.
thank you all for your help.

i am trying to understand how this PIC16C54 send data ( pulse and direction ) to the stepper motor driver 5804.
i have attached the data sheet of the kit,pic,stepper motor i am using and the stepper motor driver.

i need your help to understand how this pic16c54 "interact" with the driver. and how the driver analysis the data and move the motor.


note* motor i using page 3/4 (MY5602)
 

Attachments

  • 5804 IC.pdf
    155.2 KB · Views: 89
  • k94.pdf
    26.3 KB · Views: 87
  • PI IC.pdf
    2.6 MB · Views: 72
  • MY3002-Astrosyn-datasheet-11809482.pdf
    633.9 KB · Views: 83
  • k94.bmp
    3.7 MB · Views: 73

Hi,

You really need to first understand the principles of a stepper motors operation.

MicroChip have several application notes on this, some in Assembly, just two links below, search for more.
Also many basic stepper tutorials on the web, again one example below.

Once you understand how they function then it will be easier for you to follow the assembly code.

http://ww1.microchip.com/downloads/en/AppNotes/00907a.pdf
http://ww1.microchip.com/downloads/en/AppNotes/00906B.pdf
http://www.pyroelectro.com/tutorials/stepper_motor/index.html
 
  • Like
Reactions: eeec

    eeec

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top