hello everyone i have some problems with counting pulses, main purpose of this program is to stop motor after some time yea i know i could just use delay and stop it after some time, but i need to know the motor position. Something like this: At start motors calibrates to main position, after some work i need to know what positions they are. Sorry for poor English. i am using encoder with 4 positions 90 180 270 360 degrees. so one rotate = 4 pulses. i am now experimenting with led's and tryed this code, i am green in programing if someone could help me it would be great. here is code:
Code:
ANSEL = 0
OSCCON = $60
TRISB = %00001000
TRISA = %00000000
counts var byte
opto var PORTB.3
led VAR PORTB.4
led2 var PORTB.5
counts = 0
loop
if opto = 1 then
counts = counts+1
if counts >=10 THEN
high led
endif
endif
goto loop
end
i am using pic16f88. also i think i need to use interrupts but i don't have any idea how to, i checked on datasheet but its to complex for me :/
Bookmarks