How to perform an 'AND NOT' on a BS2e
Tibo
Posts: 81
Hi,
I need a little help on logical operators :
I'm writing a turn decision routine as part of my robot brain running on BS2e, connected to a PWMPAL, two IR telemeters SHARP GPD2D02 and a SRF04 ultrasonic telemeter.
For that I'm using (probably like a noob) the two banks of the chip, seperating logics, sharing global variables, etc... (BTW thanks to EME systems for their applications notes)
Here is my problem :
Since there is no AND NOT operator on the BS2, i'd like to perform a bitwise operation on the irStatus Nib in order to take move decision.
I'm pretty sure there is a math trick to do so...but i dont remember [noparse]:([/noparse]
Thank you to help if you can
I need a little help on logical operators :
I'm writing a turn decision routine as part of my robot brain running on BS2e, connected to a PWMPAL, two IR telemeters SHARP GPD2D02 and a SRF04 ultrasonic telemeter.
For that I'm using (probably like a noob) the two banks of the chip, seperating logics, sharing global variables, etc... (BTW thanks to EME systems for their applications notes)
Here is my problem :
Since there is no AND NOT operator on the BS2, i'd like to perform a bitwise operation on the irStatus Nib in order to take move decision.
I'm pretty sure there is a math trick to do so...but i dont remember [noparse]:([/noparse]
main : stopBit=%0 '----- debug DO leftIrFlag=%0 rightIrFlag=%0 irStatus=%0000 DEBUG HOME, "IR-GAUCHE: ", DEC agregMeasures.BYTE0, " IR-DROITE: ", DEC agregMeasures.BYTE1, REP " "\4 IF agregMeasures.BYTE0>=minDist THEN leftIrFlag=%1 'AgregMeasures come from IR detectors reading routine IF agregMeasures.BYTE1>=minDist THEN rightIrFlag=%1 'I'm checking if not at minimum distance offset ' update stop bit with last sr_IR computation (case both sr_IR = 1), needed for WIFI control stopBit = leftIrFlag & rightIrFlag DEBUG CRSRXY, 0, 1, "STOPBIT ",BIN2 stopBit, " " DEBUG CRSRXY, 0, 2, "leftIrFlag ",BIN2 leftIrFlag, " rightIrFlag ",BIN2 rightIrFlag, REP " "\4 ' check for turn needs IF NOT leftIrFlag & rightIrFlag THEN irStatus=%0000 ' forward ok IF leftIrFlag & rightIrFlag THEN irStatus=%1111 ' backward ok '[b]Here is my problem : both lines under are equals....so i cant know if left or right [/b] IF leftIrFlag=%0 & rightIrFlag =%1 THEN irStatus=%1011 ' left u trun IF leftIrFlag=%1 & rightIrFlag =%0 THEN irStatus=%0111 ' right u turn DEBUG CRSRXY, 0, 4, "irStatus :" ,BIN4 irStatus, REP " "\4 SELECT irStatus CASE %0000 DEBUG CRSRXY, 0, 6, "FORWARD", REP " "\20 CASE %1111 DEBUG CRSRXY, 0, 6, "BACKWARD", REP " "\20 CASE %1011 DEBUG CRSRXY, 0, 6, "LEFT UTURN", REP " "\20 CASE %0111 DEBUG CRSRXY, 0, 6, "RIGHT UTURN", REP " "\20 ENDSELECT RUN 1 LOOP
Thank you to help if you can
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
thx Jon.