View previous topic :: View next topic |
Author |
Message |
chad Guest
|
need a help...imp!!! |
Posted: Sat Jun 25, 2005 11:59 am |
|
|
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
|
|
Posted: Sat Jun 25, 2005 3:18 pm |
|
|
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
|
|
Posted: Sat Jun 25, 2005 5:26 pm |
|
|
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
|
|
Posted: Sat Jun 25, 2005 5:56 pm |
|
|
We sure have a great deal of knowlege on this forum.
Great people here.
You can ask almost anything.
Why is the sky blue ? ? |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Sat Jun 25, 2005 6:06 pm |
|
|
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
|
|
Posted: Sun Jun 26, 2005 4:05 pm |
|
|
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
|
|
Posted: Mon Jun 27, 2005 7:41 am |
|
|
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
|
|
Posted: Tue Jun 28, 2005 3:11 pm |
|
|
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
|
|
Posted: Tue Jun 28, 2005 3:18 pm |
|
|
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 |
|
|
|