Author Topic: AXON II - Freezes after first loop  (Read 2557 times)

0 Members and 1 Guest are viewing this topic.

Offline teoxanTopic starter

  • Full Member
  • ***
  • Posts: 49
  • Helpful? 2
AXON II - Freezes after first loop
« on: August 31, 2010, 12:49:14 PM »

I have a strange problem today with the Axon2.

I have attached a TPA81, a CMPS03 compass and a Sharp IR. Program loads ok but Axon runs it only once and then "freezes". No output, it just "stands" there.
I tried to turn it off and on again and still the same problem.

The TPA81 and the compass use I2C, I have a simple I2C expansion board, bought from Robotics Connection. I have also tried this separately, with no luck.

I thought it was a battery problem, so I put a new fresh one, but I have still the same problem..

I have attached my code below, please note that yesterday it was running ok and I haven't changed anything.

Code: [Select]
#include "sys\axon2.h"
#include "led.h"
#include "rprintf.h"
#include "hardware2.h"
#include "a2d.h"
#include "C:\My_Robot\WebbotLib\Sensors\Distance\Sharp\GP2.h"
#include "C:\My_Robot\WebbotLib\Sensors\Distance\Devantech\SRF05_Sonar.h"
#include "math.h"
#include "rprintf.h"
#include "C:\My_Robot\WebbotLib\servos.h"
#include "Servos/Devantech/SD21.h"
#include "C:\My_Robot\WebbotLib\Sensors\Temperature\Devantech\TPA81.h"
#include "Sensors/Compass/Devantech/CMPS03.h"

#define RPRINTF_FLOAT
#define RPRINTF_COMPLEX

uint8_t led_value;

Devantech_TPA81 tpa=MAKE_Devantech_TPA81_At(0xD0);
CMPS03_I2C cmps03=MAKE_CMPS03_I2C_At(0xC0);
Sharp_GP2D12 sharp = MAKE_Sharp_GP2D12(ADC0);


void appInitHardware(void){

uartInit(USB_UART, USB_BAUD);
       
rprintfInit(USB_ACTIVATE);
   
distanceInit(sharp);
compassInit(cmps03);
temperatureInit(tpa);
}

TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
rprintf("\nAxon initiated.\n\n");
return 0;
}

/
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){
 
  compassRead(cmps03);
rprintf("CMPS03 = %d\n",cmps03.compass.bearingDegrees);
distanceRead(sharp);
delay_ms(70);
led_value=interpolate(sharp.distance.cm,0,30,0,9);//stretch value for LED display
   
  led_put_char(led_value);
  temperatureRead(tpa);

distanceDump(sharp);
rprintf("\n%d", sharp.distance.cm);
rprintf("\nmine %d",(long int)(1384.4*pow(a2dConvert8bit(ADC_NUMBER_TO_CHANNEL(0)),-.9988)));
rprintf("\n");

rprintf("\nTemperature: ");
rprintf("\n%d", tpa.temperature.celsius);
rprintf("\n%d", tpa.sensor[0]);
    rprintf("\n%d", tpa.sensor[1]);
rprintf("\n%d", tpa.sensor[2]);
rprintf("\n%d", tpa.sensor[3]);
rprintf("\n%d", tpa.sensor[4]);
rprintf("\n%d", tpa.sensor[5]);
rprintf("\n%d", tpa.sensor[6]);
rprintf("\n%d", tpa.sensor[7]);
rprintf("\n");




return 20000;
}



Any help would be greatly appreciated!

Thanks

Theo

P.S. my Axon2 is a brand new one...

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: AXON II - Freezes after first loop
« Reply #1 on: August 31, 2010, 04:45:36 PM »
This is a 'feature' of WebbotLib. If it can't access an external device, WebbotLib will cause your mcu to freeze without any debugging information.

Webbot doesn't want to add this in for memory limitations of much less powerful mcu's, but I really think it should be added in . . . anyways . . .

There is something you aren't doing right with your I2C bus in terms of hardware. Check your wiring and also make sure the two sensors aren't conflicting with each other (try one at a time).


ps - Here is where Webbot chimes in and throws a big rock at me for this :P
(his code is still way more awesome than anything else you could use, or throw a rock at)
« Last Edit: August 31, 2010, 04:46:47 PM by Admin »

Offline teoxanTopic starter

  • Full Member
  • ***
  • Posts: 49
  • Helpful? 2
Re: AXON II - Freezes after first loop
« Reply #2 on: August 31, 2010, 04:56:59 PM »

Thanks Admin,

I tried the two sensors one at a time, the compass is working fine, but the TPA gives me 0s. I tested the TPA with the Devantech's USB-ISC module directly connected to
my computer and it works fine, so no damaged TPA81.

I also changed the wires, but no luck, so I'm out of any solutions at the moment.

Theo

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: AXON II - Freezes after first loop
« Reply #3 on: August 31, 2010, 05:01:06 PM »
This is a 'feature' of WebbotLib.

Hehe, we have many of these 'features' in the million $ robots I use at work.

There should at least be a flashy error message. I have always like the flashy error messages for when i messed something up. I though "Can't read sensor" would at least be in there as well.

Commence rock slinging.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: AXON II - Freezes after first loop
« Reply #4 on: August 31, 2010, 05:04:24 PM »
Hi teoxan

