Society of Robots - Robot Forum

Software => Software => Topic started by: Aberg098 on April 04, 2011, 11:51:27 AM

Title: Axon2 and Hello World
Post by: Aberg098 on April 04, 2011, 11:51:27 AM
I have a question regarding the output of basic "Hello World" program and the Axon2.

I  run a program where there is a simple rprintf("Hello World") command, which the output set to USB. I can read the numerous Hello World lines on Hyperterminal just fine, however every couple of seconds something seems to glitch. For example, the glitches look like:

Hello WoúHello World
Hello WorldHello World

What is happening here? It seems to me like the Axon is chopping up part of the message and restarting anew.
Title: Re: Axon2 and Hello World
Post by: Webbot on April 04, 2011, 02:17:20 PM
Are you using WebbotLib? If so what version?
Title: Re: Axon2 and Hello World
Post by: Aberg098 on April 04, 2011, 02:36:51 PM
I am using webbotlib version 1.30.

Edited to add: Am I using the wrong version?
Title: Re: Axon2 and Hello World
Post by: Admin on April 07, 2011, 08:16:21 PM
Is there any other code running other than that rprintf?

Also, are the LEDs flashing? It could be that your Axon battery is low, causing it to reset, thereby causing that glitch.

Does that glitch constantly happen, or just once during power up?
Title: Re: Axon2 and Hello World
Post by: Aberg098 on April 11, 2011, 11:00:27 AM
Hello Admin,

There is no other code running, literally just printing hello world. The battery is fully charged and the errors occur at random, not at power-up. I am just leaving the AxonII on, and leaving it on for a while.  I can't comment on frequency or amount of errors because I haven't counted them.

What I do see, is that scrolling through hyperterminal after maybe 5 minutes, I get some errors as I have described below.
Title: Re: Axon2 and Hello World
Post by: Admin on April 11, 2011, 03:46:17 PM
Does the LED flash during the error?

Tell us about your battery.
Title: Re: Axon2 and Hello World
Post by: Aberg098 on April 12, 2011, 12:38:01 PM
Just to clarify the code part:
Code: [Select]
#include "hardware.h"

// Initialise the hardware
void appInitHardware(void) {
initHardware();
}

// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
return 0;
}

// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

// -------- Start Switch/Button-------
// Switch/Button - see switch.h

// To test if it is pressed then
if(SWITCH_pressed(&button)){
// pressed
}

// To test if it is released then
if(SWITCH_released(&button)){
// released
}
// -------- End   Switch/Button-------

// -------- Start Marquee-------
// Marquee - see 'segled.h'
// Before using the Marquee you need to redirect rprintf to write to it
// This can be done using
Writer old = rprintfInit(marqueeGetWriter(&marquee));

// All rprintf output will then be sent to the marquee but will not
// display until an end-of-line eg "\n" has been sent. Example:-
// rprintf("Hello World\n");

// If the endDelay is non-zero then the marquee will scroll
// forever or until you call: marqueeStop(&marquee);

// If the endDelay is zero then the marquee will stop once
// the entire line has been shown ('one-shot' mode)

// In 'one-shot' mode then you may want to make sure that
// a previous line has finished before you display a second line.
// This can be done as follows:-
marqueeSetEndDelay(&marquee,0); // Make sure we are in one-shot mode
if(marqueeIsActive(&marquee)==FALSE){
     if(loopCount==1){
      rprintf("HELLO WORLD\n");
     }else{
rprintf("Loop=%u\n",(unsigned)loopCount); // Put the loop count
     }
}

// Restore rprintf back to its previous location
rprintfInit(old);
// -------- End   Marquee-------
rprintf("Hello World\n");
return 0;
}
I have also made sure to be using the latest versions of project designer and webbotlib.

As for the LED, it stays nice and shiny red all the time. It's hard for me to spot the errors since the messages are outputted very quickly. The 7-segment displays a loop counter I think. For example, loop49823, loop61574 and so on.

I have a few different batteries: Right now I am using a 1000 mAh 9.6V Ni-cad. I am trying out some 1400mAh Li-ions. I have used a simple square "D" cell battery in the past. What would the batteries have to do with this?

Title: Re: Axon2 and Hello World
Post by: Webbot on April 13, 2011, 12:34:03 PM
Hmmm, the only time I've seen funnies is using other terminal emulators. For example: I've been using RealTerm for a while and if you keep hitting it repeatedly at 115200 baud then it just hangs. Spent ages checking my code only to discover it was the terminal emulator to blame - and everything worked fine with other emulators. Not sure what baud rate you are using. Have you tried it at slower speeds?

If all else fails then send me your whole project (ie everything needed to compile) so that I can compile it and take a look.
Title: Re: Axon2 and Hello World
Post by: garrettg84 on April 13, 2011, 12:40:00 PM
Do the libs use/implement a serial queue/buffer? Could the queue/buffer be wrapping if the axon can generate the 'hello world's faster than the serial can transmit?

*edit: axon, not arduino
Title: Re: Axon2 and Hello World
Post by: Aberg098 on April 13, 2011, 01:00:57 PM
Well, to answer to the last few comments.

Title: Re: Axon2 and Hello World
Post by: Webbot on April 13, 2011, 01:33:28 PM
Well rather than spending your time to come up with stats on how often you are getting glitches - then send me your code so that I can find out whats causing the glitches (or at least say 'works for me so must be your set up'.

@garretg84 WebbotLib allows you to use buffers (of whatever size you like, including zero). And 'no' its not an overlap issue as the lib traps all of that ie it waits until there is space in the buffer. But thanks for the input.