Go Down

### Topic: math function (Read 1 time)previous topic - next topic

#### hong89

##### Apr 02, 2012, 10:47 am
Hi,

I am going to to build a symtem with plenty of fomular, anyone know what code to perform integration function and transfer function?

Thanks and regards.

#### Grumpy_Mike

#1
##### Apr 02, 2012, 10:57 am
Transfer function is best done with a look up table.
Integration is best done by using discreet methods.

#### hong89

#2
##### Apr 02, 2012, 12:29 pm
If the system is a real time system, how would the coding be?
It's function is to integrate acceleration to velocity then position.
And integration in PID function.

Thanks for the help.

Regards

#### Grumpy_Mike

#3
##### Apr 02, 2012, 03:15 pm
Quote
to integrate acceleration to velocity then position.

If this is data from an acceleration sensor then the results are less than perfect because of noise on the output of the sensor. This gives a DC term into the integrator which causes the output to drift consistently, giving an error in any positional reading. I assume you want to do an inertial navigation system or a dead reckoning system. The results of trying to do this are not very good.

You have to write the code to implement what ever algorithm you are using, look here for the algorithms you can use:-
http://en.wikipedia.org/wiki/Integral#Computing_integrals

#### hong89

#4
##### Apr 02, 2012, 05:09 pm
Mine is to build a 'virtual' position signal (with the affect of force detected) and compare with the the actual position calculated and correct the actual position to be same as the virtual one (the force will vary all the time).

Thanks for the help~=)

Regards.

#### robtillaart

#5
##### Apr 02, 2012, 07:10 pm

Quote
the force will vary all the time

Is this a quote from Star Wars ?

seen this - http://arduino.cc/playground/Code/PIDLibrary - ?

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### hong89

#6
##### Apr 03, 2012, 10:16 am
I have read that link before, but now the quetions is I have two different input and require two different Kp, will this working as well? If so how to modify the code?
I am doing job like converting simulink(done by others) to arduino code.

attached image is how does my PID look like.

p/s: I duno how to insert image, not sure can bee seen or not?

#### hong89

#7
##### Apr 03, 2012, 01:32 pm
Thx for the help
Now I trying with the PID() function

#### hong89

#8
##### Apr 04, 2012, 03:25 pm
Is there any sample code for doing integration and transfer function?

Thanks for the help~~~

#### robtillaart

#9
##### Apr 04, 2012, 06:38 pm

Theory
- http://en.wikipedia.org/wiki/Trapezoidal_rule -
- http://en.wikipedia.org/wiki/Numerical_analysis -

Some practice:
- http://www.cplusplus.com/forum/general/26335/ -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up