bug or not multiple AND conditions in IF statment?

professor_jonny

New Member
ok so here is some code but I have a problem with it during simulation

if pin B.3 and B.5 are operated and pin 4 is not it jumps out of the loop why?
is there another way of acomplishing this ?

Code:
pause 1000

main:
if pinB.3=1 AND pinB.4=1 AND pinB.5=1 then
	goto  avpack_bypass
end if
goto main

avpack_bypass:
pause 1000
if i rearange it to:
Code:
 if pinB.4=1 AND pinB.3=1 AND pinB.5=1
then it still skips the middle conditional statment and ideas?
 

Goeytex

Senior Member
Looks like a simulator bug in PE6. It works fine in PE5.5. It should work fine on the silicon. When I run into stuff like this I always test on the chip itself.
 

neiltechspec

Senior Member
Cant see why that shouldn't work.

I use this in one of my projects & it works fine (I used symbols for the input pins).

Code:
	if driv=1 and pass=1 and boot=1 and stor=1 and lights=0 and ign=0 then
	 serout lcd,baud,(254,8)  ;turn off display if ign,lights off & all openings closed
	endif
 

hippy

Ex-Staff (retired)
This appears to be an issue with simulation which we are investigating. The problem appears to materialise when there are more than two comparisons with only the first and last being assessed.

It should normally be possible to express any sequence of multiple comparisons using single comparisons and nested or consecutive IF statements as a work round. For example -

Code:
if pinB.3=1 AND pinB.4=1 AND pinB.5=1 then
  goto avpack_bypass
end if
Has the same functionality as -

Code:
if pinB.3=1 then
  if pinB.4=1 then
    if pinB.5=1 then
      goto avpack_bypass
    end if
  end if
end if
 

Hemi345

Senior Member
Could this be accomplished with something like:

Code:
let b0 = outpinsB AND %00111000
if b0 = 56 then
   goto avpack_bypass
end if
?
 
Top