Go Down

Topic: idea for physics.h library (Read 1 time) previous topic - next topic

robtillaart


Hi,

Last month I had the idea to create a  "physics.h" which is a (sub)set of different physics formulas one can use. Recall what  "math.h"  is for math formulas.

The rationale was that while I was making a library for the DHT (temp/humidity) sensor I thought the dewPoint() formula should not be part of the sensor library as it is useful for any temp/humid sensor combination. 

So physics.h doesn't do sensors, actuators or I/O, just formulas. For now I have a simple first version with a few temperature related macro's and functions.

The architecture / structure I have in mind has 2 levels, at top is  "physics.h"  which just includes the more specific areas => To have multiple files one can tweak physics.h to include/exclude subsets very easily. Drawback is that some formulas will fit in multiple subsections.....

The following questions: (high level)
1) What do you think of this idea? why?
2) What do you think of the architecture?  other ideas? why?
3) other remarks? why?

(low level)
4) what subsections should exist? (mechanics, electro, radiation, ...?
5) which formulas in which subsection?
6) sources for good formulas?

Please shoot! ;)

Rob



physics.h
Code: [Select]
//
//    FILE: physics.h
// VERSION: 0.1.00
// PURPOSE: physics functions for Arduino
//
// HISTORY:
// 2011-04-17 first version  rob.tillaart(at)gmail.com
//
//

#ifndef physics_h
#define physics_h

#include "temperature.h"

#endif


temperature.h
Code: [Select]

//
//    FILE: temperature.h
// VERSION: 0.1.00
// PURPOSE: temperature functions for Arduino
//
// HISTORY:
// 2011-04-17 first version
//
//

#ifndef temperature_h
#define temperature_h

#include "WProgram.h"

#define TEMPERATURE_LIB_VERSION "0.1.00"

// TEMPERATURE
#define Celsius2Fahrenheit(C) ((C)*9/5+32)
#define Fahrenheit2Celsius(F) (((F)-32)*5/9)
#define Celsius2Kelvin(C) ((C)+273.15)
#define Kelvin2Celsius(K) ((K)-273.15)


// DEWPOINT
// dewPoint function NOAA
// reference: http://wahiduddin.net/calc/density_algorithms.htm
double dewPoint(double celsius, double humidity)
{
double A0= 373.15/(273.15 + celsius);
double SUM = -7.90298 * (A0-1);
SUM += 5.02808 * log10(A0);
SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
SUM += log10(1013.246);
double VP = pow(10, SUM-3) * humidity;
double T = log(VP/0.61078);   // temp var
return (241.88 * T) / (17.558-T);
}

// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity/100);
double Td = (b * temp) / (a - temp);
return Td;
}

#endif
//
// END OF FILE
//




Rob Tillaart

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

robtillaart

- http://www.extremescience.com/zoom/index.php/science-calculators/99-physical-constants -

one constants.h file or should they be in the right subset ?
Rob Tillaart

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

bubulindo

#2
May 02, 2011, 06:35 pm Last Edit: May 02, 2011, 06:37 pm by bubulindo Reason: 1
This is quite good thinking... :)

About subsets... well, you could do a mechanical one with calculation of speed based on two positions, torque limiting (if there's current feedback) and even directions if you feed two encoder signals to the object, also you could make it with the possibility of a gear. So you could, for example, feed encoder counts and based on the configuration of the encoder signal and gear, get the speed, torque, etc... on the other side of the gear. This would be quite generic and could be used both in a robot, or for example a winch. (of course that, for the direction, you'd need to configure your system as a two motor on a fixed axis.

Density, based on two pressures.

Torque based on current?

Power measurements coming from current and voltage measurement...

There's plenty of ideas. Some simpler to be made others not so simple because of all the hardware involved. :\

Edit:

Position based on speed and angle, in the extreme case of having two encoders...
Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

liudr

You could also add a formula to convert resistance to temperature for a thermistor. It's a bit intimidating to some newbies. Formula is here for simple thermistor curves. I'm sure some more accurate thermistors has more than three constants, R1, T1, and B.

http://liudr.wordpress.com/2011/02/10/measure-temperature/

retrolefty

Here is a great little free windows GUI conversion utilites that might be useful for checking out many conversion functions you might create:

http://joshmadison.com/convert-for-windows/

Lefty

cr0sh

I think the idea has merit, but I am not too keen on the name; perhaps it should be named "algorithms.h" or something similar...? When I think "physics", I think about things like motion and such, but not temperature and humidity - though I suppose there's a lot of overlap.
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

bubulindo


I think the idea has merit, but I am not too keen on the name; perhaps it should be named "algorithms.h" or something similar...? When I think "physics", I think about things like motion and such, but not temperature and humidity - though I suppose there's a lot of overlap.


I think temperature/humidity was the beginning of the idea. It could be easy to add more subsets for different things. Although, for simpleness, I think it should concentrate on things that can be measured by "standard" sensors to make facilitate it's use. :\
Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

Go Up