understanding analogRead(VCCM) #267
Replies: 13 comments
-
|
Beta Was this translation helpful? Give feedback.
-
So the data sheet says something about "Internal support 1/5 Divider input (VDO)" and that would match my results. In which "Match" is a little stretch.
(4.625 V is verified. I could add more digits.) 0.3 V off? I seem to make something wrong. // me confused. |
Beta Was this translation helpful? Give feedback.
-
Hi! The default values after reset:
After your first measure you get this value form analogRead(VCCM): 1000
On the green board there is a 'power selector' diode. If you powered your board by USB this diode will drop the VCC by 0.3 - 0.5 V. |
Beta Was this translation helpful? Give feedback.
-
That is very confusing. Vcc at LGT8F328 pin 4 is 4.62 V. My 3.3V=A0 is measured correctly and scaled by 5V reference voltage value. The Vcc diode stuff is confusing. If the LGT8F328 sees the voltage after the diode, it should be lower... I found no schematic of the green board I have and can't really trace out mine, because it is fix soldered into a different pcb. |
Beta Was this translation helpful? Give feedback.
-
I am confused too. You selected the DEFAULT internal reference voltage, which is 1.024V But if you use VCC for reference voltage when measuring 3.3V then your reference was 4.62V. |
Beta Was this translation helpful? Give feedback.
-
Anyway this calculation is not correct The ADC will get the maximum (4095) value when it's input is is reach or exceeds the 1.024V reference voltage. So the correct calculation is: |
Beta Was this translation helpful? Give feedback.
-
I made a test with my board. |
Beta Was this translation helpful? Give feedback.
-
Please show what the above code produces. 1======================================= What is https://github.com/LaZsolt/lgt8fx/blob/master/lgt8f/cores/lgt8f/wiring_analog.c#L161 doing?
Looks like averaging two measurements? Why? 2======================================= |
Beta Was this translation helpful? Give feedback.
-
2=================== 1===================
The algorithm of the measurement came from LGT8F328P databook:
You may learm more from the databook, page: 258 |
Beta Was this translation helpful? Give feedback.
-
Thanks. Currently I clean up the code of __analogRead from all the defines. It I found that ADC-stuff in that pdf already. They seam simply measure from top to bottom and bottom to top and average that. It gives some bits difference. One could use only one read, result is valid, too. It is just whether two times the processing time might not be wanted. Or precision. I might need to sleep a night over that all. To me it still looks like the error is simply missing the 1/5 vcc factor correction. Oh, I just noticed: it might be a misunderstanding what to expect from analogRead(). I expect it to behave in accordance to analagReference() and hide the 1/5 internal factoring with vccm. |
Beta Was this translation helpful? Give feedback.
-
Ok, I think I would like to implement this solution (I will submit a pull after the pending pulls are pulled...):
This would make it easy for a starting user and provides a clear interface, All this should be documented in the wiki. I will happily do that. |
Beta Was this translation helpful? Give feedback.
-
Sooo. It is alive. https://github.com/holgerlembke/lgt8fx/blob/master/lgt8f/cores/lgt8f/wiring_analog.c#L169 Results seem to be spot on, ähm, 3,5% difference. Vcc/A0: 4.6297 V |
Beta Was this translation helpful? Give feedback.
-
That's 3‰ , not 3%! |
Beta Was this translation helpful? Give feedback.
-
Moin.
I try to understand how measuring the supply voltage works. I have a LGT8F328, the 1.0.7 and use the following code.
Result is:
So the 1 V is a little bit wrong. Did I do something wrong? Did I miss something? What?
// me confused.
Beta Was this translation helpful? Give feedback.
All reactions