|
|
View previous topic :: View next topic |
Author |
Message |
gunking88
Joined: 18 Jun 2004 Posts: 11 Location: WV
|
problem of table look up.. thanks a lot |
Posted: Sun Aug 01, 2004 7:23 pm |
|
|
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!! |
|
|
Sherpa Doug Guest
|
|
Posted: Sun Aug 01, 2004 7:58 pm |
|
|
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
|
yes, I can just use fixed point |
Posted: Mon Aug 02, 2004 9:26 am |
|
|
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 |
Posted: Mon Aug 02, 2004 9:27 am |
|
|
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!! |
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 |
|
|
|
|
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
|