How to get derivative and signum function in PSoC 5

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Hi, I want to develop an algorithm my project ( for a control systems design). For the same I need to take derivative of functions. So can someone help me to get the derivative of a function in PSoC5 (code in main.c)

   

I am also trying to implement the signum function in the 'main.c' but i am getting many errors. Please help me to get the derivative and signum function,. 

0 Likes
8 Replies
Anonymous
Not applicable

if you have the values of the function in an array it is just a matter of doing simple X1-X0*mod and storing it in another array

0 Likes
Anonymous
Not applicable

 imean (X1-X2)*mod

   

where mod properly scales the value

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Signum is defined as 0 if x==0; 1 if x >0 and -1 if x<0. Nothing we can tell more without a bit more insight into what runs and what not.

   

To calculate the derivate of a given function you have the choice to calculate it as a math solution and implement the function in C as usual or calculate an approximation based on the hints of the previous post calculating dY/dX as discrete (Y1-Y0)/(X1-X0) and keeping an eye on (X1-X0) getting near zero.

   

 

   

It sounds a bit like programming a control-loop (PID) . there are examples in the web for C subroutines.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

for the Signu, depending on the data type you could just check the sign bit. 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

@Zeta

   

That's not enough, remember the Zero which should return 0

   

 

   

Bob

0 Likes
Anonymous
Not applicable

my ad, but you just need to add a comparison for the special case of zero

0 Likes
Anonymous
Not applicable

 my bad*

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Not too bad (Smile)

   

 

   

Bob

0 Likes