
The assembly code for the interrupt will be simple. Language will not work for the rotary encoder. Probably you already know that.An interrupt in PicBasic

Last edited by ice - 3rd May 2005 at 14:00. The whole problem seems to be the direction decoding part. LCDOut $fe,$c0,DEC counter," ", BIN direction_bitĮnable1>The interrupts are worng fine,however the code is still unable to distinguish between CW and CCW,because of which the counting goes awry.Ģ>if i remove the "if then " statement for CW/CCW direction and only put a LCDOut $fe,$c0,DEC counter," ",BIN direction_bit New= PORTB & %00000011 'load new value of A/B channels into new by anding with HEX3ĭirection_bit=old.bit1 ^ new.bit0 'check direction Myint: Low led ' If we get here, turn LED off ON INTERRUPT GoTo myint ' Define interrupt handler

this is a long post.but its the best i could do to explain wht im trying to do.Īdval VAR WORD ' Create adval to store result Now i dont know where to go from here.how do i get the motor to move to position 32500,when the pot is moved to 128 Hence required count value=*pot_val+counter_2 Pot_val holds the pot value connected to analog portA.0 say it is CW and counter increments to 32600 till the endĥ>move the motor to the other side,count the is decrementing nowħ>now i have to scale the gear assembly range to a potentiometer Using the current sense feature of the chip,i detect wheteher the gear assembly has reached an end point.The current sense pin is connected to an ADC port.portA.1 namelyģ> count pulses.if CW,increment.if CCW decrement Scale the 200 counts to a potentiometer value The above was just the calibration routine.Using the above values ,i have to now i rotate it to the other side ,say the count at this point is 32400 Say, i start with a count of 32500 and the count at one end of the gear assembly is 32600 I have to first detect the endpoints of a gear assembly. I need to control the position of a DC motor,using a potentiometer


Before i go ahead with my code.ill explain wht i have to do
