Author Topic: AXON II, not enough memory or something else?  (Read 2764 times)

0 Members and 1 Guest are viewing this topic.

Offline happy_hippoTopic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
    • Read Stuff Here
AXON II, not enough memory or something else?
« on: July 27, 2011, 07:57:39 PM »
I wrote just a small program to move my newly built hexapod when I press a key in hyperterminal, but already the hex file is 60kb , and when I try to use McUber to program AXON2, I get "flashing failed" message. It works with smaller programs , like 58kb.
The code is not even a walking routine or anything, just small movements of servos... Maybe I've done something wrong?
I followed the tutorial for AXON2 for configuration options in AVR studio (given here: http://www.societyofrobots.com/axon2/axon2_setup1.shtml ).
And here is my source code:


hardware.h
Code: [Select]
/*************************************************************************
Authored by John Palmisano of SocietyofRobots.com
in collaboration with Clive Webster of WebbotLib

2009

intended use for Axon and Axon II

instructions:
This file is where you define all of your intended hardware connected to
your Axon microcontroller. You can set up baud rates for your UART,
specificy which sensors you are using, declare servos, etc.

Keeping this separate from your other code makes code sharing easy.
*************************************************************************/



//////////////////////////LIBRARIES///////////////////////////
//declare sensor libraries (examples are commented out)
//#include <Sensors/Acceleration/DynamicEngineering/ACCM3D2.h>
//#include <Sensors/Compass/Honeywell/HMC6343.h>
//#include <Sensors/Gyro/InvenSense/IDG300.h>
//////////////////////////////////////////////////////////////


/////////////////////////////UART/////////////////////////////
//UART defines (name your UART)
#define GPS_UART UART0
#define USB_UART UART1
#define WIRELESS_UART UART2
#define OTHER_UART UART3
//UART baud defines (change baud rate)
#define GPS_BAUD (BAUD_RATE)9600
#define USB_BAUD (BAUD_RATE)115200
#define WIRELESS_BAUD (BAUD_RATE)9600
#define OTHER_BAUD (BAUD_RATE)38400
//UART define which uart to use
#define GPS_ACTIVATE &uart0SendByte
#define USB_ACTIVATE &uart1SendByte
#define WIRELESS_ACTIVATE &uart2SendByte
#define OTHER_ACTIVATE &uart3SendByte

#define UART2_GET uart2GetByte()
//////////////////////////////////////////////////////////////





/////////////////////////////SERVOS///////////////////////////
//define servo hardware, use TRUE for right side, FALSE for inverted side
//if you use hardware PWM, use only PWM pins
//example: MAKE_SERVO(ROTATION DIRECTION, PIN, CENTER, RANGE)
//arm1 servos
SERVO s_1_1 = MAKE_SERVO(FALSE, L1, 1500, 900);
SERVO s_1_2 = MAKE_SERVO(FALSE, B7, 1500, 900);
SERVO s_1_3 = MAKE_SERVO(FALSE, H3, 1500, 900);

//arm2 servos
SERVO s_2_1 = MAKE_SERVO(FALSE, L2, 1500, 900);
SERVO s_2_2 = MAKE_SERVO(FALSE, B6, 1500, 900);
SERVO s_2_3 = MAKE_SERVO(FALSE, E7, 1500, 900);

//arm3 servos
SERVO s_3_1 = MAKE_SERVO(FALSE, L3, 1500, 900);
SERVO s_3_2 = MAKE_SERVO(FALSE, B5, 1500, 900);
SERVO s_3_3 = MAKE_SERVO(FALSE, E6, 1500, 900);

//arm4 servos
SERVO s_4_1 = MAKE_SERVO(FALSE, L4, 1500, 900);
SERVO s_4_2 = MAKE_SERVO(FALSE, B4, 1500, 900);
SERVO s_4_3 = MAKE_SERVO(FALSE, E5, 1500, 900);

//arm5 servos
SERVO s_5_1 = MAKE_SERVO(FALSE, L5, 1500, 900);
SERVO s_5_2 = MAKE_SERVO(FALSE, H6, 1500, 900);
SERVO s_5_3 = MAKE_SERVO(FALSE, E4, 1500, 900);

//arm6 servos
SERVO s_6_1 = MAKE_SERVO(FALSE, L6, 1500, 900);
SERVO s_6_2 = MAKE_SERVO(FALSE, H5, 1500, 900);
SERVO s_6_3 = MAKE_SERVO(FALSE, E3, 1500, 900);



// Create the list - remember to place an & at the
// start of each servo name
SERVO_LIST jt1[] = {&s_1_1, &s_2_1, &s_3_1, &s_4_1, &s_5_1, &s_6_1};
SERVO_LIST jt2[] = {&s_1_2, &s_2_2, &s_3_2, &s_4_2, &s_5_2, &s_6_2};
SERVO_LIST jt3[] = {&s_1_3, &s_2_3, &s_3_3, &s_4_3, &s_5_3, &s_6_3};


// Create a driver for the list of servos

SERVO_DRIVER bank1 = MAKE_SERVO_DRIVER(jt1);
SERVO_DRIVER bank2 = MAKE_SERVO_DRIVER(jt2);
SERVO_DRIVER bank3 = MAKE_SERVO_DRIVER(jt3);

//////////////////////////////////////////////////////////////




main program: uart_test.c
Code: [Select]
/*************************************************************************
AXON AND AXON II CODE FOR WEBBOTLIB

Authored by John Palmisano of SocietyofRobots.com
in collaboration with Clive Webster of WebbotLib.

For more information, see:
http://www.societyofrobots.com/axon
http://www.societyofrobots.com/axon2
http://sourceforge.net/projects/webbotavrclib

2009

intended use for Axon and Axon II

instructions:
Read comments for explanation of all code.

appInitHardware() is for initiating the Axon.

appControl() is where your code goes. It is similar to control.c
for the original Axon code.

See hardware.h for defining your external hardware.
See sys/axon2.h in WebbotLib to change which pins are input and output.
*************************************************************************/


//allows for printing with features, but uses more memory
#define RPRINTF_FLOAT
#define RPRINTF_COMPLEX

//additional math capabilities
//#include <math.h>

//WebbotLib includes
#include "sys/axon2.h" //defines your MCU (change to axon.h if you use the original Axon)
#include "servos.h" //use for software servo PWM
#include "a2d.h" //use for ADC
#include "rprintf.h" //use for UART
//#include "i2c_master.h" //use for I2C
//#include "buffer.h" //use for GPS and other serial stuff

//user includes
#include "hardware.h"
#include "stdio.h"
#include "string.h"


// In my initialising code - pass the list of servos to control
void appInitHardware(void)
{
//initialize UART ports (see hardware.h to change baud/names)
uartInit(GPS_UART, GPS_BAUD); //UART0
uartInit(USB_UART, USB_BAUD); //USB
uartInit(WIRELESS_UART, WIRELESS_BAUD); //UART2
uartInit(OTHER_UART, OTHER_BAUD); //UART3

// declare USB for output
rprintfInit(WIRELESS_ACTIVATE);

// Initialise the servo controller
//servoPWMInit(&bank1); //use PWM to control servos (must use PWM pins!)
servosInit(&bank1, TIMER1); //use software PWM to control servos (can use any pin)
servosInit(&bank2, TIMER4);
servosInit(&bank3, TIMER5);
// Initiate Sensors (examples commented out)
//accelerometerInit(accm3d2);
//compassInit(hmc6343);
//gyroInit(idg300);

}

TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
rprintf("\nAxon Initiated.\n\n");


return 0;
}




