Supplying VRef from IO pin output?
hi all, newb here.
my initial project simple ohm meter. it's left me how achieve this, there seem several approaches. decided on simple voltage divider system.
so essentially, in classic voltage divider equation vo = (vi * r2) / (r1 + r2)
the equation rearranged isolate want : r2 = (vo * r1) / (vi - vo)
where vi supply voltage of 5v, vo voltage detected @ junction of r1 , r2 adc port , r1 known resistance.
so in code i'd doing this:
but assuming supply voltage 5. plus current voltage divider supplied io pin in output mode may different supply voltage when under small load of divider.
now seems me long vref , vi same, reading @ adc port not change means don't have assume voltage. can take absolute port readings.
so that's i'm thinking. connect voltage divider d2 , put d2 output mode when need take reading. directly connect d2 vref reference voltage going same vi. understand there's 32k resistor somewhere inline on vref circuit? don't know if that's going mess things up. don't know if directly connecting d2 vref cause problems internally in mc. know have set ref external before take readings tho'.
if can offer thoughts, point out errors or suggest easier (less component count) method. i'd grateful input.
many thanks.
quentin
my initial project simple ohm meter. it's left me how achieve this, there seem several approaches. decided on simple voltage divider system.
so essentially, in classic voltage divider equation vo = (vi * r2) / (r1 + r2)
the equation rearranged isolate want : r2 = (vo * r1) / (vi - vo)
where vi supply voltage of 5v, vo voltage detected @ junction of r1 , r2 adc port , r1 known resistance.
so in code i'd doing this:
code: [select]
float vo = (float)analogread(a0) / 204.8;
float r2 = (vo * 1000.0) / (5.0 - vo);
but assuming supply voltage 5. plus current voltage divider supplied io pin in output mode may different supply voltage when under small load of divider.
now seems me long vref , vi same, reading @ adc port not change means don't have assume voltage. can take absolute port readings.
code: [select]
float r2 = ( 1024.0 * 1000.0 ) / (1024.0 - (float)analogread(a0) );
so that's i'm thinking. connect voltage divider d2 , put d2 output mode when need take reading. directly connect d2 vref reference voltage going same vi. understand there's 32k resistor somewhere inline on vref circuit? don't know if that's going mess things up. don't know if directly connecting d2 vref cause problems internally in mc. know have set ref external before take readings tho'.
if can offer thoughts, point out errors or suggest easier (less component count) method. i'd grateful input.
many thanks.
quentin
quentin, not sure why making complicated, assume must have reason?
why not connect r1 vcc. then, say, actual voltage irrelevant , analogread gives 1023 * r1 / (r1 + r2). no need bother vref or use digital pins.
is problem circuit portable/battery powered? no current flow until r2 connected.
paul
why not connect r1 vcc. then, say, actual voltage irrelevant , analogread gives 1023 * r1 / (r1 + r2). no need bother vref or use digital pins.
is problem circuit portable/battery powered? no current flow until r2 connected.
paul
Arduino Forum > Using Arduino > Project Guidance > Supplying VRef from IO pin output?
arduino
Comments
Post a Comment