Can you define what you mean by 'runs once'
 
ie What 'runs once'? appControl, or one of the appInit routines

What happens if your program only uses one device: ie just TPA81 and nothing else? Does it work?




Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: AXON II - Freezes after first loop
« Reply #5 on: August 31, 2010, 05:15:06 PM »
This is a 'feature' of WebbotLib.

Hehe, we have many of these 'features' in the million $ robots I use at work.

There should at least be a flashy error message. I have always like the flashy error messages for when i messed something up. I though "Can't read sensor" would at least be in there as well.

Commence rock slinging.

Its a question of how far do you go? 

Admin recently had a problem due to a bad solder connection (yep - happens to him as well) and wanted the system to dump out all sorts of text debug help. The library already said 'it aint working' via an error return. No 'flashing lights' as the error was 'you have no sdCard inserted' which can be sorted out at runtime by inserting the card - so it isn't a fatal error and can be handled in software eq: while(cardInit() == false){ tell user; }

But storing all these text debug messages eats up program space - and for a 'working board' will never be used.

So on the one hand I have people asking if WebbotLib can work on an ATtiny with 4kb and on the other people asking if it can emit enough debug info to solve their soldering problems!

No pleasing some people !

Carry on throwing rocks - they are bouncing off nicely !!


Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: AXON II - Freezes after first loop
« Reply #6 on: August 31, 2010, 05:19:59 PM »

Thanks Admin,

I tried the two sensors one at a time, the compass is working fine, but the TPA gives me 0s. I tested the TPA with the Devantech's USB-ISC module directly connected to
my computer and it works fine, so no damaged TPA81.

I also changed the wires, but no luck, so I'm out of any solutions at the moment.

Theo


Can you send me your source code - including any H files. Not sure if you are using Project Designer or not?
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: AXON II - Freezes after first loop
« Reply #7 on: August 31, 2010, 05:34:51 PM »
The library already said 'it aint working' via an error return.

That's acceptable. Admin made it sound like it did nothing and just locked up.

To me, if say my I2C compass became unplugged and all the Axon did was lock up, that's not cool. I make it a habit to check all the error returns in my code with my own printf debug sentences. That's how I caught the fact the library was denying 10hz sensor reads of my 10hz compass.

Also, could a generic "external fault" error message be used for anything related to sensors or devices outside the Atmega core? Save on memory but alert through flashy error that something is up. Instruct the user to find the offender through process of elimination. Just a thought on a middle ground.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: AXON II - Freezes after first loop
« Reply #8 on: August 31, 2010, 05:41:44 PM »
Quote
That's acceptable. Admin made it sound like it did nothing and just locked up.
Actually, it does lock up. Absolutely nothing happens, at all. Nadda.


Quote
But storing all these text debug messages eats up program space - and for a 'working board' will never be used.

So on the one hand I have people asking if WebbotLib can work on an ATtiny with 4kb and on the other people asking if it can emit enough debug info to solve their soldering problems!
I also had the idea of having a 'debug.h' that is only added for mcu's with large memories . . . why limit the Axon for an ATtiny?

But Webbot threw a rock back saying it complicated everything having multiple codes for different mcus. And that was that :P

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: AXON II - Freezes after first loop
« Reply #9 on: August 31, 2010, 05:56:19 PM »
I also had the idea of having a 'debug.h'

Better yet a '#define debug'  that enables debug library wide. I've seen #ifdef debug lines in the various h files, it would be nice to bring that out to the end user.

*thinks for a second*

Crap, won't work with pre-compiled files. I'm been meaning to post the question how do we get rid of the pre-compiled .a files and compile from source every time, since you give us the source anyway; it's actually become an issue at work where they don't like me using a pre-compiled library, especially from a foreign national. (No offense). But that's for another post, I don't want to pollute here more then I already have.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: AXON II - Freezes after first loop
« Reply #10 on: August 31, 2010, 06:26:55 PM »
I suggest that this is taken off line, or elsewhere, as it has nothing to do with Theo's original post.

Some people seem to be 're-writing the past and the present' in a different light and are beating me up when their code doesn't work coz their hardware is flakey, not plugged in or has intermittent dry joints.

Despite me spending hours to try and help that individual to solve their problems over 10 days ago then the only feedback I've had is - 'yes its my hardware problem which I have fixed but I've not had time to re-test the code'. So not sure what else I can do to help people if thats all the communication I get.

As for '#define debug' then madsci has answered his own, and Admins, question - it wont work with precompiled libs as its a 'pre-processor' statement.

On the plus side - whilst it may be a loss for the US/Navy then it can still be a plus for the rest of the world  :P

How do we "get rid of pre-compiled libraries" - Make everyone use Project Designer whereby the pre-compiled code can also be MUCH smaller and may even run on ATtiny chips.












Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline teoxanTopic starter

  • Full Member
  • ***
  • Posts: 49
  • Helpful? 2
Re: AXON II - Freezes after first loop
« Reply #11 on: September 01, 2010, 03:11:03 AM »



Can you send me your source code - including any H files. Not sure if you are using Project Designer or not?




I have e-mailed you my code, also a code generated with Project Designer.

I come to believe it is a hardware problem, from bad cables to faulty pins..

any resulets you come up, let me know.

Thanks, I appreciate!

theo

 


Get Your Ad Here

data_list