[Moved] need help explaining code. line by line

Status
Not open for further replies.

eeec

Newbie level 4
Joined
Jan 21, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
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: 72

its code of which microcontroller................

it's in PIC16C54. i have to explain what the code means. but i don't get them. especially pin 16. of pic16C54
 

That is very strange 16C54 code.

What language is it written in? It's an old chip but I've programmed hundreds of them in the past and I don't recognize some of those opcodes.

Brian.
 

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: 82
  • k94.pdf
    26.3 KB · Views: 78
  • PI IC.pdf
    2.6 MB · Views: 66
  • MY3002-Astrosyn-datasheet-11809482.pdf
    633.9 KB · Views: 77
  • k94.bmp
    3.7 MB · Views: 67

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
 
Reactions: eeec

    eeec

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

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…