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

need a help...imp!!!

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







need a help...imp!!!
PostPosted: Sat Jun 25, 2005 11:59 am     Reply with quote

need Help..

Iam using PIC 16F877 .. i need to implement (or emulate) a Transfer function (ex: 1/(5s+2) ) in the PIC..

If any one could help that woruld be great..

Thank you
Ttelmah
Guest







PostPosted: Sat Jun 25, 2005 3:18 pm     Reply with quote

Start with describing how you are going to get the signal into the chip, and out again.
You could simply sample the signal with an ADC, scale this number to give a value in the range required, calculate the arithmetic, and feed the result out a DAC. The arithmetic is the easiest part, but you need to be thinking of what rates are involved, the voltage ranges required for input and output, whether offsets need to be applied (they probably will, since the incoming voltage range is unlikely to match that of the ADC) etc.. You have already typed the basic arithmetic of the function, and this is basically, a perfectly acceptable line of C code. It is the work around the chip to get the value 'ready' for the function that is the hardest part.

Best Wishes
Guest








PostPosted: Sat Jun 25, 2005 5:26 pm     Reply with quote

Chad,

I haven't done digital control with PIC (but I've done it with MATLAB plus NI DAC/ADC card). If you implement yor transfer function with a PIC, it will be a digital implementation. You should use Z-transform instead of Laplace transform. Z-transform is a digital counterpart of a Laplace transform.

If you find yourself stuck, you can try to implement you transfer function with op-amps. Of course such solution will be less flexible then PIC, but it might end up being more accurate, because you will have no quantization error.

BTW, what's the application of your controller?

Vic
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Sat Jun 25, 2005 5:56 pm     Reply with quote

We sure have a great deal of knowlege on this forum.
Great people here.

You can ask almost anything.
Very Happy

Why is the sky blue ? ? Rolling Eyes
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Sat Jun 25, 2005 6:06 pm     Reply with quote

treitmey wrote:
You can ask almost anything.


Yeah. Embedded design is a multidisciplinary field; no wonder fundamental questions emerge from the engineering work some times.
chad
Guest







PostPosted: Sun Jun 26, 2005 4:05 pm     Reply with quote

thank you for all your quick replies..

Iam actually trying to emulate an alternator , for which the controller is designed in a seperate PIC. The arithmatic is a good idea .. i am using a sampling frequency of 10K .. where i am not sure if i could get a good range of values...


If i do a Z transform is there any other method than arithmatic to do implementation..


thank you

Chad
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Mon Jun 27, 2005 7:41 am     Reply with quote

chad wrote:
thank you for all your quick replies..

Iam actually trying to emulate an alternator , for which the controller is designed in a seperate PIC. The arithmatic is a good idea .. i am using a sampling frequency of 10K .. where i am not sure if i could get a good range of values...


If i do a Z transform is there any other method than arithmatic to do implementation..


thank you

Chad


By "doing a z-transform", are you talking about a bilinear transformation??

In a PIC, there is no other way, assuming you don't know what the input is, except the arithmetic, and I'll caution you in advance about using floating point algorithms in a 10K loop. See http://www.ccsinfo.com/faq/?30 for times to perform floating point operations.

This task should be no problem for a dsPIC, by the way.

If you know what the input is in advance, the arithmetic should get a whole bunch easier.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Tue Jun 28, 2005 3:11 pm     Reply with quote

sseidman wrote:

By "doing a z-transform", are you talking about a bilinear transformation??


As far as I understand, bilinear transformation is not the same as a Z-transform. The latter is sort of a digital equivalent of a Laplace transform. Given F(s) one can get F(z) using a bilinear transformation.

What�s your take on this?

Nick
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Tue Jun 28, 2005 3:18 pm     Reply with quote

kender wrote:
sseidman wrote:

By "doing a z-transform", are you talking about a bilinear transformation??


As far as I understand, bilinear transformation is not the same as a Z-transform. The latter is sort of a digital equivalent of a Laplace transform. Given F(s) one can get F(z) using a bilinear transformation.

What�s your take on this?

Nick


Given a Laplace transform in s, it's not always straightforward to turn that into a z transform (you can't just swap "z" for "s"). The bilinear transformation is just a way to to this, but by no means the only way, of doing this. You can see the implementation at http://www.earlevel.com/Digital%20Audio/Bilinear.html, but not the real details. If I recall, certain assumptions are made about what you want, and it's not perfect. For example, if you're real picky about a certain predetermined band of the spectrum, you might choose a different approach.

Scott
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