Bruce:
Thank you I did forget to set up those two registers. I will fix that.
Joe:
I'm using a function generator on the input with a scope on it as well and there is no bouncing on the pin. In the end it will be from a hall effect switch which also should not have any bouncing.
Ioannis:
I believe PBP will do negative numbers, Location should never be a negative number anyways as 0 would be the lowest number of counts you can have it will be zero we it is set up.
I think I'm going to try and use the internal timer which I haven't been able to work on it much as work has me burried. I did have some time to write out some code. I will post is below, if you guys would like to comment on it I would appreciate it. It might be a little chopy at the moment though.
************************************************** *****
@ 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
'* Hardware Setups *
INTCON = %10001000
PIE1 = %00000000
PIR1 = %00000000
OSCCON = %01110000
'* I/O Pin Descriptions Below *
'* PIN 1 - VDD - 5V *
'* PIN 2 - T1CK1 - Input - Pulses from Hall Effect *
'* PIN 3 -
'* PIN 4 - GP3 - Input for the direction of the Hall Effect *
'* PIN 5 - CCP1 - PWM Output to the Analog converter *
'* PIN 6 -
'* PIN 7 -
'* PIN 8 - VSS - Ground *
TRISIO = %00101000
WPU = %00000000
IOC = %00001000
'* Timer Setup *
T1CON = %00100111
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:
GOTO main
end
************************************************** ***
Sure, PBP and assembly both will do negative numbers, but they won't show up the way you want them to...i.e.:
5 - 6 = -1, but PBP will show 255 (for a byte variable), 65535 (for a word variable).
You're going to want to add something like this to your program in post #4:
main:
IF Pulse = 1 AND Was_Low = 0 THEN
IF Direction = 1 THEN
Mult_Count = Mult_Count + 1
ELSE
if mult_count > 0 then mult_count = mult_count - 1
ENDIF
Was_Low = 1
ENDIF
...............
IF Mult_Count = -10 THEN(statement won't work the way you want it to in PBP)
Location = Location - 1
Mult_Count = 0
ENDIF
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks