OpenServo.com Forum Index OpenServo.com
Discussion of the OpenServo project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Space on the AVR?

 
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software
View previous topic :: View next topic  
Author Message
Zeddicus



Joined: 21 May 2006
Posts: 109

PostPosted: Thu Jun 01, 2006 6:54 pm    Post subject: Space on the AVR? Reply with quote

Hi,

I was wondering: how much of the 16K of the 168 is currently being used? And how much would the code grow if we were to use floats in the calculations? It would really be much better from a control point of view to use floating point calculations.

ZZZ
Back to top
View user's profile Send private message
mpthompson



Joined: 02 Jan 2006
Posts: 650
Location: San Carlos, CA

PostPosted: Thu Jun 01, 2006 7:07 pm    Post subject: Reply with quote

Currently the OpenServo uses nearly 5K of Flash space with the bootloader occupying about 1K of that space.

The problem with floating point is that while supported on the AVR, it is VERY slow. In fact 16 and 32 bit integer operations aren't directly supported by the AVR either, but they are much faster than floating point operations would be. I'm using a combination of 16 bit fixed and some 32 bit fixed mathematics in the PID and don't feel very handicapped at this point. The precision seems very reasonable given the hardware environment of hobby RC servos or small geared motors.

If you are looking to compete with the control of very high-end commercial servos then floating point makes more sense, but you are probably outside the realm of what can be done with the lowly 8MHz AVR 8-bit MCUs.

-Mike
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Zeddicus



Joined: 21 May 2006
Posts: 109

PostPosted: Thu Jun 01, 2006 8:17 pm    Post subject: Reply with quote

Ok, thanks. It's good to know we're still only at 5K!

I'll get back to this after I catch up with everyone else. My parts still haven't arrived!!!! AARRGGHH!!!!

Z
Back to top
View user's profile Send private message
Zeddicus



Joined: 21 May 2006
Posts: 109

PostPosted: Thu Jun 15, 2006 2:37 pm    Post subject: Reply with quote

Two more questions:

1.- Does anyone know how much RAM is being used on the AVR at the moment?

2.- Mike, could you please explain to me how you're using 16b/32b fixed point?

Thing is, the algorithms I'm looking into at the moment are getting rather complicated, with a lot of calculations involved. There's even a sqrt and a sin involved in places, which is not funny on an 8bit uC. I may have to absorb my C Recipee book and implement the math functions myself.


ZZZ
Back to top
View user's profile Send private message
mpthompson



Joined: 02 Jan 2006
Posts: 650
Location: San Carlos, CA

PostPosted: Thu Jun 15, 2006 6:54 pm    Post subject: Reply with quote

SRAM useage is about 135 bytes not including the stack. A healthy stack size would be about 256 bytes so I would say that about 390 bytes of 1024 bytes of SRAM are used.

My use of fixed point math is fairly limited and fairly straight forward in the pid.c module. Stefan Engelke did more extensive fixed point work in the estimator.c module which is worth a look -- I learned some things myself from his code. Stefan wrapped up school work about a month ago and I'm not sure of his status of working on his own algorithms for the OpenServo. However, his earlier work was very promising.

In the pid.c module I'm using 8:8 fixed point gains for the proportional, derivative and integral gains. The function gain_multiply() does a fixed point multiply which includes a truncation of the multiplication result truncate the result to 16-bits of precision.

-Mike
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group