CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

problem of table look up.. thanks a lot

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gunking88



Joined: 18 Jun 2004
Posts: 11
Location: WV

View user's profile Send private message Send e-mail

problem of table look up.. thanks a lot
PostPosted: Sun Aug 01, 2004 7:23 pm     Reply with quote

I am doing a project to using PIC chip to control a dc/dc converter. here is my problem.
when calculation of of new duty cycle involves the PID or other type controller, it employs the floating number multiple.
as shown here
new_duty=(int)(Kp*error+Ki*Sum_error+Kd*(error-error_1)
here error is vref - Voutput, Voutput from 8 bit A/D. it takes time.
for table lookup idea, limits the number of error(minError and maxEorror). for example, the error can be -13 to 13, then plus 13, making it from 0 to 26, construct a table which stores the value of Kp*error, call a[error], when the error( Vref-Voutput) is obtained, then look up for table a[error], then the procedure just involves the plus and looking up the table. it looks like will decrease the time significantly compare to mulitple and divide the floating number. however, it takes more time to look up the table according to my code.

so my questions are,
1 is table lookup faster than kp*error in this case?here 3 tables (3*26 floating number) are needed.
2 if so, how to reallize it in CCS ?
3, if not, should I use assembly in this kind of situation.

thanks lot!! Question
Sherpa Doug
Guest







PostPosted: Sun Aug 01, 2004 7:58 pm     Reply with quote

Why are you using FLOATING POINT???
Fixed point is MUCH faster. Where speed matters never use floating point unless you are really really sure it is absolutely necessary, which is almost never.
gunking88



Joined: 18 Jun 2004
Posts: 11
Location: WV

View user's profile Send private message Send e-mail

yes, I can just use fixed point
PostPosted: Mon Aug 02, 2004 9:26 am     Reply with quote

I check the possible value, 0.5 makes no big different at new_dutycycle(0-249). thanks.

Sherpa Doug wrote:
Why are you using FLOATING POINT???
Fixed point is MUCH faster. Where speed matters never use floating point unless you are really really sure it is absolutely necessary, which is almost never.
Ttelmah
Guest







Re: problem of table look up.. thanks a lot
PostPosted: Mon Aug 02, 2004 9:27 am     Reply with quote

gunking88 wrote:
I am doing a project to using PIC chip to control a dc/dc converter. here is my problem.
when calculation of of new duty cycle involves the PID or other type controller, it employs the floating number multiple.
as shown here
new_duty=(int)(Kp*error+Ki*Sum_error+Kd*(error-error_1)
here error is vref - Voutput, Voutput from 8 bit A/D. it takes time.
for table lookup idea, limits the number of error(minError and maxEorror). for example, the error can be -13 to 13, then plus 13, making it from 0 to 26, construct a table which stores the value of Kp*error, call a[error], when the error( Vref-Voutput) is obtained, then look up for table a[error], then the procedure just involves the plus and looking up the table. it looks like will decrease the time significantly compare to mulitple and divide the floating number. however, it takes more time to look up the table according to my code.

so my questions are,
1 is table lookup faster than kp*error in this case?here 3 tables (3*26 floating number) are needed.
2 if so, how to reallize it in CCS ?
3, if not, should I use assembly in this kind of situation.

thanks lot!! Question

I'd look at the servo application notes on the MicroChip sites. These generally use scaled integers to perform the servo loop. I have a modified version of one of these, written in CCS C, that performs fine, using the same basic algorithm.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
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