Hi All
Just having a play to see if possible to select a pin on a variable changeable setting in
relation to the results of a sensor. Without pre setting the pins to ie if X<1 then high else.........ect
In effect finding its own balance
ie set point 30 reading 31 make next pin high (all other low), no change in reading make next pin high
example start B.4 (high)->B.5 (high)-->time elapse-->no change-->B.6(high) ect
lower than set as above in reverse
have come up with the following creating a mask for b1 to look at B.4 to B.7 works fine up and dwn
whilst there is no highs on the lower pins how can I tell it to discount the lower pins values
hope the explination makes sense
regards john
Just having a play to see if possible to select a pin on a variable changeable setting in
relation to the results of a sensor. Without pre setting the pins to ie if X<1 then high else.........ect
In effect finding its own balance
ie set point 30 reading 31 make next pin high (all other low), no change in reading make next pin high
example start B.4 (high)->B.5 (high)-->time elapse-->no change-->B.6(high) ect
lower than set as above in reverse
have come up with the following creating a mask for b1 to look at B.4 to B.7 works fine up and dwn
whilst there is no highs on the lower pins how can I tell it to discount the lower pins values
Code:
b12=20 'set value required
b10=20 ' sensor value
high b.6 'set a point to start from
'high b.2
do 'if no difference loop until a change occurs
' finds the pins setting to achive balance
let b1=pinsB&%11110000
if pinB.0=1 then:dec b10 'for simulation to replicate sensor reading only
elseif pinB.1=1 then inc b10 'as above
endif
if b10>b12 then
gosub up
elseif b10<b12 then
gosub dwn
endif
loop
up:
let b1=pinsB&%11110000*2 max 128 ' make a mask and limit it so the bits
select case pinsB 'do not fall off the edge
case 16 high B.5 low B.4
case 32 high B.6 low B.5
case 64 high B.7 low B.6
case 128 high B.7 low B.6,B.5,B.4
end select
return
dwn:
let b1=pinsB&%11110000/2 min 16
select case pinsB
case 128 low B.7 high B.6
case 64 low B.6 high B.5
case 32 low B.5 high B.4
case 16 high B.4 low B.7,B.6,B.5
end select
return
regards john