void move_servo(SERVO_LIST* joint_id, short int leg_id, short int servo_position)
{
act_setSpeed((SERVO *)pgm_read_word(&joint_id[leg_id-1]), servo_position);
delay_ms(24);
}



int get_position(SERVO_LIST* joint_id, short int leg_id)
{
return (act_getSpeed((SERVO *)pgm_read_word(&joint_id[leg_id-1])));
}


void move_servo_inc(SERVO_LIST* joint_id, short int leg_id, short int increment)
{
act_setSpeed((SERVO *)pgm_read_word(&joint_id[leg_id-1]), act_getSpeed((SERVO *)pgm_read_word(&joint_id[leg_id]))+increment);
delay_ms(24);
}


void reset_pos ()
{
short int i;
for (i=0; i<6; i++)
{
move_servo(jt1, i, 0);
move_servo(jt2, i, 0);
move_servo(jt3, i, 0);
}
}


void raise_jt(SERVO_LIST* joint_id, short int s_1, short int pos1, short int s_2, short int pos2, short int s_3, short int pos3) {

move_servo(joint_id, s_1, pos1);
move_servo(joint_id, s_2, pos2);
move_servo(joint_id, s_3, pos3);

}



int tempbyte;

// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart)
{
tempbyte=UART2_GET;//get a single character



if (tempbyte=='1') {

servosConnect(&bank1);//turn servos on
servosConnect(&bank2);
servosConnect(&bank3);
rprintf("servos on\n");
}

//power servos
if (tempbyte=='2')
{
servosDisconnect(&bank1);//turn servos off
servosDisconnect(&bank2);
servosDisconnect(&bank3);
rprintf("servos off\n");
}



if (tempbyte=='l') {

{
raise_jt(jt2, 1,  60, 3, 60, 5, -60);
raise_jt(jt3, 1,  60, 3, 60, 5, -60);

delay_ms(3000);


move_servo(jt1, 6, 75);
move_servo(jt2, 6, -5);
move_servo(jt3, 6, -25);


move_servo(jt1, 2, 40);
move_servo(jt2, 2, 5);
move_servo(jt3, 2, 8);



move_servo(jt1, 4, 10);
move_servo(jt2, 4, 15);
move_servo(jt3, 4, 30);





}
}

short int i;
if (tempbyte=='u') {                //send byte from hyperterminal

rprintf("moving arm_x_1 forward\n");

for (i=0; i<6; i++)
{ move_servo_inc(jt1, i, -10);
}



}

if (tempbyte=='o') {
reset_pos();
}

if (tempbyte=='i') {                //send byte from hyperterminal

rprintf("moving arm_x_1 backwards\n");


for (i=0; i<6; i++)
{ move_servo_inc(jt1, i, 10);
}




}





if (tempbyte=='j') {                //send byte from hyperterminal

rprintf("moving arm_x_2 forward\n");


for (i=0; i<3; i++)
{ move_servo_inc(jt2, i, 10);
}

for (i=3; i<6; i++)
{ move_servo_inc(jt2, i, -10);
}


}

if (tempbyte=='k') {                //send byte from hyperterminal

rprintf("moving arm_x_2 backwards\n");
for (i=0; i<3; i++)
{ move_servo_inc(jt2, i, -10);
}

for (i=3; i<6; i++)
{ move_servo_inc(jt2, i, 10);
}

}


if (tempbyte=='n') {                //send byte from hyperterminal

rprintf("moving arm_x_3 forward\n");

for (i=0; i<3; i++)
{ move_servo_inc(jt3, i, 10);
}

for (i=3; i<6; i++)
{ move_servo_inc(jt3, i, -10);
}

}

if (tempbyte=='m') {                //send byte from hyperterminal

rprintf("moving arm_x_3 backwards\n");
for (i=0; i<3; i++)
{ move_servo_inc(jt3, i, -10);
}

for (i=3; i<6; i++)
{ move_servo_inc(jt3, i, 10);
}

}




//print out sensor data



return 34000; // wait for 20ms to stop crazy oscillations (long story)
}



