To Skimask:
I tried out the code you gave me and it did write through the EEPROM like it was suppose to. I re-wrote the code I had and it gives me 00 00 when I do not move any of the inputs around at all if I pull the Pulse Wire in and out of ground it seems to give me random values not how many time I pull it in and out, it does seem kind of close though. The code is posted below if you see a problem with it. Thanks for your help btw. I've been working on this all day now and can't seem to get any repeatability.
*************************************************
@ DEVICE PIC12F683, INTRC_OSC_NOCLKOUT
@ DEVICE PIC12F683, WDT_ON
@ DEVICE PIC12F683, PWRT_ON
@ DEVICE PIC12F683, MCLR_OFF
@ DEVICE PIC12F683, BOD_ON
@ DEVICE PIC12F683, CPD_OFF
@ DEVICE PIC12F683, PROTECT_OFF
TRISIO = %11111111
Location var WORD
Mult_Count VAR BYTE
Was_Low VAR BIT
Pulse var gpio.3
Direction VAR gpio.5
Mult_Count = 0
Location = 0
Was_Low = 0
PAUSE 500
main:
IF Pulse = 1 AND Was_Low = 0 THEN
IF Direction = 1 THEN
Mult_Count = Mult_Count + 1
ELSE
Mult_Count = Mult_Count - 1
ENDIF
Was_Low = 1
ENDIF
IF Pulse = 0 THEN
Was_Low = 0
ENDIF
IF Mult_Count = 10 THEN
Location = Location + 1
Mult_Count = 0
ENDIF
IF Mult_Count = -10 THEN
Location = Location - 1
Mult_Count = 0
ENDIF
WRITE 0, Location.Byte1
WRITE 1, Location.Byte0
GOTO main
end
*********************************************
To mister_e:
I can easily change the clock to 8MHz, I should have done that in the first place. The PWM signal I have done as well, using C code on this chip, and it works pretty nicely. I haven't used the timers before though, although I would really like to go this route with this. My only concern would be I need to be able to count up and down and I'm unsure if can I do so with these Timers. Maybe one way to do so would be to call a interrupt when a direction change is seen and save the timer value before resetting it to 0. Then do the math to another variable with the true position value. I'm gonna start reading on it while I'm still at work. Thanks for the idea it sounds like the best way to go. If you have any advice for going about it let me know. Thanks again.
Anthony
Bookmarks