dw_picbasic
- 9th January 2021, 20:02
Hello All,
I have a theoretical question about guesstimating how fast an input signal a PIC can track.
I'd like to experiment with an 18pin PIC - such as the PIC6F627A
I'd like to simulate a binary up/down counter
But this counter will keep track of degrees - with a max value of 359
Which means it needs to role over when > 359 and role over when < 0
The input signal to track will be a standard A/B encoder signal requiring 2 input pins.
The output will be PORTB's 8 pins, and one pin from PORTA to function as 9th bit.
9 bits can hold our expected values.
The PIC will be running with internal oscillator at 4mhz
Is there a way I can guesstimate how fast an encoder pulse the PIC will be able to accurately track?
Thanks in advance! :-]
dw
A description of the process follows:
PORTA will have 2 input pins with alias names = Pin_A, Pin_B
PORTA will have 1 output pin with alias name = bit9
PORTB will have 8 output pins
main:
'Here we remain in a loop until Pin_A clock input goes high
while pin_A = 0
wend
'We are now here because pin_A clock input went high starting a clock cycle
'------------------------------------------------------------------------
if pin_B = 1 then counter = counter + 1
if pin_B = 0 then counter = counter - 1
if counter > 359 then counter = counter - 360
if counter < 0 then counter = counter + 360
if counter > 255 then HIGH bit9 else LOW bit9
PORTB = counter && 255
'We now wait for pin_A clock input to go LOW
'In order to be ready for its next clock cycle
'---------------------------------------------
while pin_A = 1
wend
'we are now here because pin_A has gone LOW and is now ready for its next cycle
'Start over and get pin_A next clock cycle
goto main
I have a theoretical question about guesstimating how fast an input signal a PIC can track.
I'd like to experiment with an 18pin PIC - such as the PIC6F627A
I'd like to simulate a binary up/down counter
But this counter will keep track of degrees - with a max value of 359
Which means it needs to role over when > 359 and role over when < 0
The input signal to track will be a standard A/B encoder signal requiring 2 input pins.
The output will be PORTB's 8 pins, and one pin from PORTA to function as 9th bit.
9 bits can hold our expected values.
The PIC will be running with internal oscillator at 4mhz
Is there a way I can guesstimate how fast an encoder pulse the PIC will be able to accurately track?
Thanks in advance! :-]
dw
A description of the process follows:
PORTA will have 2 input pins with alias names = Pin_A, Pin_B
PORTA will have 1 output pin with alias name = bit9
PORTB will have 8 output pins
main:
'Here we remain in a loop until Pin_A clock input goes high
while pin_A = 0
wend
'We are now here because pin_A clock input went high starting a clock cycle
'------------------------------------------------------------------------
if pin_B = 1 then counter = counter + 1
if pin_B = 0 then counter = counter - 1
if counter > 359 then counter = counter - 360
if counter < 0 then counter = counter + 360
if counter > 255 then HIGH bit9 else LOW bit9
PORTB = counter && 255
'We now wait for pin_A clock input to go LOW
'In order to be ready for its next clock cycle
'---------------------------------------------
while pin_A = 1
wend
'we are now here because pin_A has gone LOW and is now ready for its next cycle
'Start over and get pin_A next clock cycle
goto main