If you need that much accuracy you should use 1% resistors and also calibrate your conversion factor with a known accurate voltage. Maybe compare it to a DVM?
With those values, the max reading I can get from the ADC is 4095 @ 4.985Vin from sensors -> 3.29993V through the divider.
The accuracy of the sensors is 38mV per G for the accelerometer and 45.9mv/kPa, so i'd loose perhaps 1G off the accel and 1kPA from the pressure sensor.
The top end voltage of the accelerometer is @ 50G. I have had some discussion with other rocket people and its not unheard of to hit 45G's in some of the transonic/supersonic rockets.
The max altitude for the pressure sensor is 35000 feet so im failry sure I can afford to miss a few feet here [noparse]:)[/noparse]
There is also the voltage variation of the power supply (both the 5V and 3V3) which is around 5%.
Would all these factors make the last few millivolts irralevant? I probably got my calc's wrong somewhere in there [noparse]:)[/noparse]
That spreadsheet was a tricky one, but I think I got it!
The bad assumption was that Vin would be different with the 5V and the 3.3V reference.
Here's what works:
1. Assume that Vin is the same for both reference columns, i.e. cell F7 = cell A7, etc. down the column.
2. Then, the Prelaunch AVG count is still 2048 for the 5V ref, but it's now 3102 for the 3.3V ref. This is because the Prelaunch null voltage is still 2.5V coming out of the accelerometer.
3. This gives the same G value for both voltages.
I think this shows that you can't use the 3.3V reference because you need a 5V range.
Let me know if this makes sense.
Jim
P.S. I received my MCP3208's today, so I'll let you know how the voltage divider works.
Hmmm but Vin IS different as it is coming out of a volatage divider for the 3.3V Vref version.
EDIT: Vin is the voltage reading at the input pin on the ADC as opposed to the voltage reading on the output pin on the sensor.
WHich means the voltage reading is the reading AFTER the divider in the 3.3VRef case.
Notice that the ADC Out column matches up. This suggests that everything in the first 2 columns (Vin and ADCOut) is working.
This would mean the problem is with the Accel column as thats where things start to go funny.
What do you think?
EDIT: I should also note, that the G range for the ADXL78 is +50G to -50G, not +59G to -59G as per the 5V table?
Grrrrr
Ok, heres a bit more which may help [noparse]:)[/noparse]
I have added the pressure calcuations which are also coming from a 5V sensor, through the divider into 3.3V, then into the ADC.
As you can see, the 5V colums and 3.3V columns are the same (within reason) which further proves that the calculations up until that point are ok [noparse]:)[/noparse]
This leads me to believe its something to do with the mV/G calculations up the top (which the acceleration columns reference).
The txt in grey·are values which are outside the sensors range, I have only put them in for reference.
I didn't understand your definition of terms before.
Try this (with the original spreadsheet):
Remember that Vref is different for the two cases.
Since you have a voltage divider for the 3.3 Vref, then it's input is reduced by a factor of 3.3/5.
This also reduces the mV/G by the same factor.
If you replace the 38 mv/G by 38*3.3/5 it will give the right answers.
Also, if the range of the accelerometer were 50G per 2500mV then it would be 50 mV/G.
Since you're given the number 38mV/G then the voltage output range of the accelerometer must be plus or minus 38mV/G*50G = 1.9V.
I just figured out the mV/G part too [noparse]:)[/noparse]
Changing the mV/G by the same ratio as VRef changes (I used the voltage divider calc, but 3.3/5 works too) everything works out just fine with regards to scale.
That 1.9V bit makes sense in the spread sheet. I don't understand then why the data sheet would say the range is 0.25V -> Vdd-0.25V (I.e. 0.25V -> 4.75V).
FYI: The average error factor is now 57feet (largest 81.6ft) for the pressure sensor (once converted the altitude), and 0.032G's (largest 0.067G's) so 1LSB
Well, at least we figured out the ratio thing, thanks [noparse]:)[/noparse]
I left the other pins unconnected just to see what would happen. I suspect they're internally pulled low but I'm not sure. You'll have to calibrate the conversion values once you get it connected.
The code requires you to connect the DIN and DOUT pins. I did this and then connected them to the Propeller pin thru a 1K resistor to limit any current flow in case the code became confused. I think this is good practice anyway. The chip select and clock pins don't need a resistor because they're always input, never output.
I coded the whole thing on the Propeller Proto board. I added some connectors on the Proto board to make the breadboarding easier. I used the voltage busses on the Proto and connected the adc chip to p13, p14 and p15.
My code is a little bit of a kludge because I combined it with my VGA/Keyboard routine to make debugging easier. Now that I know it works, it's pretty easy to make it run with almost any application. I'll be happy to supply you the code if you're interested. It you're getting a Proto board it should be easy to test it out.
Hey! I'd like to see a picture of your super rocket. It sounds like fun!
Code would be good [noparse]:)[/noparse] I am getting through the objects and have a fairly good understanding, but its nice to see how others do it [noparse]:)[/noparse]
Everyone wants to see my rocket lol. Unfortunatly I am only doing the electronics and don't currently have a rocket of my own[noparse]:([/noparse]
I used to, but that was before I got married lol.
I am designing a flight controller to return other peoples baby's safely to earth...hopefully in 1 piece! [noparse]:)[/noparse]
I have someone who is willing to flight test it for me, so I can get some pics of that and flight rocket once everything is up and running [noparse]:)[/noparse]
EDIT: Oh, and ive designed my own board which I will use, complete with FTDI chip and whatnot, lets just hope it works
I have had the rocket specific bits checked over by a few people and everything looks good so far. The prop side of things (memory, prop, USb interface etc) is mostly borrowed from the prop datasheet so should be fine.
If anyone can suggest a few things I should watch out for in terms of board layout that would be much appreciated! I can post the schematic & board layout is required? If I do, i will put it in another thread as its a bit off the topic of this one.
Anyone care to take a look for me?
Here's a copy of the code I used to test the MCP3208 ADC chip.
You can also use it as a general debugging tool for the Proto Board. It supports VGA output at 1024x768 resolution with character output of 128x64. It supports the keyboard with all of the usual control keys. It also has the usual output routines: bin, dec, hex, bin, str, cursloc, etc.
Comments
2K4 for R1 and 4K7 for R2 give 3.309V @ 5V
Post Edited (Basil) : 5/6/2007 6:51:49 AM GMT
If you need that much accuracy you should use 1% resistors and also calibrate your conversion factor with a known accurate voltage. Maybe compare it to a DVM?
The accuracy of the sensors is 38mV per G for the accelerometer and 45.9mv/kPa, so i'd loose perhaps 1G off the accel and 1kPA from the pressure sensor.
The top end voltage of the accelerometer is @ 50G. I have had some discussion with other rocket people and its not unheard of to hit 45G's in some of the transonic/supersonic rockets.
The max altitude for the pressure sensor is 35000 feet so im failry sure I can afford to miss a few feet here [noparse]:)[/noparse]
There is also the voltage variation of the power supply (both the 5V and 3V3) which is around 5%.
Would all these factors make the last few millivolts irralevant? I probably got my calc's wrong somewhere in there [noparse]:)[/noparse]
4985mV / 4095 counts = 1.22mV / count.
So you should be able to break your 38mv/G into about 31 counts.
This means your error should be about 0.03G, assuming everything else is calibrated perfectly.
Check my assumptions, I could be wrong.
mV/G =38
mV/Bit (5000/4096bits) =1.220703125
g/Bit (mV/Bit / mV/G) =0.032123766
And at 3.3V...
mV/Bit (3300/4096bits) =0.805664063
g/Bit (mV/Bit / mV/G) =0.021201686
Which makes it more accurate @ 3.3V??? Am I missing something lol
Im a little confused on something.
I have attached an excel workbook with a table showing volts vs. G's for 5V, and then when its converted to 3.3V.
The max G's don't match! Grrrr... Could someone take a look at this and let me know where I went wrong, its probably something really simple!
Post Edited (Basil) : 5/7/2007 9:23:46 PM GMT
The bad assumption was that Vin would be different with the 5V and the 3.3V reference.
Here's what works:
1. Assume that Vin is the same for both reference columns, i.e. cell F7 = cell A7, etc. down the column.
2. Then, the Prelaunch AVG count is still 2048 for the 5V ref, but it's now 3102 for the 3.3V ref. This is because the Prelaunch null voltage is still 2.5V coming out of the accelerometer.
3. This gives the same G value for both voltages.
I think this shows that you can't use the 3.3V reference because you need a 5V range.
Let me know if this makes sense.
Jim
P.S. I received my MCP3208's today, so I'll let you know how the voltage divider works.
EDIT: Vin is the voltage reading at the input pin on the ADC as opposed to the voltage reading on the output pin on the sensor.
WHich means the voltage reading is the reading AFTER the divider in the 3.3VRef case.
Notice that the ADC Out column matches up. This suggests that everything in the first 2 columns (Vin and ADCOut) is working.
This would mean the problem is with the Accel column as thats where things start to go funny.
What do you think?
EDIT: I should also note, that the G range for the ADXL78 is +50G to -50G, not +59G to -59G as per the 5V table?
Grrrrr
Post Edited (Basil) : 5/8/2007 1:34:16 AM GMT
I have added the pressure calcuations which are also coming from a 5V sensor, through the divider into 3.3V, then into the ADC.
As you can see, the 5V colums and 3.3V columns are the same (within reason) which further proves that the calculations up until that point are ok [noparse]:)[/noparse]
This leads me to believe its something to do with the mV/G calculations up the top (which the acceleration columns reference).
The txt in grey·are values which are outside the sensors range, I have only put them in for reference.
Thanks for the help on this puzzling thing!
Try this (with the original spreadsheet):
Remember that Vref is different for the two cases.
Since you have a voltage divider for the 3.3 Vref, then it's input is reduced by a factor of 3.3/5.
This also reduces the mV/G by the same factor.
If you replace the 38 mv/G by 38*3.3/5 it will give the right answers.
Also, if the range of the accelerometer were 50G per 2500mV then it would be 50 mV/G.
Since you're given the number 38mV/G then the voltage output range of the accelerometer must be plus or minus 38mV/G*50G = 1.9V.
I hope this helps.
Changing the mV/G by the same ratio as VRef changes (I used the voltage divider calc, but 3.3/5 works too) everything works out just fine with regards to scale.
That 1.9V bit makes sense in the spread sheet. I don't understand then why the data sheet would say the range is 0.25V -> Vdd-0.25V (I.e. 0.25V -> 4.75V).
FYI: The average error factor is now 57feet (largest 81.6ft) for the pressure sensor (once converted the altitude), and 0.032G's (largest 0.067G's) so 1LSB
Well, at least we figured out the ratio thing, thanks [noparse]:)[/noparse]
Post Edited (Basil) : 5/8/2007 9:07:31 PM GMT
I put the 2.4K/4.7K voltage dividers on pins 1 and 3 (adc0 and adc2) of the MCP3208.
I connected the first one to the 5V source from the Propeller Proto board.
The second one I connected to the 3.3V source.
The other adc pins were not connected to anything.
The chip and Vref are both driven by 3.3V.
I printed the results out on a VGA screen, updating the output once per second.
I've attached a picture of the screen so you can see the results.
As you can see, the 5V counts are near the top of the range and the 3.3V counts are about what you would expect.
As far as I can see, this proves that the voltage divider circuit works and you don't need anything fancier.
Take a look and let me know what you think.
Jim
Thats brilliant! Thanks!
Good old resistors aye [noparse]:)[/noparse]
Are the odd values on the other ADC inputs due to the fact that they are left floating?
Is the device nice and simple to code?
I ask all these questions cause i'm writing my code without actually owning a Prop [noparse]:)[/noparse]
The code requires you to connect the DIN and DOUT pins. I did this and then connected them to the Propeller pin thru a 1K resistor to limit any current flow in case the code became confused. I think this is good practice anyway. The chip select and clock pins don't need a resistor because they're always input, never output.
I coded the whole thing on the Propeller Proto board. I added some connectors on the Proto board to make the breadboarding easier. I used the voltage busses on the Proto and connected the adc chip to p13, p14 and p15.
My code is a little bit of a kludge because I combined it with my VGA/Keyboard routine to make debugging easier. Now that I know it works, it's pretty easy to make it run with almost any application. I'll be happy to supply you the code if you're interested. It you're getting a Proto board it should be easy to test it out.
Hey! I'd like to see a picture of your super rocket. It sounds like fun!
Jim
Everyone wants to see my rocket lol. Unfortunatly I am only doing the electronics and don't currently have a rocket of my own[noparse]:([/noparse]
I used to, but that was before I got married lol.
I am designing a flight controller to return other peoples baby's safely to earth...hopefully in 1 piece! [noparse]:)[/noparse]
I have someone who is willing to flight test it for me, so I can get some pics of that and flight rocket once everything is up and running [noparse]:)[/noparse]
EDIT: Oh, and ive designed my own board which I will use, complete with FTDI chip and whatnot, lets just hope it works
I have had the rocket specific bits checked over by a few people and everything looks good so far. The prop side of things (memory, prop, USb interface etc) is mostly borrowed from the prop datasheet so should be fine.
If anyone can suggest a few things I should watch out for in terms of board layout that would be much appreciated! I can post the schematic & board layout is required? If I do, i will put it in another thread as its a bit off the topic of this one.
Anyone care to take a look for me?
Post Edited (Basil) : 5/9/2007 4:27:07 AM GMT
You can also use it as a general debugging tool for the Proto Board. It supports VGA output at 1024x768 resolution with character output of 128x64. It supports the keyboard with all of the usual control keys. It also has the usual output routines: bin, dec, hex, bin, str, cursloc, etc.
Let me know if you have any questions about it.
Take care.