Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C code to implement transfer function?

Status
Not open for further replies.

electrojit

Member level 1
Joined
Dec 15, 2005
Messages
41
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Activity points
1,576
c code for transfer function

Hello Can any one please tell me that How to implement any transfer function of control system (temperature Control System) using C.

For example how to implement (1/s+1 ) in C.

Please help me.
 

i've got the same problem and i've tried to solve it like this, but i don't know if this is properly resolved

Let's say we've got unity feedback:
E(s) = X(s) - Y(s)
Y(s)/E(s) = 1/(s+1) ==> E(s) = Y(s) + sY(s)
then:
e(t) = y(t) + dy(t)/dt
e(t) = y(t) + [y(t) - y(t-1)]/1
e(t) = 2y(t) - y(t-1) ==> y(t) = [e(t) + y(t-1)]/2
implementation:

for (int i = 1 ; i<... ; i++)
{
e = u - y
y[0] = 0
y = (e + y[i-1])/2
}

but i'm afraid it's wrong. Can anyone help?
 
Last edited:

if you have acess to matlab, you can try generating a standalone c code from simulink for the same. . .
 

Code:
y(t) = [e(t) + y(t-1)]/2
Is the above deduction right???
I think you should separate the e() and y() and normalize it.

Well if you say it is right, then you must find a terminal condition for e() and y().
and recursive Function of y() has to be implemented.
 

Code:
y(t) = [e(t) + y(t-1)]/2
Well if you say it is right, then you must find a terminal condition for e() and y(). and recursive Function of y() has to be implemented.
It's actually the differential equation of a time discrete first order low pass with fc = fs, and it's already in a recursive form. Nothing more has to be done.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top