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.
long unsigned int MaxVal=0;void control(void) { while(1) { if(button_pressed()){ delay_ms(50); MaxVal=sonar_MaxSonar(a2dConvert8bit(0)); rprintf("MaxVal=%d\r\n",MaxVal); }delay_ms(1000); }
it gives me this message "calledbadISR" in the hyperterminal with the rest of the Sonar values
After getting the value I want to change it to meters but I don't know how.
Quoteit gives me this message "calledbadISR" in the hyperterminal with the rest of the Sonar valueshmmmm another person recently got this error, appears to be a new bug with the latest software release . . .Anyway, this code:sonar_MaxSonar(a2dConvert8bit(0))returns an int value. Try changing:long unsigned int MaxVal=0;to:int MaxVal=0;and let us know if that fixes it.QuoteAfter getting the value I want to change it to meters but I don't know how.That function automatically returns a value in inches. Just multiply it by 2.54 and you'll get centimeters.
Isnt it divide by 2,54?
The error appear when there is delay,I think it doesn't have time to appear when I remove the delay because the code keep on executing so fast.
long unsigned int MaxVal=0;void control(void) { while(1) { if(button_pressed()){ //delay_ms(50);//delay is removed MaxVal=sonar_MaxSonar(a2dConvert8bit(0)); rprintf("MaxVal=%d\r\n",MaxVal); }delay_ms(1000); }
long unsigned int MaxVal=0;void control(void) { while(1) { if(button_pressed()){ //delay_ms(50);//delay is removed MaxVal=sonar_MaxSonar(a2dConvert8bit(0)); rprintf("MaxVal=%d\r\n",MaxVal); }//delay_ms(1000); you have to remove this also }
I wanted to ask about another thing,how to make the MaxSonar more accurate ?
and when I add delay in "my function" or inside "while(1)" ,it gives me this message "calledbadISR" in the hyperterminal with the rest of the Sonar values. I am not using Interrupts and I tried every way to change my code but it kept on showing up. any idea what is this ?
If an unexpected interrupt occurs (interrupt is enabled and no handler is installed, which usually indicates a bug), then the default action is to reset the device by jumping to the reset vector.
Well I will be using PWM for my motors, can't I take the PWM code from the new Source code and put in the old one ?