Calculation components (e.g RGB color calculation)

Moderator: Benj

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Calculation components (e.g RGB color calculation)

Postby hyperion007 » Sat May 11, 2013 12:25 pm

I would like to see "components" or macros for different algorithms and calculations. For example RGB color cycle function, or a temperature control macro, that calculates and "learns" when and for how long it should turn on an output controlling a fan for example, to keep a constant and stable temperature. Maybe incorporating some fuzzy logic.

So basically, function macros, that are not for a physical component. Or just more example programs and tutorials. I'm not that great at math so I have a really hard time figuring out these kinds of things.
I mean, I can do the basic things like changing RGB color from 0,0,0 to 255,255,255 but if I want to take things like human perception of colors vs light intensity etc into consideration I struck out :)

Or things like this (see attached picture):
tempcontrol.jpg
tempcontrol.jpg (104.5 KiB) Viewed 2637 times

User avatar
Benj
Matrix Staff
Posts: 14553
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4585 times
Been thanked: 4234 times
Contact:

Re: Calculation components (e.g RGB color calculation)

Postby Benj » Tue May 21, 2013 3:38 pm

Hello,

Like your suggestion will have a think about if we can do something like this with v6.

PID is fairly straight forward and can be expressed much simpler then that. I have a nice fluffy version of the equation somewhere I developed at Uni. Have a look at some of the equations relating to Laplace, Z-plane and Inverse Kinematics etc, there's some serious maths!

PID equates to something like this as taken from the DSP control component.

%a_OUTPUT_NAME[idx] = %a_PROPORTIONAL * (error - errorm1 + (error / %a_INTEGRAL) + %a_DIFFERENTIAL * (error - (2 * errorm1) + errorm2));

Where error is the current error, errorm1 is the error from the last cycle and errorm2 is the cycle before that. The inputs P, I and D are then constants which are used to tweak the system into giving the correct optimum response.