Hi, I posted a few weeks ago regarding a Vector 2XG electronic compass which is now working fine, thanks all. I'm now working on parsing some NMEA sentences from a GPS receiver and comparing the results with the heading from the compass. I want the PIC to decide if it has to turn left or right to match the GPS's waypoint data and the compass data. I came up with the following logical tests to determine the shortest path to the desired heading : A = current angle (compass heading) B = desired angle (GPS waypoint heading) if A < B then if ABS(A-B) > 180 then TURN COUNTER CLOCK-WISE else TURN CLOCK-WISE else if A > B then if ABS(A-B) < 180 then TURN COUNTER CLOCK-WISE else TURN CLOCK-WISE else NO CORRECTION; This works fine in a little Windows App I made and I think I could port it to PIC assembly fairly easily or program it directly in C. However, I feel it will take a lot of program memory to directly translate every conditional and math operator (the values are 16 bits wide since there are 360 degrees) to the PIC. Any suggestions on how to simplify this procedure in PIC assembly? There must be a simple combination of binary operations that will give the same result ?!?!? Thanks, --------------------------------------------------------------- Tobie Horswill Ex Machina 103, rue Dalhousie Quibec (Quibec) CAN G1K 4B9 thorswil@exmachina.qc.ca -- http://www.piclist.com hint: PICList Posts must start with ONE topic: "[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's