Thanks for the replies, I have checked and there are no 253 in the code, the project is using a keyes rotary encoder to input a number of steps for a stepper motor, most of the code was off the forum and works well as confirmed by debug, the counter is a variable b1 and this is incremented or decremented by 5 steps per step of the encoder rotation.
I have added the display code which I have used before on a non OLED display without difficulty. The text, clear screen and position commands work fine but it will not correctly display the number held in b1,
bfgstew, as requested I have added the code in progress, I am using an 18-m2.
Thanks again
'===================================
'ROTARY ENCODER READER Picaxe 18M2
INSTRUCTIONS:
#Picaxe 18M2 ' specify the PICAXE the program code is for
#No_Data 'do not download data EEPROM values
'=====================================
STARTUP:
serout C.7,n2400,(254,128)
serout C.7,n2400,(" FOCUS STACKER")
serout C.7,n2400,(254,192)
serout C.7,n2400,(" Jim Small 2018")
Pause 2000
serout C.7,n2400,(254,1)
pause 1000
serout C.7,n2400,(254,128)
serout C.7,n2400,("No of Steps ")
serout C.7,n2400,(254,192)
serout C.7,n2400,("Press to enter")
serout C.7,n2400,(254,141)
let dirsC=%0000000
INIT:
setfreq M32 'set clock frequency
'b1 is output counter
'c.1=clk
'c.2=DT
'C.1=0 and c.2=0 = b0=0
'C.1=1 and c.2=0 = b0=2
'C.1=0 and c.2=1 = b0=4
'C.1=1 and c.2=1 = b0=6
main: gosub read_c 'read the encoder
if b0=0 then main 'test rotation?
if b0=4 then goto CW 'start of a clockwise rotation
if b0=2 then goto CCW 'start of a counter clockwise rotation
goto main
CW: gosub read_c 'is rotation CW
If b0=4 then 'wait for more
goto CW
else
if b0=0 then main 'return if rotation reversed
endif
six: gosub read_c 'read the encoder
if b0=6 then 'check if clockwise
goto six
else
if b0=4 then CW 'if reverse rotation then goto cw
deux: gosub read_c 'read the encoder
if b0=2 then 'check if clockwise
goto deux 'wait for more
else
gosub read_c 'read the encoder
if b0=6 then six 'if reverse rotation then goto six
goto CWT 'clockwise complet?
endif
endif
CWT: B1=b1+5 'increment b1 +5
gosub DISPLAY
debug
goto main
CCW: gosub read_c 'rotation is clockwise
If b0=2 then 'wait for more
goto CCW
else
if b0=0 then main 'goto main if rotation reversed
endif
six1: gosub read_c 'read the encoder
if b0=6 then 'check if counterclockwise
goto six1 'wait for more
else
if b0=2 then CCW 'if reverse rotation then goto ccw
deux1: gosub read_c 'read the encoder
if b0=4 then 'check if counteclockwise
goto deux1 'wait for more
else
gosub read_c 'read the encoder
if b0=6 then six1 'if reverse rotation then goto six1
goto CCWT 'counterclockwise complet?
endif
endif
CCWT: if b1=0 then fin 'if b1 = 0 then fin
B1=b1-5 'decrement b1-5
gosub DISPLAY
fin: debug
goto main
read_c: b0=pinsC 'reading pins c
b0=b0 & %00000110 'mask c1 & c2
return
DISPLAY:
serout C.7,n2400,(254,141)
serout C.7,n2400,(#b1)
pause 1000
return