GoForSmoke:
Corpze:
I will try that, but what about the frequency, why can´t it go any lower than 10869 Hz? I haven´t calibrated the ZP yet, can it be the problem?
For single samples you get 1086. Why? I don't know!
freq = (pulses1000)/(periodarea);
Is it any surprise that 10 pulses gets 10x the freq?
Also you should mix your mixed-types math.
As above you have by types: long = (long * int) / (short * float) <<=== not a good idea
That whole business needs a total going-over.
You can throw in casts (tell the compiler to treat a variable as a different type) but if you're not careful you won't get the equation you think. Without casts, as it is now, you're letting the compiler decide.
Example of casting:
long L;
int I = 1000;
float F = 0.1;
L = (long) ((float I) * F);
And thanks to the floating point math, the result won't likely be 100L. Yes 100L because it's cast as a long to go into a long variable. 100 is a 16-bit signed integer. 100L is a 32-bit signed integer. If the letter U is used, 100U is a 16-bit unsigned integer and 100UL is a 32-bit unsigned integer.
If you use a constant and want it seen as a floating point then put in a decimal point, 100.0 is a 32-bit floating point value.
Give the compiler less room to wiggle and you may get more predictable results.
To be honest, i don´t understand anything of what you just wrote
Maybe i should just start over with a basic frequency counter and go from there?
Basicly, all i wanna do is translate frequence to mag/arcsecond2, and because the sensor is linear, wouldn´t it be quite easy to do that?
I am fairly new to arduinos and coding, i have just got a steppermotor to work with two buttons and a lcd-display
Is this the way to go maybe?:
I have one sensor, capable of sending between 0.00x Hz to 1000kHz
I also have a luxmeter, so i can calibrate the sensorvalue roughly.
if i has a light that shines with 100 lux, and the sensor is sending 20 kHz, can i from there convert to mag/arcsecond2?
I dont need any pulsecounter any else of the data, i am just interested of Mag/AS2
Is this possible?
BR/ Daniel