Compiler output.
Quote
Program:   21558 bytes (32.9% Full)
(.text + .data + .bootloader)

Data:        889 bytes (10.9% Full)
(.data + .bss + .noinit)


It's supposed to do some moves when I press different keys in hyperterminal, that's all.

Is this the limit of AXON2 microcontroller?

I guess I can try to write just functions that move each servo only in response to serial port signals and send them in MATLAB. That's what I'll try to do I think.

Thanks
« Last Edit: July 28, 2011, 04:34:20 AM by happy_hippo »
??? -> :D

Offline klims

  • Robot Overlord
  • ****
  • Posts: 190
  • Helpful? 2
Re: AXON II, not enough memory or something else?
« Reply #1 on: July 28, 2011, 06:42:46 AM »
Datasheet says 64k flash. What does the compiler say when you compile? Does it give you a percentage of memory used?

I remember having a problem on my axon 1 I thought was memory related but turned out to be a bad compile I think. I added a few more nonsense lines of code and it worked. Might be worth a shot.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: AXON II, not enough memory or something else?
« Reply #2 on: July 28, 2011, 06:48:25 AM »
It's definitely not the Axon running out of memory, you have plenty memory left.

Try a different bootloader and see if you get the same error.


As a side note, I recommend using the latest version of WebbotLib. It's much better with Project Designer :P

