Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
int SimpleForward(void) { int Front = sharp_IR_interpret_GP2Y0A02YK(a2dConvert8bit(0));; int Left = sharp_IR_interpret_GP2Y0A02YK(a2dConvert8bit(5));; int Right = sharp_IR_interpret_GP2Y0A02YK(a2dConvert8bit(10));; delay_ms(50); if (stuckcheck==50) { rprintf("\r\n*********************StuckCheck*********************"); delay_ms(500); Stuck(Front, Left, Right); stuckcheck=0; } stuckcheck=stuckcheck+1; }int Stuck(int Front, int Left, int Right) { if (OldLeft>=0.95*Left && OldLeft<=1.05*Left && Left!=0 && Left>!1500) { GoBack(1950); printf("\r\nLeft stuck, OldLeft=%d, Left = %d", OldLeft, Left); return 0; } if (OldRight>=0.95*Right && OldRight<=1.05*Right && Right!=0 && Right>!1500) { GoBack(1200); rprintf("\r\nRight stuck, OldRight=%d, Right = %d", OldRight, Right); } return 0; } if (OldFront>=0.95*Front && OldFront<=1.05*Front && Front!=0 && Front>!1500) { GoBack(1650); rprintf("\r\nFront stuck, OldFront=%d, Front = %d", OldFront, Front); return 0; } rprintf("\r\nFront not stuck, OldFront=%d, Front = %d", OldFront, Front); rprintf("\r\nLeft not stuck, OldLeft=%d, Left = %d", OldLeft, Left); rprintf("\r\nRight not stuck, OldRight=%d, Right = %d", OldRight, Right); OldFront=Front; OldLeft=Left; OldRight=Right; return 0; }
badISR calledbadISR calledbadISR calledbadISR calledbadISR calledbadISR call
The µC is all of the sudden resetting on something that has worked in ages.
do_stuff(1);rprintf("testA");do_stuff(2);rprintf("testB");do_stuff(3);rprintf("testC");