go away spammer

Author Topic: Problem with Axon And LV-MaxSonar-EZ0  (Read 3639 times)

0 Members and 1 Guest are viewing this topic.

Offline HanoushTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Helpful? 0
Problem with Axon And LV-MaxSonar-EZ0
« on: February 09, 2009, 03:12:25 PM »
When I use this function "sonar_MaxSonar(a2dConvert8bit(0))"    in sensors.c. It gives me weird output that isn't reasonable at all & I don't even know if it outputs in meters or inches or what ?

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 ?

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #1 on: February 09, 2009, 04:06:35 PM »
Would you mind posting some code for me?

Offline HanoushTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Helpful? 0
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #2 on: February 09, 2009, 04:15:55 PM »
Code: [Select]

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);
}

This is the last code,it reads the value from the Analog pin only when I push the button on my Axon. After getting the value I want to change it to meters but I don't know how. this is for my graduation project and it's my first robot in my life and I have to do a flying robot in 3 months  ???

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #3 on: February 09, 2009, 09:26:29 PM »
Quote
it gives me this message "calledbadISR" in the hyperterminal with the rest of the Sonar values
hmmmm 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.

Quote
After 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.

Offline Tomas

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 0
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #4 on: February 10, 2009, 02:23:27 AM »
Quote
it gives me this message "calledbadISR" in the hyperterminal with the rest of the Sonar values
hmmmm 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.

Quote
After 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? :P

And it the problem continues, heres what solved calledbadISR for me. Simply downgrading to 1.01. Im not 100% sure, but I believe I havent had that error since I downgraded(and that I didnt have that problem before I upgraded). And btw, if you are installing a new version, follow the tutorial! I found that just downloading the source code and opening the project created problems for me which continued until I did it the right way.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #5 on: February 10, 2009, 02:28:19 AM »
Quote
Isnt it divide by 2,54?
nope, multiply :P



edit: So what exactly do you guys add to the code that triggers this badISR? Are you guys using interrupts?
« Last Edit: February 10, 2009, 02:33:00 AM by Admin »

Offline HanoushTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Helpful? 0
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #6 on: February 10, 2009, 04:25:20 AM »
I tried to use int instead of long unsigned int but it is the same error. 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. anyway,Thanks a lot for you help. I will try to downgrade and install the source code again.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #7 on: February 10, 2009, 05:07:56 AM »
Quote
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.

If I can narrow the problem down I can squash this bug. When you use this code there is no error?

Code: [Select]
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);
}

Offline HanoushTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Helpful? 0
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #8 on: February 10, 2009, 05:33:15 AM »
Code: [Select]
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
}

you have to remove both delays. I wanted to ask about another thing,how to make the MaxSonar more accurate ?

Offline HanoushTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Helpful? 0
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #9 on: February 10, 2009, 10:12:57 AM »
Thanks Tomas,The error disappeared once I downgraded.

Offline Tomas

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 0
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #10 on: February 10, 2009, 03:28:21 PM »
Dont worry about it.

And to Admin, I will try using 1.05 again (and I will try reproducing the error) when Im back in schedual. Right now Im one week behind on my project because of the problems :) But I will fault search it in a few days.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #11 on: February 10, 2009, 08:10:25 PM »
The main advantage of 1.05 is that is has PWM. If you don't plan to use PWM, just uses the older software for now.

Quote
I wanted to ask about another thing,how to make the MaxSonar more accurate ?
Well, you'd want to use I2C, or at least 10 bit adc and not convert to cm:

MaxVal=a2dConvert10bit(0);

When you convert to cm, you get rounding errors, you don't actually need to convert for the robot to work.

Offline yerbie

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 3
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #12 on: February 10, 2009, 08:49:21 PM »
Quote
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 ?

the reason for the badISR printing out is because there was an uncaught interrupt.  This seems to mean that somehow the delay function is causing some interrupt to be fired that you weren't expecting.  I'll try out your code to see if I can get the same results.  Having the uncaught interrupt is bad because it can cause the axon to spontaneously reboot.

This quote is from the gcc-avr interrupt page: http://www.gnu.org/savannah-checkouts/non-gnu/avr-libc/user-manual/group__avr__interrupts.html
Quote
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.


Offline HanoushTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Helpful? 0
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #13 on: February 11, 2009, 06:23:48 AM »
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 ?

Offline Tomas

  • Full Member
  • ***
  • Posts: 111
  • Helpful? 0
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #14 on: February 11, 2009, 11:31:26 AM »
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 ?

If this is the code you are using, then it works in 1.01 too:

http://www.societyofrobots.com/robotforum/index.php?topic=5590.0

Offline HanoushTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Helpful? 0
Re: Problem with Axon And LV-MaxSonar-EZ0
« Reply #15 on: February 11, 2009, 06:42:12 PM »
I will try it out as soon as I get my motor driver. Thanks a lot  :)

 


Get Your Ad Here

data_list