This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: TM4C123GH6PGE
Hello all Ti Engineer.
This is the source code question for the ProcessDataItems () function in the qs-logger / Acquire.c file.
Q1> ui32Millivolts = (g_pui32ADCData[ui8Idx] * 4100) / 819
12-bit precision ADC = 2 ^ 12 = 4096
Explain mV per ADC code = (VREFP-VREFN) / 4096 in the data sheet.
How did the numbers 4100, 819 mean?
Please may I explain in detail.
Q2> ui32Current = (ui32Current * 200) / 273
How did the numbers 200, 273 mean?
Honestly, I have no idea how to answer your question. The example was developed very long time ago by the software team. My impression is that some calculation and manipulation was intended to fine tune the results specifically for the sensors (i.e. the 9-axis digital sensor on the development board). Perhaps the details of these numbers (i.e. 4100, 819, 273) may be in these sensors' datasheet.
I think this example's main purpose is to illustrate how to use the MCU to collect data from the various sensors on the TM4C123 development board and display them on the LCD screen. Again, the emphasis is on the MCU's interface to these sensors and not the sensors themselves. Therefore, please do not get hung up on the post processing of the data. In your application, I assume you will be interfacing to different components/sensors. I know this may not be the answer you desire but I don't have a good answer for them.
We are glad that we were able to resolve this issue, and will now proceed to close this thread.
If you have further questions related to this thread, you may click "Ask a related question" below. The newly created question will be automatically linked to this question.
In reply to Charles Tsai:
Vendor's Charles has - in my opinion - well answered by stating those (unusual) numbers 'fine-tune' the, "Sensor Outputs (perhaps range) to the 3300mV range of your MCU's ADC."
Those numbers serve as, 'Range Accommodation Factors' - which 'best adapt the (combined) Sensor Output Level to that of the MCU's ADC.'
For example: 4100/819 = 5.006 Those 2 numbers (usually) represent the 'lowest two values' which 'Scale Up the ADC's reading so that the ADC's 'Full Range' is accommodated.' To further clarify - it is (likely) that the sensor employed has a 'maximum output' which is only one-fifth of the ADC's full-scale input range. (i.e. it is suspected that the sensor's maximum output is ~660mV - which is (only) 1/5th of the MCU's full scale capability. Assuming the Analog Reference Voltage was 3300mV - the ADC would read '819' w/an input signal of 660mV. (that is 'where' the '819' originated.) The '4100' value (likely) is the 'round-off' of 4095 - which is the ADC's full-scale reading.)
An alternate means exists to achieve this 'mating of Sensor Output to ADC scale.' Via hardware - a 'gain stage' may be added which boosts the sensor's output by a factor of 5! Adding such hardware adds to board's size & cost - thus the use of 'Range Accommodation Factors.'
it should be noted that (both methods) degrade ADC precision. Ideally a sensor is chosen which (naturally) best matches the ADC's input range - thus eliminating the requirement for, 'Range Accommodation or external signal boosting/reducing.' In the case of your first example - to maintain (the potential) for 12 bit ADC precision - the 'Analog Reference Voltage' would have to be lowered (from 3300mV to 660mV.) In that manner - the ADC's full range IS exploited - and the 12 bit count-resolution is restored.
This explanation holds true for your 2nd example as well. In that case the signal is 'reduced' (scaled down by 0.733) yet the principle is the same...
In reply to cb1_mobile:
Hello Cb1 & Charles,
In [Figure1] block diagram, I want to display OLED by measuring 5V fixed measurement and current.
But I have no idea
Q1> Please give me advice and help on what to change or modify?
Q2> How long does it take for a + 5V input to be displayed on an OLED via ADC conversion as a U1 output signal?
ADC conversion time ( 1us) + Display ( about 1ms ) !!
In reply to Jame shin:
Were not your original questions (both of them) very well answered? (Charles was good enough to mark my post as 'Suggested Answer' - something my team never does!)
You now have vastly expanded the, 'Field of Play' yet have 'Made ZERO mention' (or thanks) for the time/effort (already) invested - in your exclusive behalf! (i.e. as your thread's title well notes, "QS Logger - Example Source Code Questions.")
Can that be right?
My dear Friend,
Cb1 said> your original questions (both of them) very well answered?
Cb1 said> Can that be right?
Yes it is. And great answer.
I know you are doing Justice in the forum.
So I am your fan and my star
I saw an additional valuable answer , visited once more in the previous post. Thank you.
May I Can you answer Q1 and Q2?
My small group's goal is (Neither) fan or stardom - instead we seek to provide 'General 'Tech' Problem Spolving Methods & Insights.' (rarely Cut n Paste)
When a post is 'well answered' (i.e. RESOLVED) it is normal to mark that ANSWERING POST (not your own) with the Green Stamp. This enables follow-on readers to more quickly & easily 'Recognize the Answer' - multiplying the Value of the Thread! AND the forum!
Have you followed forum procedure:
As stated earlier - your NEW Questions wander FAR FROM your thread's "ADC Source Code Questions" - which were (notably) answered...
We may - or may not - deal w/those - if & when they appear in a new thread. Placing multiple 'unrelated' issues w/in a single forum thread makes 'Categorization of the thread impossible' - thus is to be avoided...
You need to look at the entire circuit to understand the 4100/819 multiplier. This example is for the TM4C123G Development Board. This board has a resistor divider network on the analog inputs.
The 18K and 105K resistors ratio the voltage down by 18/(18+105) = 0.1463
VrefA+ is 3.0V, not 3.3V
Now the relationship of external voltage in mV to ADC count is:(3000/4096)/0.1463 = 5.006
Now they could have changed the ADC value to a floating point number and multiplied by 5.006, but they chose to use integer math. Note that 4100/819 = 5.006.
Best Regards,Bob Crosby
Jame shinQ1> Please give me advice and help on what to change or modify?
The original example supports an input voltage up to 20V. If your input voltage does not exceed 5V, you can change the resistor divider instead of divide by 6.8, to divide by 2. (Max scale would then be 6V). For example both Rs equal to 105K. This will give you more accuracy. I cannot comment on you current sense circuit since I did not find a 1NA198 datasheet.
Jame shinQ2> How long does it take for a + 5V input to be displayed on an OLED via ADC conversion as a U1 output signal?
That is dependent on your OLED device and the SPI baud rate.
In reply to Bob Crosby:
This article might help you for the current sensor.
You're providing those 2 schematics (neither supplied by the o.p.) added most helpful insight - thanks much for that.
Now may we (respectfully) note that the 'origin' of (both 'poster questioned' values) '4100 & 819' - appears not clearly explained.
Bob CrosbyNow they could have changed the ADC value to a floating point number and multiplied by 5.006, but they chose to use integer math. Note that 4100/819 = 5.006.
Now there is no doubt that the 5.006 quotient 'holds' for that number pairing - yet staff & I believe that the, 'How & Why' of (both) '4100 & 819' are unexplained.
Again - the derivation of the 5.006 'factor' is clear. My group believes that, "Two lower numeric values may be 'more directly' (and easily) calculated!" This is achieved by simply multiplying 5.006 by 1000 - and then dividing that result by 1000.
Thus 5.006 * 1000 = 5,006; then 5,006 / 1000 = 5.006! However - our mechanism enables a clear, 'Divide by Two' - yielding '2503 / 500.' Note that this number pairing remains equal to (5.006) yet being lower valued - reduces calculation demand. (nominally in this case - yet still 'best practice!')
The method my group presents is (again) a 'General Solution Method' - it IS of interest if you could describe, "How the paired '4100 & 819' were (specifically) chosen!"
Thanks your time & attention...
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.