fernando_g
Senior Member
The snippet below actually consists of two routines. Each one with (slight) advantages or disadvantages to the other.
Use only one.
'
Use only one.
'
Code:
testing of two routines which provide hysteresis to a compared value.
'In this example, I'm adding +/- 11 counts to a setpoint value of 128
'Using 08M2 port C.1 as analog input, port C.0 as output
*******************************************************************
'first routine, more lines, less compiled bytes (24)
schmitt_trig1:
readadc C.1, b0
if pinC.0 = 1 then
goto lohyst
endif
hihyst: 'C.0 =0
if b0 >139 then
high C.0
endif
lohyst: 'C.1 =1
if b0 <117 then
low C.0
endif
'second routine, more compact, more compiled bytes (26)
schmitt_trig2:
readadc C.1, b0
if b0 >139 and pinC.0 =0 then
high C.0
elseif b0 <117 and pinC.0 =1 then
low C.0
endif