Society of Robots - Robot Forum
|
Robot Tutorials
|
FAQ
|
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Squirrels have fuzzy tails.
Home
Help
Search
Login
Register
Society of Robots - Robot Forum
»
Software
»
Software
»
OMG !!!!!! "Hex file too large for target !"
Print
Author
Topic: OMG !!!!!! "Hex file too large for target !" (Read 4472 times)
0 Members and 1 Guest are viewing this topic.
Hasan999
Full Member
Posts: 75
Helpful? 1
OMG !!!!!! "Hex file too large for target !"
«
on:
December 25, 2009, 01:52:32 PM »
I thought Axon would have enough memory !??....
After programming (and even after reducing stuff) I could make my Axon.hex file to 204 kb...which Microcontroller can't handle !?
(Bootloader: it gives error: Axon.h to large for target! ..something like that and it closes)
I have only Axon.c and SoR_Utils.h in the Project ...!!
I haven't even done 50% of the programming yet....
What should I do ??
Thanks..
Logged
SmAsH
Supreme Robot
Posts: 3,959
Helpful? 75
SoR's Locale Electronics Nut.
Re: OMG !!!!!! "Hex file too large for target !"
«
Reply #1 on:
December 25, 2009, 05:08:02 PM »
Axon has 64kb of flash, that must be a gigantic program for it to take up 204kb!
My advice is to get another microcontroller or see if the axon can take external flash memory.
May i ask, what is the program for? I've never come across a program that big before
Logged
Howdy
Hasan999
Full Member
Posts: 75
Helpful? 1
Re: OMG !!!!!! "Hex file too large for target !"
«
Reply #2 on:
December 25, 2009, 05:43:48 PM »
You'll probably laugh when I'll tell you what made the program so heavy.........
I'm building a 24 Degrees of freedom (transformable) robot... (hence 24+ servos)
I tried a lot to understand PWM timers etc, to control multiple servo's simultaneously.......but I failed ! - I just can't get it !!
But, I'm not bad in C programming, so what I did is...
I transformed the simple servo controller code "servo(PORTA,1,700);" in such a way (using lots of shortcuts, i.e. #Define) that I can now easily control as many Servo's at a time and at different intervals and speed !...
after a lot of crap (hell loads of programming), I made it as simple as this: (just an example):
delay(); SSS;
Servo1(position,speed);
delay(); SSS;
delay(); SSS;
delay(); SSS;
Servo(position,speed); Servo2(position, speed); Servo3(position, speed);
...
delay(); SSS;
delay(); SSS;
delay(); SSS;
Servo(position,speed);
.
.
.
where delays act like a timeline (each line wastes 0.2s) and I can put the
green
Servo commands anywhere as many I want, to control the servos at known intervals.
I succeeded
... it took me only 3 hours to do so !...worked perfectly !
THE PROBLEM:
I have 24 Servo's lol... and It already overloaded with a few servo commands :/
I really need some help
«
Last Edit: December 25, 2009, 05:45:21 PM by Hasan999
»
Logged
Razor Concepts
Supreme Robot
Posts: 1,856
Helpful? 53
Re: OMG !!!!!! "Hex file too large for target !"
«
Reply #3 on:
December 25, 2009, 05:54:27 PM »
You have to post the code before we can find why it is so large.
Logged
www.razorconcepts.net
SmAsH
Supreme Robot
Posts: 3,959
Helpful? 75
SoR's Locale Electronics Nut.
Re: OMG !!!!!! "Hex file too large for target !"
«
Reply #4 on:
December 25, 2009, 05:56:03 PM »
And please put [ code ] at the start and [/ code ] at the end. (without the spaces)
I hate giant code chunks posted without it, they take up most of the page.
«
Last Edit: December 25, 2009, 06:10:39 PM by SmAsH
»
Logged
Howdy
Hasan999
Full Member
Posts: 75
Helpful? 1
Re: OMG !!!!!! "Hex file too large for target !"
«
Reply #5 on:
December 25, 2009, 06:01:46 PM »
lol.... btw.. my Code won't look so large... and I can bet, no one would be able to understand it...
(its just the way I do C programming... its for myself)
here goes...
«
Last Edit: December 25, 2009, 06:26:19 PM by Hasan999
»
Logged
Hasan999
Full Member
Posts: 75
Helpful? 1
Re: OMG !!!!!! "Hex file too large for target !"
«
Reply #6 on:
December 25, 2009, 06:10:04 PM »
All of this in Axon.c (no other .c files used) ...this one is reduced, only 9 out of 24 servos :p [Axon can't handle it if I add anything now]
#define d(x) delay_ms(x)
//Variables:
int lp = 0; int n1;int n2;int n3;int n4;int n5;int n6;int n7;int n8; int n9; int n10; int n11;
//Servos:
#define s1(pos1) servo(PORTE,4,pos1)
#define s2(pos2) servo(PORTA,1,pos2)
#define s3(pos3) servo(PORTA,2,pos3)
#define s4(pos4) servo(PORTA,3,pos4)
#define s5(pos5) servo(PORTA,4,pos5)
#define s6(pos6) servo(PORTA,5,pos6)
#define s7(pos7) servo(PORTA,6,pos7)
#define s8(pos8) servo(PORTA,7,pos8)
#define s9(pos9) servo(PORTA,8,pos9)
#define servo1(p,s) switch (p) {case 0:x1=s1r0;break; case 45:x1=s1r45;break; case 90:x1=s1r90;break; case 135:x1=s1r135;break; case 180:x1=s1r180;break;}; switch (s) {case 1:N1a;break; case 2: N1b;break;};
//Servo Controller:
#define SS1 if(n1>0){if(p1<x1){s1(p1);p1+=n1;}else{if(p1<(x1+(2+n1*2))){s1(x1);p1+=n1;}}}else{if(p1>x1){s1(p1);p1+=n1;}else{if(p1>(x1-((-n1*2)-2))){s1(x1);p1+=n1;}}}
#define SS2 if(n2>0){if(p2<x2){s2(p2);p2+=n2;}else{if(p2<(x2+(2+n2*2))){s2(x2);p2+=n2;}}}else{if(p2>x2){s2(p2);p2+=n2;}else{if(p2>(x2-((-n2*2)-2))){s2(x2);p2+=n2;}}}
#define SS3 if(n3>0){if(p3<x3){s3(p3);p3+=n3;}else{if(p3<(x3+(2+n3*2))){s3(x3);p3+=n3;}}}else{if(p3>x3){s3(p3);p3+=n3;}else{if(p3>(x3-((-n3*2)-2))){s3(x3);p3+=n3;}}}
#define SS4 if(n4>0){if(p4<x4){s4(p4);p4+=n4;}else{if(p4<(x4+(2+n4*2))){s4(x4);p4+=n4;}}}else{if(p4>x4){s4(p4);p4+=n4;}else{if(p4>(x4-((-n4*2)-2))){s4(x4);p4+=n4;}}}
#define SS5 if(n5>0){if(p5<x5){s5(p5);p5+=n5;}else{if(p5<(x5+(2+n5*2))){s5(x5);p5+=n5;}}}else{if(p5>x5){s5(p5);p5+=n5;}else{if(p5>(x5-((-n5*2)-2))){s5(x5);p5+=n5;}}}
#define SS6 if(n6>0){if(p6<x6){s6(p6);p6+=n6;}else{if(p6<(x6+(2+n6*2))){s6(x6);p6+=n6;}}}else{if(p6>x6){s6(p6);p6+=n6;}else{if(p6>(x6-((-n6*2)-2))){s6(x6);p6+=n6;}}}
#define SS7 if(n7>0){if(p7<x7){s7(p7);p7+=n7;}else{if(p7<(x7+(2+n7*2))){s7(x7);p7+=n7;}}}else{if(p7>x7){s7(p7);p7+=n7;}else{if(p7>(x7-((-n7*2)-2))){s7(x7);p7+=n7;}}}
#define SS8 if(n8>0){if(p8<x8){s8(p8);p8+=n8;}else{if(p8<(x8+(2+n8*2))){s8(x8);p8+=n8;}}}else{if(p8>x8){s8(p8);p8+=n8;}else{if(p8>(x8-((-n8*2)-2))){s8(x8);p8+=n8;}}}
#define SS9 if(n9>0){if(p9<x9){s9(p9);p9+=n9;}else{if(p9<(x9+(2+n9*2))){s9(x9);p9+=n9;}}}else{if(p9>x9){s9(p9);p9+=n9;}else{if(p9>(x9-((-n9*2)-2))){s9(x9);p9+=n9;}}}
//All Servos:
#define SSS SS1;SS2;SS3;SS4; SS5;SS6;SS7;SS8;SS9;SS10;SS11;//SS12;SS13;SS14;SS15;SS16;SS17;SS18;SS19;SS20;SS21;SS22;SS23;SS24;
//Center Position:
#define s1r90 680
#define s2r90 700
#define s3r90 700
#define s4r90 700
#define s5r90 700
#define s6r90 700
#define s7r90 700
#define s8r90 700
#define s9r90 700
//Center Servos:
for(uint16_t i=0;i<25;i++){
s1(s1r90);
s2(s2r90);
s3(s3r90);
s4(s4r90);
s5(s5r90);
s6(s6r90);
s7(s7r90);
s8(s8r90);
d(18);}
//Speed: Na = High Speed, Nb = Low Speed
#define N1a if(x1>p1){n1=25;}else{n1=-25;}
#define N1b if(x1>p1){n1=16;}else{n1=-16;}
#define N2a if(x2>p2){n2=25;}else{n2=-25;}
#define N2b if(x2>p2){n2=16;}else{n2=-16;}
#define N3a if(x3>p3){n3=25;}else{n3=-25;}
#define N3b if(x3>p3){n3=16;}else{n3=-16;}
#define N4a if(x4>p4){n4=25;}else{n4=-25;}
#define N4b if(x4>p4){n4=16;}else{n4=-16;}
#define N5a if(x5>p5){n5=25;}else{n1=-25;}
#define N5b if(x5>p5){n5=16;}else{n1=-16;}
#define N6a if(x6>p6){n6=25;}else{n2=-25;}
#define N6b if(x6>p6){n6=16;}else{n2=-16;}
#define N7a if(x7>p7){n7=25;}else{n3=-25;}
#define N7b if(x7>p7){n7=16;}else{n3=-16;}
#define N8a if(x8>p8){n8=25;}else{n4=-25;}
#define N8b if(x8>p8){n8=16;}else{n4=-16;}
//Positions:
int s1r180 = s1r90 + 415; int s1r0 = s1r90 - 415; int s1r135 = (s1r90 + 415/2); int s1r45 = (s1r90 - 415/2);//
int s2r180 = s2r90 + 415; int s2r0 = s2r90 - 415; int s2r135 = (s2r90 + 415/2); int s2r45 = (s2r90 - 415/2);//
int s3r180 = s3r90 + 415; int s3r0 = s3r90 - 415; int s3r135 = (s3r90 + 415/2); int s3r45 = (s3r90 - 415/2);//
int s4r180 = s4r90 + 415; int s4r0 = s4r90 - 415; int s4r135 = (s4r90 + 415/2); int s4r45 = (s4r90 - 415/2);//
int s5r180 = s5r90 + 415; int s5r0 = s5r90 - 415; int s5r135 = (s5r90 + 415/2); int s5r45 = (s5r90 - 415/2);//
int s6r180 = s6r90 + 415; int s6r0 = s6r90 - 415; int s6r135 = (s6r90 + 415/2); int s6r45 = (s6r90 - 415/2);//
int s7r180 = s7r90 + 415; int s7r0 = s7r90 - 415; int s7r135 = (s7r90 + 415/2); int s7r45 = (s7r90 - 415/2);//
int s8r180 = s8r90 + 415; int s8r0 = s8r90 - 415; int s8r135 = (s8r90 + 415/2); int s8r45 = (s8r90 - 415/2);//
int s9r180 = s9r90 + 415; int s9r0 = s9r90 - 415; int s9r135 = (s9r90 + 415/2); int s9r45 = (s9r90 - 415/2);//
//Initial Position:
int p1 = s1r90; int x1 = s1r90;
int p2 = s2r90; int x2 = s2r90;
int p3 = s3r90; int x3 = s3r90;
int p4 = s4r90; int x4 = s4r90;
int p5 = s5r90; int x5 = s5r90;
int p6 = s6r90; int x6 = s6r90;
int p7 = s7r90; int x7 = s7r90;
int p8 = s8r90; int x8 = s8r90;
int p9 = s9r90; int x9 = s9r90;
/* Each line = 0.2s */ d(2000); servo1(180,1); //servoX(position, speed)
for(lp=0;lp<10;lp++){d(20);SSS};
for(lp=0;lp<10;lp++){d(20);SSS};
for(lp=0;lp<10;lp++){d(20);SSS}; servo1(0,2); servo2(135,1);
for(lp=0;lp<10;lp++){d(20);SSS};
for(lp=0;lp<10;lp++){d(20);SSS};
ok don't say WTF, ...honestly, this is how I program...
..cuz otherwise, it would be tooo long !
the SS1, SS2, etc equations take all the memory actually, but that's the most imp thing of the whole program !
anyway ... have fun going thru it :p
Logged
Razor Concepts
Supreme Robot
Posts: 1,856
Helpful? 53
Re: OMG !!!!!! "Hex file too large for target !"
«
Reply #7 on:
December 25, 2009, 06:17:06 PM »
You should change the code.. so there isn't anything that is based on each servo.
For example, say you were programming a Pokemon game. You wouldnt code each and every single monster, you would create a class or object called "monster", and that would save a ton of space.
Look up structs, that would help... object oriented programming will save you tons of space here!!
Logged
www.razorconcepts.net
Hasan999
Full Member
Posts: 75
Helpful? 1
Re: OMG !!!!!! "Hex file too large for target !"
«
Reply #8 on:
December 25, 2009, 06:25:25 PM »
The problem is... each servo will eventually have to be controlled independently and varying speeds and intervals...
and SINCE i didn't make use of PWM etc, I had to program the normal "servo(PORTX,N,Position) for every servo...
However, i'll still try to group things somehow..
[right now, its too late over here - Im off ... will check this forum after 12 hours from now - hope to see some more advises]
«
Last Edit: December 25, 2009, 06:27:31 PM by Hasan999
»
Logged
frank26080115
Supreme Robot
Posts: 322
Helpful? 2
Re: OMG !!!!!! "Hex file too large for target !"
«
Reply #9 on:
December 25, 2009, 10:01:48 PM »
dude, get a dedicated servo controller... i'm the kind of person that hates buying "solutions" but this is the kind of thing that calls for it
or make your own, i have code for a serial controlled version that handles 8 servos with an attiny2313, you should port it over to a MCU that supports TWI and then put 3 of them on one TWI bus to do 24
from the looks of the code, it shouldn't even work even if it did fit
Logged
http://frank.circleofcurrent.com/
Admin
Administrator
Supreme Robot
Posts: 11,704
Helpful? 173
Re: OMG !!!!!! "Hex file too large for target !"
«
Reply #10 on:
December 26, 2009, 12:56:33 AM »
I agree with Razor, you need to start using functions and structs.
My ERP, with all code I've ever written for it, combined, and optimization turned off, it still came out to be under 33kb. My robot fish has 20 servos, with huge arrays to define motions for them, and that doesn't even come close to half the 64kb on the Axon.
You may want to read the C code optimization tutorial:
http://www.societyofrobots.com/member_tutorials/node/202
Logged
subscribe to SoR's YouTube account
Print
Society of Robots - Robot Forum
»
Software
»
Software
»
OMG !!!!!! "Hex file too large for target !"
SMF spam
blocked by CleanTalk