Hi, Bobbo
seems PBP is not the only one to have difficulties with your maths ...
so, in case I could help ...
Could you give me a link to your sensor Datasheet ...
There are things I'm missing ...
Alain
Hi, Bobbo
seems PBP is not the only one to have difficulties with your maths ...
so, in case I could help ...
Could you give me a link to your sensor Datasheet ...
There are things I'm missing ...
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi Ace,
Sorry, :-( some concepts just dont sink in, they need to be beaten in, :-)
Attached is the datasheet.
Haven t tried again since Thursday, going to sit down now and try get each value multiplied out and then DIV32'ed to try get to the right values, see if it works.
Many thanks for the help
Rob
First the ADC needs to be converted into KPA for yourformuls to work.
You will need to have the ADC setup with a 3.0 volt reference.
Using the old formula of
y = mx-b
y = output 'Volts
m = slope
x = input units
b = offset
You are wanting to read form 0 to 30 amps.
You are wanting to read form 0 to 3.92kpa.
Output is 0.6 to 3 volts.
Start off by look at the output in volts. You have a 2.4 volt span. Giving a span of 3.92 / 2.4 = 1.633
m = 1.633
The offset. Starting at 0.6 volts. 0.6 volts = 0 kpa. The offset is 0.6 * 1.633 = 0.98
b = 0.98
Plug all this into the formula and lets say the input is 3.0 volts.(full scale)
y = (1.633 * 3) - 0.98
y = 3.92
Now convert this to an 10 bit PIC resolution.
10 bits ADC = 0 to 1023, 1024 steps.
At 3.0 volts one volt of input will will read 341.
Spanning 2.4 volts or 818 steps (2.4 * 341).
New value for m. 3.92 / 818 = 0.00479
m = 0.00479
The new offset starting at 205, (0.6 * 341).
205 * 0.00479 = 0.98
b = 0.98
y = (ADC * 0.00479) - 0.98
ADC = 1023
y = 3.92kpa
ADC is from the sensor.
Now for some code.
Code:' m = 0.00479 ' b = 0.98 ' y = (ADC * 0.00479) - 0.98 ' ADC = 1023 ' y = 3.92kpa M CON 479 'm = 0.00479 * 10,000 B CON 98 'b = 0.98 * 100 ADC VAR WORD 'INPUT FROM SENSOR Y VAR WORD 'KPA Z VAR WORD 'DUMMY VAR Z1 VAR WORD 'DUMMY VAR 'V = SQRT((2 * (Y/1000)) / 1.225) V VAR WORD 'METERS/SECOND D CON 122 'AIR DENSITY START: ADC = 1023 'FULL SCALE HARD CODED, NO SENSOR Z = ADC * M Z1 = DIV32 1000 Y = Z1 - B Z = (2 * Y * 10000) Z1 = DIV32 1000 V = SQR(Z1 / D *100) LCDOUT $FE,1,"KPA= ",DEC Y/100,".",DEC Y//100 LCDOUT $FE,$C0,"M/S= ",DEC V PAUSE 250 GOTO START
Dave
Always wear safety glasses while programming.
Hi Dave,
Fianlly have usable numbers to work with, had some issues using a 3.3v reference as the sensor only works to 3V so I bought a LM317 adjustable reg and got it set to 3.00V, now it is working as per you calculations, :-) only thing im need to change a bit is the air density constant based on the altitude, temp and humidity.
the reveal, :-) basically what I am doing with this sesnor and program is setting it up in my RC plane to drop the flaps in relation to the airspeed, so as the airspeed decreases the flaps increase, and then as airspeed increases the flaps decrease. was driving in the car with the GPS, PIC and 2 servos connected and they seem to be reacting as I want them.
Will post a clip when I get a second hand to hold the cammera while I drive, :-)
Kind regards
Rob
Hi, bobbo
Some diving bomber planned ???
I hope not the " Stuka syndrom " ...
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
lol, nope, just a lazy pilot and like automating as much as possible, :-), if I could figure out how to do an inflight re-fuel I would be quite happy, :-)
Next thing will be to use a sensor to turn on nav lights automatically, :-)
Bookmarks