View Full Version : different voltaje a/d sensors
RodSTAR
- 20th October 2009, 15:55
Hello grls & guys
i have a pic18f4431 (obvious 5v) and i want to A/D at the same time:
1.- a 0-3,3v device (accelerometer),
2.- a 0-3,0v device (gyro) and
3.- a 0-5,0v device (thermsistor)
of course i have o problem on power supplying them, just voltage regulators & stuff, my problem is to measure the full range of each.
it seems VREF works just for all a/d inputs at a time?
is it possible?
if possible, how should i circuit it?
thx grls & guys
mackrackit
- 20th October 2009, 17:46
It may not be the best solution but when I run into this type of thing I will scale the higher voltages down with a voltage divider so they all match.
The 0 to 5 volt sensor is now a 0 to 3.
dhouston
- 20th October 2009, 18:16
I don't understand the problem. If you are using 5V to power the PIC, you can also use it for AVdd. You will get the full range of all 3 sensors, you will merely lose resolution on the 3.3V & 3.0V sensors. If you want to maximize resolution, use op amps setup for DC gain to promote the 3.0V & 3.3V sensors.
ScaleRobotics
- 21st October 2009, 01:09
I think he wants full resolution of the A/D converter at 3.3v as well as 5.0v.
Darrell had a real nice 10 to 16 bit selectable over sample routine. It seems the sites.picbasic.net site is having some issues, so right now you can not download it from there. It was here: http://sites.picbasic.net/index.php?option=com_uhp2&Itemid=6&task=viewpage&user_id=70&pageid=27 and it was called DT_Analog.pbp
By going to 11 bit over sampling, you would effectively get the resolution back for your 3.3v devices, and no extra hardware. It does slow your sampling time a tiny "bit" for the extra bit.
Here is the speed
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3446&stc=1&d=1243955850
RodSTAR
- 21st October 2009, 02:32
As PIC is 5v I was thinking to transform electrically all sensors to ranges to 0-5v with a "magical IC" that outputs an analog voltaje (not digital) proportional to the input.
For example if a 3,3v device (accelerometer, sensor) outputs 1,65v (50% of 3,3v), then this "magical IC" will recive 1,65v and output 2,5v (50% of 5v).- Aswell if in another channel or other IC configured to transform 0-3v to 0-5v (if sensor says 1,5v my PIC will receive 2,5v). Of course I think this IC should be circuited for matching the desired specific voltaje range
Maybe those "magical" IC's are OpAmps, as dhouston (thx!) commented. Can OpAmps make that function?
"Realtime" processing is critical, so multisampling solution suggested by scalerobotics (thx!)is definitely not an option to my application. Interesting for another app anyway.
And to shrink voltaje as mackrackit suggested (thx!) it would limit "natural" analog resolution. I prefer to amplify a voltaje than shrinking it. And I hope an Operational Amplifier (OpAmp) does that.
So: Can OpAmps make that function?
Thank you very much for your attention :) !
ScaleRobotics
- 21st October 2009, 02:49
Sounds good. Certainly a lot of options.
96.8 millionths of a second can seem like an eternity.
dhouston
- 21st October 2009, 04:09
So: Can OpAmps make that function?See the Non-Inverting Amplifier in http://www.national.com/an/AN/AN-31.pdf.
Melanie
- 21st October 2009, 07:54
You should be able to do it with three Resistors and two additional PIC pins...
R1 connects between Vdd and VRef+.
R2 connects between VRef+ and Digital PICpinX.
R3 connects between VRef+ and Digital PICpinY.
For additional stability, I would connect a 100nF Capacitor between VRef+ and 0v.
Vref- connects to 0v.
PICpinX and PICpinY are any available PIC pins that you have spare, that have full I/O capability and when in INPUT mode DO NOT have an internal Weak Pull-Up enabled.
When requiring 5v on Vref+, set PICpinX and PICpinY to INPUT. A Vref+ of 5v is provided via R1. R2 and R3 are effectively not in circuit.
When requiring 3.3v on Vref+, set PICpinX to OUTPUT LOW and PICpinY to INPUT. Vref+ is the product of Resistor divider chain R1 and R2. R3 is effectively not in circuit.
When requiring 3.0v on Vref, set PICpinX to INPUT and PICpinY to OUTPUT LOW. Vref+ is the product of Resistor divider chain R1 and R3. R2 is effectively not in circuit.
Resistors should be 1% or better. For absolute precision, make R2 and R3 hi-stab multi-turn pots and calibrate for 3.3v and 3.0v with their respecive PICpinX or PICpinY pulled OUTPUT LOW.
In software, remember when switching between different VRef's, allow a short settling time before performing a new ADC measurement.
Simple... cheap...
mackrackit
- 21st October 2009, 09:37
Simple... cheap...
That is slick !!!
dhouston
- 21st October 2009, 12:07
You should be able to do it with three Resistors and two additional PIC pins...I considered that but the OP seemed to be asking how to promote the 3.0V and 3.3V sensors so they are, in effect, 5V sensors. I don't think anything other than amplifying the signals accomplishes that.
By changing ADCON1 on the fly (between AVdd & Vref+) you can simplify it further. Or, it can be simplified by using 3.3V for the thermistor circuit.
However, it does assume that the OUTPUT LOW voltage is 0V which may not be the case. It may be as high as 0.6V @ 4.5Vdd.
Melanie
- 21st October 2009, 12:59
Actually you don't need to assume 0v. It can be 1v for all the divider Resistors care... choose the values for R2/R3 that will give you 3.3v/3.0v when that pin is LOW, if you assume 0.6v then you will be pretty close with a paper exercise. If it's a one-off build (or a product where a high degree of accuracy is required), the using Hi-Stab multi-turn pots and manually calibrating as I suggested is the way to go...
Either way, it's just another suggestion thrown into the melting pot of ideas... another could be using an LM317 and using the PIC to switch-in different Resistor values for different voltages (depending on the current draw, that option could also power your Sensor as well as Vref+)... one could carry on throwing ideas around all night long...
Acetronics2
- 21st October 2009, 13:11
Mel is Right ( as always !!! )
For a project I am developping these days ... I use a DAC to feed the Vref + of the ADC ( external ...) and GND or a fraction of Vref+ as Vref - ...
Note Vref+ is to change with atmospheric conditions ( NO, I didn't tell it's a barometer, ... nooooo ... )
just to artificially enhance the ADC resolution ...
Alain
dhouston
- 21st October 2009, 14:02
Actually you don't need to assume 0v.Yeah - I realized that just after posting.
RodSTAR
- 21st October 2009, 14:20
I'm really amazed on how much options have appeared for the same operation thx all, and I have really learned from all of you, but...
...In my specific application, I must choose the closest possible to realtime AD option, and Melanies is a really great solution but it requires switching and waiting for a settling time for a succesfull digitalization.
My application is an IMU, which means sampling 8 A/D as fastest as possible, then applying kalman, then PID, while doing PWM, interrupt bidirectional communications, logic & communication to other PIC's. Probably I'm abusing my poor PIC, and from all tasks, analog conversion should be the priority as the rest of the processess are based on my movement sensors, to stabilize movement.
Is Amplifying all analog signals to 5v the best choice?
Is OpAmp the best choice to amplify them?
Really thx babies & guys.-
PD: I changed from PIC18F4431 to PIC18F4553, for faster speed (12 MIPS [48 MHz/4]), more A/D inputs (13 pins) and better A/D resolution (12 bit)
mackrackit
- 21st October 2009, 14:56
http://www.national.com/mpf/DC/ADC0831.html
:eek: another option.
dhouston
- 21st October 2009, 14:58
best choice?That's too subjective a criteria.
You can maximize resolution by choosing Vref+ that is(are) slightly higher than the highest expected voltage(s) from your sensor(s). This would be an extension of Melanie's approach. For example, if the gyro never outputs more than 3V you could use 3V for Vref and power the thermistor circuit with 3V also. There's no additional switching.
The op amp solution is straightforward, time-honored and easy to understand. It can also maximize resolution and operates in realtime (essentially) so there are no additional delays.
Both increase noise sensitivity.
You really need to be clear about what you want. If you want maximum sensitivity, 5V/4096=1.22mV per unit while 3V/4096=0.73mV per unit so the op amp gives you a little more sensitivity. The difference is proportionally greater with 10-bit ADC.
Melanie
- 21st October 2009, 15:02
Well, ultimately the question is "Can I afford to lose 1 Bit of resolution in exchange for speed"?
If the answer is YES, then your worstcase scenario with a 10-Bit ADC is...
5v Sensor = 1023 Bits FSD
3.3v Sensor = 675 Bits FSD
3.0v Sensor = 613 Bits FSD.
... and you don't have to do anything.
If you can't live with that, then it looks like OP-AMPs could be your choice. That's a lot of extra components for one extra measly bit of accuracy...
But you could of course run your PIC at 3.0v (the voltage of your lowest Sensor) and simply use divider Resistors for your 3.3 and 5.0v Sensor inputs.
RodSTAR
- 21st October 2009, 16:11
Considering melanie's and dhouston, last suggestions, I think the simplest, cheapest, noise cleanest, circuit simplest and MIPS faster option is to just connect sensors directly to my MCU/PIC/CPU.. specifically considering this case in which my PIC has a 12 bit resolution A/D (4 times the resolution than 10 bit). I'm happy with the idea, will test it and I'll let you know how how it works! and I think I'll can live with it :)
__
PD: Just away from this, appart I will play with OpAmps, just to know how these toys work.
RodSTAR
Acetronics2
- 21st October 2009, 16:12
Hi, Mel
I think the main Problem in those Autopilots is the "Heading lock" feature ... One must ALSO measure very small Gyro variations for the Vehicle ( let's say UAV ... 10$ !!! ) to keep the perfect straight line.
so, a maximum resolution must be kept for heading precision while the full signal range has to be measured for High "G" movements controlling ... and avoiding " non linear " ( ROFL ) - or unwanted - moves.
Thermistor is just here for best temp compensation of Gyro and Accelmeter ...
May be 8 Bits PICs, and generally Pīcs are not the best components for this kind of Games ...
Alain
RodSTAR
- 21st October 2009, 16:21
Hi, Mel
I think the main Problem in those Autopilots is the "Heading lock" feature ... One must ALSO measure very small Gyro variations for the Vehicle ( let's say UAV ... 10$ !!! ) to keep the perfect straight line.
so, a maximum resolution must be kept for heading precision while the full signal range has to be measured for High "G" movements controlling ... and avoiding " non linear " ( ROFL ) - or unwanted - moves.
Thermistor is just here for best temp compensation of Gyro and Accelmeter ...
May be 8 Bits PICs, and generally Pīcs are not the best components for this kind of Games ...
Alain
In fact my UAV board has a dsPIC33F(12bit A/D) and a PIC32 and a math coprocessor for sensors (and other more sensors), maths processing, GPS parsing, coordinates algorythms, and blah blah, in fact is a full AHRS. I just want to play from conceptual small to prototype big. Lucky I have no problems on C30 and C32, I'm on the digital side of the project, not on the electronics side, as you can see by the title of this thread. But i love electronics and I'm working to try to get inside it. The board comes ready to program. My this thread was oriented to the "conceptual small" version of it.
dhouston
- 21st October 2009, 16:28
Considering melanie's and dhouston, last suggestions, I think the simplest, cheapest, noise cleanest, circuit simplest and MIPS faster option is to just connect sensors directly to my MCU/PIC/CPU.. Actually, that was my first suggestion, as well.
RodSTAR
- 21st October 2009, 16:31
Actually, that was my first suggestion, as well.
Yes :) but originally I didn't consider it because at that time I didn't have 12-bit A/D. your OpAmps suggestion was the one I most liked until I figured a 12 bit reolution.
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.