Relationship between 2 variables.

Evening.

Did not know which sub-forum this was best suited, but seeming as I guess it is an integral part of my development plan then yeah…it has ended up here.

I am making a timelapse rig that uses the canons remote port. My hardware fully works (light sensor included) but a bit stuck on the programming. Not the programming itself as such, but the maths on one part.

Basically, I have a starting value for the shutter speed (we will call it x).

x needs to increase to 2^y where y is a user defined value (in photography…the “stops”).

The increase needs to occur over a series of shots (s). Another user defined value.

So x = 2^y after s shots.

I do not want a linear progression…as in where the shutterspeed simply increases by the value of the curve’s gradient (y=mx+c) but I want a polynomial type? This is where my maths dies I am afraid!

I want the increase to be proportional to the shutter speed.

I wrote some basic code to “re-evaluate” the increase after say 10 shots were taken. This worked but gives a more “jagged” curve. What would be the relationship as an equation using x,y and s?

Thanks for any help! The curve looks kinda exponential but no idea how I would work it from first principles!

I have attached a print of my code outputting the values, except although it is “use-able” the code is a horrible mess so a simple equation for the relationship between the 3 variables would be great!
The image is where x=0.1 (starting shutter speed in seconds), y=10 (10 stops) and s = 130 (over 130 shots).

Ok...I may have had a breakthrough...

x =1/s * (log2 y) be correct?

#Edit.....nope. This sucks ha.

Have a look at the POW function.

Martin-X:
Have a look at the POW function.

Thanks.

It was more the maths I was struggling with.

I will re-phrase my question:

y = shutter speed.
y' = initial shutter speed.
m=number of stops
x=shot count.

I want to know how to get y when x,y' and m are all known.

y tends to y' over the number of shots x.

y' = 2^m

The increase in y is proportional to the size of itself.

So over 10 shots, the shutter speed will always double for example.
Then the next 10 it will double again.
And again.

Until it reaches y' which is 2^m.

I think I’m understanding this now… have a plot of this, which will give a two-fold increase over 10 steps…

y = 2e0.0693x

Where x will be the shot number and y the exposure time.

Martin-X:
I think I’m understanding this now… have a plot of this, which will give a two-fold increase over 10 steps…

y = 2e0.0693x

Where x will be the shot number and y the exposure time.

Awesome. Now how did you work it out is the real question :P?

It looks along the right lines and I may be able to finish it from there.

I cheated and used a bit of Excel. It is actually the POW function you need where the number of steps is a variable, so have a look at this...

factor = 2 ^ (ShotNum / NumSteps)

By multiplying the start exposure by the factor you should get the results you want. Just remember that ShotNumber will be zero-based.

Sounds like you need to count the number of stops.

Don't try comparing floats with = it wont work in this kind of case.

Mark

Johnny010:
Awesome. Now how did you work it out is the real question :P?

It looks along the right lines and I may be able to finish it from there.

if when (x=10) this statement is true then a generic exponential growth formula is:

2y’=y’e^((ln(2)/(x-1))*x-1)

to iterate for ten steps.

y=y’e^((ln(2)/9)*(x-1))

void sendit(float growth, float initial, uint8_t steps){
Serial.print("\nExponential growth from ");
Serial.print(initial,8);
Serial.print(" to ");
Serial.print((initial*growth),8);
Serial.print(" in ");
Serial.print(steps,DEC);
Serial.println(" steps.");

float y; // calculated shutter
         // growth 2 = double, 3= tripple ...

growth = log(growth)/float(steps-1); // actually want the natural log of 2 divided by num steps,
  // 0 is the first step

for(uint8_t x=0;x<10;x++){
  y = initial*exp(growth*float(x));
  Serial.print(y,10);
  Serial.println();
  }
}

void setup(){
Serial.begin(19200);
sendit(2,6,10);
sendit(3,6,10);
sendit(4,6,10);
}

void loop(){
}

If you don’t need variable growth factors you might be able to reduce the code space by pre-calculating the growth value and storing it as a constant.

Chuck.

chucktodd:
if when (x=10) this statement is true then a generic exponential growth formula is:

2y’=y’e^((ln(2)/(x-1))*x-1)

You seem to be using ‘x’ for two different purposes. Shouldn’t that be:
y=y’e^((ln(2)/(n-1))*x-1)
where n is the number of steps per stop, y’ is the first exposure time and y is the exposure time of the xth exposure?

EDIT: n is really the number of exposures that cover a whole stop

The formula can be written:
y=y’2(x-1)/(n-1)

Archibald:
You seem to be using ‘x’ for two different purposes. Shouldn’t that be:
y=y’e^((ln(2)/(n-1))*x-1)
where n is the number of steps per stop, y’ is the first exposure time and y is the exposure time of the xth exposure?

The formula can be written:
y=y’2(x-1)/(n-1)

]

You are awesome! Thanks so much and yes this works perfectly.

I can kinda see the resemblence of some of the terms in the exponential…but still completely lost in the actual deriving.

"So over 10 shots, the shutter speed will always double for example."

There is a mathematical function ( *2) that will do that for you.

Yeah thanks :P.

I needed the curve "smoothed". I did not know the equation to get the change proportional for each value in the series.

What if you multiply by 1.2 each time ? It may not be exactly the formula you ask for, but it should be pretty close.

Thankyou for your help. I have been pointed towards the solution I wanted with non-static variables :).

I really need to pick up an A-level maths text book again :(.

Johnny010:
I can kinda see the resemblence of some of the terms in the exponential…but still completely lost in the actual deriving.

Mathematicians would derive this by diving into algebraic manipulation and thereby lose any appreciation of reality.

It may be easier to see how the formula works if we start with some simple examples.

Consider x increasing (as an integer):
1,2,3,4, . . . etc
and if you want the exposure time to increase by increments of a whole stop, such as:
1, 2, 4, 8, . . . (seconds) etc
The exposure times would then be simply 2(x-1)

If you want half stop increments, the exposure times should be:
1, 1.41, 2, 2.83, 4, 5.66, 8, . . . . (seconds) etc
The exposure time would then be 2(x-1)/2

Instead of starting with one second, if you start with say a tenth of a second, the y’ in the formula becomes 0.1 so you get:
0.1, 0.141, 0.2, 0.283, 0.4 . . . . (seconds) etc

Note ‘n’ in my post above (based on Chuck’s formula) is really the number of exposures that cover a whole stop, so in the case of half stop increments ‘n’ would be 3 because three exposures are required to cover a change of one stop: for example 1, 1.41 & 2 seconds.

Archibald:
Mathematicians would derive this by diving into algebraic manipulation and thereby lose any appreciation of reality.

It may be easier to see how the formula works if we start with some simple examples.

Consider x increasing (as an integer):
1,2,3,4, . . . etc
and if you want the exposure time to increase by increments of a whole stop, such as:
1, 2, 4, 8, . . . (seconds) etc
The exposure times would then be simply 2(x-1)

If you want half stop increments, the exposure times should be:
1, 1.41, 2, 2.83, 4, 5.66, 8, . . . . (seconds) etc
The exposure time would then be 2(x-1)/2

Instead of starting with one second, if you start with say a tenth of a second, the y’ in the formula becomes 0.1 so you get:
0.1, 0.141, 0.2, 0.283, 0.4 . . . . (seconds) etc

Note ‘n’ in my post above (based on Chuck’s formula) is really the number of exposures that cover a whole stop, so in the case of half stop increments ‘n’ would be 3 because three exposures are required to cover a change of one stop: for example 1, 1.41 & 2 seconds.

Thanks. I understand it that way. The mathematical derivation I will have to work on for my own interest.