Offline happy_hippoTopic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
    • Read Stuff Here
Re: AXON II, not enough memory or something else?
« Reply #3 on: July 28, 2011, 10:46:03 AM »
I tried adding more code lines, it's still not doing it :(
And no other bootloader other than McUber is working on Windows 7 64 bit :(
??? -> :D

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: AXON II, not enough memory or something else?
« Reply #4 on: July 28, 2011, 10:51:46 AM »
Try and find a Win XP computer to let you test it out . . . it might be a McUber bug.

I attached an Axon II compiled .hex (69.9kb) for my ERP. Give it a try, I know it works.

I recommend disconnecting your electronics stuff from your Axon II before running this .hex. :P

Offline happy_hippoTopic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
    • Read Stuff Here
Re: AXON II, not enough memory or something else?
« Reply #5 on: July 28, 2011, 11:10:51 AM »
yes, your file was successfully flashed. I attached my hex file. And it's not working :(

Maybe I need to try a different compiler other than AVR studio + webbotlib? (installed latest version yesterday).
??? -> :D

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer ยท Roboticist
    • Index of Oddities
Re: AXON II, not enough memory or something else?
« Reply #6 on: July 28, 2011, 01:50:41 PM »
Was "flashing failed" the full extent of the error message, or was there more?

I've not used McUber (still using Fboot17 on my XP laptop, while using Win 7 x64 for everything else...), but I'm definitely curious to know if that's the extent of the info it's error messages give =-x
I

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: AXON II, not enough memory or something else?
« Reply #7 on: July 28, 2011, 02:01:19 PM »
Your file name has 9 characters, reduce it to 8 and try again.

It uploads fine on my XP machine using both FBOOT and a hardware ISP programmer.

Offline happy_hippoTopic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
    • Read Stuff Here
Re: AXON II, not enough memory or something else?
« Reply #8 on: July 28, 2011, 02:20:23 PM »
McUber just says: "Flashing Failed" that's all. Even with 8 or less character in the name.

Anyway, I decided to take a different approach, by using MATLAB to send commands via serial port , instead of having complex walking routines flashing in the controller.

Hopefully I won't have any problems in the future.



Aside:
I also upgraded to AVR studio 5. Testing it for now. It has better syntax  editing options. But it's very similar to studio 4.


Also, I found that latest Webbotlib version 1.33 made my program completely useless. So I spent all day trying to find out why my new program wasn't working. Downgraded to 1.31 and it's working again
(though it's a different topic to what I posted here).

??? -> :D

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: AXON II, not enough memory or something else?
« Reply #9 on: July 28, 2011, 02:30:05 PM »
So, the flashing works with Matlab?


When I said latest WebbotLib version, I meant v2.06.  :P

Offline happy_hippoTopic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
    • Read Stuff Here
Re: AXON II, not enough memory or something else?
« Reply #10 on: July 28, 2011, 02:46:58 PM »
no no, MATLAB is not related to flashing, it's just a good computational, scientific software that can send bytes via serial port (like hyperterminal).

I meant that I will rewrite my program completely, and hope that there won't be flashing error.


OMG, for some reason webbotlib website had versions 1.x expanded, and I always downloaded those 1.33 ect. But now I found another folder Version 2 (as you suggested). I guess it will be much much better. I'll try it now.

Thanks :)
??? -> :D

Offline happy_hippoTopic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
    • Read Stuff Here
Re: AXON II, not enough memory or something else?
« Reply #11 on: July 28, 2011, 03:05:47 PM »
hmm, a bit off topic, but there is no sys/axon2.h   library anymore in webbotlib 2.06.  

Maybe I need to copy 1.33 , and then copy 2.06 on top of it? or somthing?
Thanks


Nope, that didn't work. Tonnes of compiler errors if I do that.

Nah, I think I will stick with 1.33. Can't get 2.06 to work at all.
« Last Edit: July 28, 2011, 03:20:19 PM by happy_hippo »
??? -> :D

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: AXON II, not enough memory or something else?
« Reply #12 on: July 28, 2011, 03:44:40 PM »
You need to use Project Designer:

http://www.youtube.com/watch?v=vWG1rfwgAX0

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: AXON II, not enough memory or something else?
« Reply #13 on: July 28, 2011, 06:47:53 PM »
You need to use Project Designer:


You know admin, while I'm kinda against having a program do all the work for you (it takes the fun out for me  :P), that's pretty impressive.

Very good work between you and webbot (and whoever else was involved).  BTW, I pronounce it with a long e like in beef.  Dunno why lol. 

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: AXON II, not enough memory or something else?
« Reply #14 on: July 28, 2011, 07:00:18 PM »
Look at it this way: it frees up the time you would have spent getting boring low-level stuff working so now you have more time to do high level interesting stuff. :P

WebbotLib is like 95% all his work. I'm just a heavy debugger/tester, software pusher, and sounding board for ideas. :P

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: AXON II, not enough memory or something else?
« Reply #15 on: July 28, 2011, 08:12:09 PM »
Look at it this way: it frees up the time you would have spent getting boring low-level stuff working so now you have more time to do high level interesting stuff. :P

I've heard and acknowledged that argument before.  My counter point is if you didn't design it and something goes wrong, it'll be hard as heck to debug it.  Or if you want to do something that isn't normal or use a very rare sensor etc.  Besides, once you get good with low level stuff it's easy and doesn't take THAT long.   :)

EDIT:  Ohhhhh related article I just came across.  http://lifehacker.com/5825756/increase-your-brain-power-by-doing-things-the-hard-way  :P :P

Anyway, to contribute, since you have an axon (or axon II) and you have such awesome software programs at your disposal, I'd suggest you use them.  
« Last Edit: July 28, 2011, 08:14:47 PM by corrado33 »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: AXON II, not enough memory or something else?
« Reply #16 on: July 28, 2011, 08:15:30 PM »
Webbot is very responsive in helping people debug their WebbotLib software, no worries on that issue. ;D

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: AXON II, not enough memory or something else?
« Reply #17 on: July 29, 2011, 08:48:34 PM »
hmm, a bit off topic, but there is no sys/axon2.h   library anymore in webbotlib 2.06.  

Maybe I need to copy 1.33 , and then copy 2.06 on top of it? or somthing?
Thanks


Nope, that didn't work. Tonnes of compiler errors if I do that.

Nah, I think I will stick with 1.33. Can't get 2.06 to work at all.

With the Version 2 code stream you MUST use Project Designer. If your board isn't listed (or its a home made one) then you can use Board Designer to create your own board design that you can then use in Project Designer.

The Version 1 code stream won't be supported for much longer. Some of the new sensors etc are only being added into Version 2. Mainly coz its too much effort trying to support Version 1, Version 2, with support for using C or C++ and therefore different manuals.

Edit:- And if you look at the release notes in 'version.h' you will see the changes between 1.31 and 1.33 which will probably explain whats up with your program. The examples in the docs show these changes. If you are using Project Designer then you don't have to worry as it generates the correct code for you.
« Last Edit: July 29, 2011, 09:02:13 PM by Webbot »
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

 


data_list