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.

TM4C123GH6PGE: qs-logger Example Source Code ADC Questions

Part Number: TM4C123GH6PGE
Other Parts Discussed in Thread: INA198

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?

        Please may I explain in detail.

Regards,

Jame,Shin

  • Hi Jame,

      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.

  • Greetings,

    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...

  • 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 ) !!

    Regards,

    Jame,Shin

  • My friend,

    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?

    Regards,

    Jame,Shin

  • My friend,

    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:

    • Green-Stamped the Answering Post (Not your own)?
    • Confined your thread to that which your Subject Line (thread title) announces?

    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...

  • Q1:

    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.

  • Jame shin said:
    Q1> 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 shin said:
    Q2> 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.

  • This article might help you for the current sensor.

    http://www.ti.com/lit/ml/slyy154/slyy154.pdf

  • Greetings Bob,,

    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 Crosby said:
    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.

    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...

  • CB1,

    Your argument is sound. Either 4100/819 or 2503/500 will produce equivalent results. Since I did not write the original code, I do not know why the original author chose 4100/819, I can only explain why it works. Personally I would have used floating point numbers because the TM4C123 has the hardware floating point unit.

  • Bob,

    Bob Crosby said:
    Since I did not write the original code, I do not know why the original author chose 4100/819

    Thank you - nor did our group recognize the 'means' by which that (past) code author 'chose' those particular values.    We did note the 'nearness of 4100 to 4096' (ADC's full scale range) - yet we could not properly develop his/her choice or insight...

    Our presentation of a 'General Solution Method' may prove superior - for those who've 'read this far.'

    It seems advisable to (also) advise any/all reading that the use of (either):

    • Voltage Divider (as your schematic revealed)
    • Gain Stage (as I had earlier proposed)

    will 'Reduce the ADC's resolution!'   

    The best means to minimize this unwanted 'Loss of Precision' is by:

    • 'Well Mating' the outside world signal's range (or span) such that it near matches the voltage span of the ADC
    • OR - in the case of a signal input whose span is less than that of the ADC - reducing the ADC's Reference Voltage - so that it matches the input signal's span.    (this 'maintains' the ADC's full resolution - albeit over 'less than the full' (normal) input  voltage span of the MCU's ADC)

     For the 'absolute purist' - there exist high performance (stand alone) ADCs which solve such 'range issues' by encompassing a wider input signal span - while providing high (usually 14 bits or greater) of signal resolution.

  • Sorry for asking so many questions.

    Bob said > 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.

    Q3> 6.8 How did the numbers come from?

         And how does the accuracy increase if the two op amp Rs values are the same?

             Rs Ratio 105/(105+105) = 0.5,  

             3000/4096 = 0.732421875

             0.732421875/0.5= 1.4648

           I didn't understand how it would be correct.

           Please may I explain in detail.

    Q4> Not 1NA198. INA198.

           I have read the slyy154 Documentation (Current Sensing) Well , I'm not sure which part to select.

           I do not know the meaning of the numbers below clearly but I can not apply.

          My first post> Q2> ui32Current = (ui32Current * 200) / 273;

                               How did the numbers 200, 273 mean?

    Q5> In the previous post, this is the (maximum) current sense value in the [Firgure1] Block Diagram.

           +5V_INT : (normal) 1.5A   (max)) 3A

           +5V_EXT : (nomal) 0.7A   (max) 1.5A

         Please give me advice and help on what to change or modify?

    Thank you for answering the previous question about my Q2.

    So what is the ADC sampling conversion completion time?

    Q6> Is the symbol (FADC, FCONV, TS, TC) correct indicated in the illustrated Figs. ?

    Q7> Is the sampling frequency (1 / TS) 1 / 250ns = 4Mhz?

    Q8> What is the difference between FADC = 16Mhz and Sampling Frequency (1 / TS) = 4MHz?

    Best Regards,

    Jame,Shin

  • Jame shin said:

    Bob said > 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.

    Q3> 6.8 How did the numbers come from?

         And how does the accuracy increase if the two op amp Rs values are the same?

    The choice of 105K was arbitrary. The point is for divide by 2, both resistors are the same value. In real life the choice is made by comparing the leakage current into the unity gain op-amp to the current consumed through the resistor divider. Low value resistors may result in too much current being drained from the voltage source you are trying to measure. Too high a resistor value means the op-amp leakage becomes a significant error factor in the measurement.

    As you calculated, using a divide by 2 (both resistors the same) means each bit is worth 1.4648mV. With the original 105K and 18 resistors (divide by 6.8333) each bit is worth 5mV. The resolution is a single bit. The measurement can be no more accurate than 1/2 of a bit (quantization error). Scaling the input voltage to make the smallest mV/bit gives you the smallest quantization error.

  • Jame shin said:

      My first post> Q2> ui32Current = (ui32Current * 200) / 273;

                               How did the numbers 200, 273 mean?

    Thanks for clarifying my misunderstanding (INA198, not 1NA198).

    The 200/273 ratio (= 0.7326007326...) is roughly the same as the mV/bit of the ADC (3000/4096 = 0.732421875). I have no idea why they chose to use 200/273 instead of 3000/4096 on a 32-bit microcontroller.

  • Jame shin said:

    Q5> In the previous post, this is the (maximum) current sense value in the [Firgure1] Block Diagram.

           +5V_INT : (normal) 1.5A   (max)) 3A

           +5V_EXT : (nomal) 0.7A   (max) 1.5A

         Please give me advice and help on what to change or modify?

    Using the INA198 with a maximum current of 3A and a maximum ADC input of 3V you need to use a sense resistor of 0.01 Ohms (not 0.1 Ohms). The 3A current will give 0.03V across the resistor. The INA198 multiplies that by 100 to give 3.0V to the ADC, which will be full scale. For the maximum 1.5A current, you could use a 0.02 Ohm resistor to achieve more precision. Of course you need to use precision resistors to get accurate results.

  • Jame shin said:
    Q6> Is the symbol (FADC, FCONV, TS, TC) correct indicated in the illustrated Figs. ?

    Yes,

    Jame shin said:

    Q7> Is the sampling frequency (1 / TS) 1 / 250ns = 4Mhz?

    No, typically we refer to the sampling frequency as how often you sample, not the inverse of the sample time. In your example the sample frequency would be 1M sample/second (1Msps or 1Mhz).

    Jame shin said:

    Q8> What is the difference between FADC = 16Mhz and Sampling Frequency (1 / TS) = 4MHz?

    FADC is the frequency at which the ADC operates. Sampling frequency is how often a sample can be taken. With this 12 bit ADC the default sample time is 4 ADC clocks and then 12 ADC clocks for the conversion, one for each bit. Therefore the FADC (ADC clock) is 16 times faster than the maximum sample rate. 

    In most application the sample rate is even slower. If the source is a high impedance, the sample time must be increased. If more than one channel is to be converted, the sample rate for each channel is divided among the channels converted.

  • Bob Crosby said:
    I have no idea why they chose to use 200/273 instead of 3000/4096 on a 32-bit microcontroller.

    Nor does my small group - yet we note that 3000/15 = 200 and 4096/15 = 273.066.     In the 'olde days' (when '8-bit MCUs' roamed) finding such 'lowest common denominator' often 'paid off.'     (it is suspected that the 'unknown programmer' (clung) to his/her 'past ways!')    

    Your direction of 3000/4096 is the superior 'conversion factor' (i.e. it is 'Mystery Free') for today's compilers & MCU capabilities...

  • Hello friend Cb1,

    Cb1 said > Nor does my small group - yet we note that 3000/15 = 200 and 4096/15 = 273.066. 

    Q1> Why did you divide by 15? and What does the number 15 mean?

             Please may I explain in detail.

    Best Regards,

    Jame, Shin

  • Hello Bob,

    I learn a lot from you. thank you.

    Bob Said >  current of 3A and a maximum ADC input of 3V you need to use a sense resistor of 0.01 Ohms.   

                        1.5A current, you could use a 0.02 Ohm resistor

    Q9> Please tell me which theoretical formula came from 0.01 Ohm & 0.02 Ohm ?

    Bob Said > 12 bit ADC the default sample time is 4 ADC clocks and then 12 ADC clocks for the conversion, one for each bit

    Q10> When sampling an analog signal by Sampling Nyquist Theory, I know you can restore the original signal if the sampling rate is 2 times

              But why do you need 4 ADC clocks?

              Please may I explain in detail.

             And is it correct that I understand below?

             12 ADC clocks / ADC 12bit (ADC 1 clock / 1 bit ADC-resolution)

             (Therefore ) 4 ADC CLK + 12 ADC CLK = 16 ADC CLK

                                16 ADC CLK x 1Mhz (sampling frequency) = 16Mhz (FADC)

    Bob Said > If more than one channel is to be converted, the sample rate for each channel is divided among the channels converted.

    Q11> I will design the MCU's AIN0 / AIN2 Volt Measure and AIN6 / AIN7 Current Measure.

             Does that mean 1Msps / 4ch = 250Ksps? and Is Volt & Current ADC conversion completion time Tc = 1us * 4 ch = 4us?

             Voltage of ADC0 Module Will ADC data capture be faster with current allocation of ADC1 module?

    Best Regards,

    Jame, Shin

  • Hello Jame,

    Twas the day before Christmas - and from cb1 firm's 'back-room'

    Emerged dark smoke - then fire - and soon a loud 'Boom'

    Twas Jame's resistors - (0.01 & 0.02Ω) - once new & pristine

    Yet their wattage rating - (we now fear) - enabled Power obscene

    While awaiting smoke's clearance - staff demanded a session

    And thus now presented - today's 'basic' math lesson...

    ......... 

    while (applause > 2x ambient noise)

    {   (Thank you - thank you very much ...  voiced in cb1's best 'Elvis');   }

    Jame shin said:
    Why did you divide by 15? and What does the number 15 mean?

    15 is the 'Least Common Denominator' of  (both)  3000 & 4095.    From 'dictionary.com'  "Least common denominator definition, the smallest number that is a common denominator of a given set of fractions."

    Young (and gifted) staff note that both 3000 & 4095 are 'Integrally Divisible' by 15 - which yields 200 & 273.    You should know that (either) 'dividing or multiplying each element of a  fraction (i.e. numerator & denominator) by the same number - does not alter that fraction's value!'     (For those 'eagle eyed' - the original programmer (for SURE) rounded 4096 to 4095 - as it proves of 'No Consequence' upon an MCU's ADC count.)    

    As my (one-up) post noted - the 'unknown programmer' most likely had experience w/less capable MCUs (i.e. 8 bit) and thus the desire was 'ALWAYS to minimize the numeric values which were fed to those (past) MCUs...'

    Indeed your 'decoration of this post' w/the 'Seasonal touch of GREEN' (so clearly earned) - awaits Jame's 'green pen!'    Ideally prior to (your) 'charred current sense resistors' - descending to (near) room temperature ...

  • Jame shin said:
    Q9> Please tell me which theoretical formula came from 0.01 Ohm & 0.02 Ohm ?

    For maximum current of 3A and maximum voltage into ADC of 3.0V, with a multiplication factor of 100 for the INA198 the maximum voltage across the sense resistor is 3.0V/100 or 0.03V. With a maximum current of 3A the maximum resistor is R = V/I  = 0.03/3.0 = 0.01 Ohm. The same calculation for a maximum current of 1.5A gives 0.02 Ohm.

    CB1's poem makes a very good point. Remember to calculate the power dissipation of the resistor. P = I*I*R = 3A * 3A * 0.01 Ohm = 0.09W;

    1.5A * 1.5A * 0.02 Ohm = 0.045W

  • Jame shin said:
              But why do you need 4 ADC clocks?

    That is a very good question. The simple answer is that 4 ADC clocks is the fastest time that this ADC converter will allow. But in some designs 4 ADC clocks (250nS) may not be enough. During the sample time, a switch is open and the voltage on the ADC input pin charges (or discharges) an internal sample and hold capacitor. The resistance of that switch, the size of the internal capacitor and the size of the source resistance all play a factor in how long it will take before the sample capacitor has equaled the voltage of the external source. Sampling a sensor with high source impedance takes longer for the capacitor to charge. This is why in the DK-TM4C123XL design shown above there is an op-amp to provide a low source impedance after the 105K/18K resistors. 

    Here is a good note on the subject: http://www.ti.com/lit/an/spna088/spna088.pdf

    Jame shin said:

    And is it correct that I understand below?

             12 ADC clocks / ADC 12bit (ADC 1 clock / 1 bit ADC-resolution)

             (Therefore ) 4 ADC CLK + 12 ADC CLK = 16 ADC CLK

                                16 ADC CLK x 1Mhz (sampling frequency) = 16Mhz (FADC)

    Yes, your understanding is correct.

  • Jame shin said:

    Q11> I will design the MCU's AIN0 / AIN2 Volt Measure and AIN6 / AIN7 Current Measure.

             Does that mean 1Msps / 4ch = 250Ksps? and Is Volt & Current ADC conversion completion time Tc = 1us * 4 ch = 4us?

    Yes, that is correct

    Jame shin said:
         Voltage of ADC0 Module Will ADC data capture be faster with current allocation of ADC1 module?

    You have two ADC modules on the TM4C123 device and they can be programmed such that they are sampling and converting at the same time. If you use one ADC for voltage and the other for current, you can have the voltage and current of a single supply (average over the 250nS sample window) at the same point in time. The sample for the second supply would then be 1uS later in time, but again the voltage and current measurements would be simultaneous.

  • Seasonal Greetings Bob,

    Bob Crosby said:
    CB1's poem makes a very good point. Remember to calculate the power dissipation of the resistor. P = I*I*R = 3A * 3A * 0.01 Ohm = 0.09W;

    Thank you - what was presented here was a (much) 'sanitized' version of the young staff's poetic offering...    (and they (properly) 'mocked me' for using 'current' where 'power' was intended ... now fixed...)   

    The 'care & handling' of 'Current-Sense Resistors' (and/or similar current measuring devices) demands 'even more' than the calculation of 'Power Dissipation.'    And - the 'short-form' - 'back-forth' of any forum presentation - cannot possibly compete w/a proper, 'Engineering School Syllabus.'    (and that - is poster Jame's (and others') ongoing dilemma...)

    Beyond the 'Calculation of Power Dissipation' (when the device is deployed in a 'current sensing' role) - it is required:

    • to extract the heat absorbed by the sensing component as well as that component's pcb pads & traces
    • to provide for 'unexpected & unwanted' EXCESS Currents - which may occur due to system issues and/or failures
    • to recognize the extent & impact of the additional heating effects added by nearby components and/or air-flows
    • and the recognition that 'n watts' (calculated) of dissipation usually requires a 50% 'over-rating'  (ideally as a Safety Factor0

    Where does one (even) begin?    And often - even those 'freshly emerged' from a 'top engineering school' do not have the 'solid experience' to recognize, 'ALL that IS required!'   

    Might it be then that (only):

    • Proper Schooling & Training
    • Focused Experience
    • and first-hand experiencing (as you & I have) the: 'Smoke, Light, & Fire' of 'Over-Dissipating Components'

    qualifies one for our (usually) calm, (mostly) 'fire-free' profession?      (maybe...)

  • Hello Bob,

    Thanks for the clear answer.

    The last question for this thread.

    Previous Q10 Supplemental Question.  

    Tc (ADC converstion Time) = 1us and Ts (ADC Sample Time) = 250ns.

    So, (ADC converstion Time) / (ADC Sample Time) = 4.

    You explained to me. In some designs, four ADC clocks (250nS) may not be enough.

    My understanding is insufficient.

    Q12> During the ADC Conversion Time (Sampling, Quantization, Encoding) time,

             Why is it divided into 4 to collect complete analog data?

             Perhaps I do not know exactly the ADC Sample time.

    Q13> And can may you explain if 4 ADC clocks are not enough?

    I change from TM123GH6PGE (144-LQFP) to TM123D5PM (64-LQFP) with PCB space conditions to design.

    By the way, TM123D5PM device has VREFP & VREFN pins merged with VDDA & GNDA pins.

    (ADC Electrical Characteristics)

    VDDA : (min) 2.97V (Nom) 3.3V (max) 3.63V   (only device TM123D5PM)

    VREFA+ : (min) 2.4V (Nom) VDDA (max) VDDA

    Q14> Can you advise how to supply power to the merged pin (VDDA, VREFP) from the 3000mV / 4096 source code review?

           Is there any problem in supplying VDDA + 3.0V !! (Tolerance 3V-(min) 2.97V = 0.03V)

    Finally, what I'm worried about is the MCU time share ratio question.

    The application content to design.

    (note ) OLED 96x64 Display

    1. Data from six UART Rx ports simultaneously input for a long time (approximately three consecutive hours). (Baud rate 115200bps, 8.68us / 1bit)

       one of six UART Rx ports is selected to display ASCII data on the OLED.

    2.When UART ASCII data is not displayed in OLED

    2-1. UART-0/1/2, Rx By counting the data input from the three ports, byte count value is displayed on the OLED.

    2-2. +5V_EXT & +5V_INT ADC0 (Voltage) and ADC1 (Current) of the power supply simultaneously collect and OLED display ADC data.

         2 ch (Volt) + 2ch (Current) = 4Ch, Tc (ADC conversion Time 1us / 1Ch), so Tc = 4us

         (i.e.) 1 or 3 UART ports 8.68us / 1bit, ADC 4ch simultaneous acquisition Tc = 4us / 4ch

    Q15> In the above, No. 1 the function implementation is completed.

           Is it possible to use MCU time share ratio for the content of No. 2 ?

          If the possible, what is it?

           May I ask you for expert group advice and advice.

    Best Regards,

    Jame, Shin

  • Jame shin said:

    Q12> During the ADC Conversion Time (Sampling, Quantization, Encoding) time,

             Why is it divided into 4 to collect complete analog data?

    The sample time is a minimum of 4 ADC clocks. That gives a minimum sample time of 250nS. It is not that the sample time needs to be divided into 4 parts, just that there is enough time for the internal sample capacitor to equalize with the external voltage. A look at the ADC converter's specifications show a maximum input resistance of 500 Ohms and input capacitance of 10pF. The goal is to allow enough sample time that the internal sample capacitor can charge all the way to within 1/2 LSb of the source voltage. Worse case is if the internal sample capacitor is at one extreme and the source voltage the other as shown in Figure 8 of the Application Note I previously referenced.

    In these examples, only two of the four scenarios adequately charged the sample capacitor in less than 250nS. The other two scenarios would require a longer sample time.

    Jame shin said:
    Q13> And can may you explain if 4 ADC clocks are not enough?

    The above scenarios are good examples. For more details you need to read the application note written by James Childers:

    http://www.ti.com/lit/an/spna088/spna088.pdf

    Jame shin said:
    Q14> Can you advise how to supply power to the merged pin (VDDA, VREFP) from the 3000mV / 4096 source code review?

           Is there any problem in supplying VDDA + 3.0V !! (Tolerance 3V-(min) 2.97V = 0.03V)

    It is OK to supply VDDA at 3.00V if you can guarantee that the supply does not drop below 2.97V. (The supply must be stable to get accurate results as it is also the reference.) However, it is just as easy to supply 3.3V and use 3.30 instead of 3.00 in the equation to calculate the actual measured voltage.

    Your last question (Q15) is hard for me to understand. If you are using the ADC converter to measure two voltages and two currents and then just outputting them to an OLED, then you do not need to do a conversion every 4uS. You cannot get the data out to the OLED that fast, and a human eye cannot discern the different values at that rate. Using an interrupt routine that fires every 100mS and starts the ADC conversion and then outputs the data to the OLED will be more than adequate. 

  • Hello Cb1,

    Haven't visited this thread !! I would like to see PM Cb1.

    This is a project that I have been talking with you together since 3 months ago.

    I would like to hear your answers to the questions in the previous post.

    The sentence from  “Finally.. 1,2, 2-1,2-2"  to "Q15". ( MCU Occupancy Time or Interrupt Occupancy Time)

    Best Regards,

    Jame, Shin

  • Greetings,

    Have not many/most of your questions been, 'Vendor's MCU Specific' - and those are (most always) best handled by 'trained vendor agents.'     My small Tech team are 'outsiders' - just like you, Jame.

    You may note that general engineering issues - and general problem solving - are the areas from which my firm derives income.    (MCUs are just, 'One part of that puzzle' - it proves 'rare' that, 'An MCU - by itself - can serve as an efficient & complete 'Engineered System.')

    Note too - I have offered repeated advice.    (often my group suspects - not (really) heard or accepted - by our friend Jame.)

    Is it not true that many (perhaps most) of your issues & questions result from (what appears to be) your, 'Crash Course' in 'MCU & related electronic engineering?'    Top U.S. colleges most always demand, '4 years of focused efforts' to gain an engineering degree.    (advanced degrees, 'Add to that total.')

    It is 'normal/customary' that most always intense:

    • Technical Schooling
    • coupled w/multiple (successful) years w/in a diverse & challenging tech work-place

    are 'required' to reasonably succeed in today's 'Global, highly competitive' Tech Environment.

    As past U.S. 'Defense Secretary Rumsfeld' once noted, "There exist 'Known Unknowns AND Unknown Unknowns!"     When (both) of the 'bullet-points' (just above) are bypassed - the 'Extent of Unknowns' vastly multiplies - greatly impeding progress.     My small firm operates much like 'Euro-based Apprenticeships.'    We strive to mentor, train, & further develop tech 'talent' - yet in a manner (generally) modeled after the 'core curriculum' of the best U.S. Universities.   

    I've encouraged you (several times now) to seek:

    • local (regional) expertise
    • study & model your learning course after those of the best engineering schools
    • find nearby 'others' - also seeking 'Further Tech Understanding & Capability.'     (there always exists, 'Strength in Numbers' - Dividing a task into small parts 'cries out' for 'group solution!')
    • avoid 'committing' to tasks which - while 'attractive at the moment' - may (Not) prove best for your long-term development

    The response you've received here has been, 'Off the Charts' - often vendor agents (& even my group) have, 'Ventured far from the MCU Focus' - which surely IS (and should remain) the 'Basis of this (and similar) MCU-Centric Forums.'

    Perhaps it proves 'wise' for you to consider how my small group (consistently) attracts 'Bright, young talent' - harvests their efforts effectively (proved by our often 'winning' - when competing against tech firms 10x our size) - while 'Building & Broadening (our talents') Tech, Finance & Small Biz Skills.'     

    While a wide & deep ocean separates us - perhaps our 'objectives' are (closer) than you imagine...    And ... just maybe - our suggestions/guides have (some) merit...

  • Hello Bob,

    Sorry and thank you. I haven't read the application note. (spna088.pdf)

    Bob said > it is just as easy to supply 3.3V and use 3.30 instead of 3.00 in the equation to calculate the actual measured voltage

    The schematic you previous posted asks if applied 3.0V.

    3.3V is exist the schematic, why not use it?

    Best Regards,

    Jame,Shin

  • Hello Cb1, 

    If you look at the time difference of the country France, I think it is dawn

    Thank you very much.

    Bast Regards,

    Jame,Shin

  • Jame shin said:
    If you look at the time difference of the country France, I think it is dawn

    In that case - perhaps the (French) Hare & Tortoise (you've past introduced both) can team ... to rebuild the (much collapsed) 'Notre Dame' Cathedral...   (And that only after they've directed (many) 'highly specific questions' to the 'Cathedral Repair forum' - on a regular/repeated basis...)

    Rejecting 'Classic Learning recommendations' via the presentation of a, 'Non Sequitur' (conclusion or statement that does not logically follow from the previous argument or statement) is noted ...  and remains disappointing & (entirely) non-productive...   

    The fact that a recommendation, 'May present a challenge' should not lead to its rejection!     Your attempt to, 'Implement those recommendations' - especially via 'KISS-based' directives (Slow - Systematic/Steady - Measured) - is expected to yield, 'FAR GREATER (i.e. real) Tech Understanding & Capability!'    

  • Jame shin said:
    The schematic you previous posted asks if applied 3.0V.

    3.3V is exist the schematic, why not use it?

    The accuracy of the ADC conversion is no more accurate than the reference used. The schematic I previously posted created a clean 3.0V reference that was unaffected (less affected) by the switching noise that will be on the 3.3V supply which is used for the rest of the device. On the 64 pin device, the reference is tied together with the ADC supply pins to reduce the number of required pins. This means there will inherently be some noise injected from the ADC converter. If you use the same 3.3V supply for the ADC and the rest of the chip, even more noise gets injected. Proper capacitor decoupling near the ADC power pins will help.

  • Hello Bob,

    (VDDA, VREFP)

    1. 3.0V : 3000mv/4096 = 0.732421875   / R divider ratio(105K ,18K) = 5.0048828125 mV / ADC bit

    2. 3.3V : 3300mv/4096 = 0.8056640625 / R divider ratio(105K, 18K) = 5.50537109375 mV / ADC bit

    Q1> Should 3.3V change the R divider ratio of the op amp to minimize ADC quantization error?

    Q2> previous post > Q2> ui32Current = (ui32Current * 200) / 273, How did the numbers 200, 273 mean?

         Bob Said> The 200/273 ratio (= 0.7326007326...) is roughly the same as the mV/bit of the ADC (3000/4096 = 0.732421875).

           (VDDA, VREFP) When the voltage is 3.3V, it is 5.505mV / ADC bit.

           How do you calculate the mA/ADC bit with a (+ 5V_EXT: (nomal) 0.7A (max) 1.5A) current measurement?

           I don't understand the current calculation,  (i.e.) Volt to Current conversion

           can I change "ui32Current = (ui32Current * 1500) / 4096" source code !!

           Please may I explain in detail.

    Best Regards,

    Jame,Shin

  • I am afraid you are concentrating on the details and failing to understand the big picture. Let me try to explain again using your circuit requirements.

    First, the ADC is a ratiometric converter. That means the digital value obtained gives the ratio of the input voltage to the reference voltage. It is a 12 bit converter so the denominator of the ratio is 2^12 or 4096. Using the 64 pin part with VADC connected to VREFP, let's use a reference voltage of 3.30V. Now you want to convert a signal that goes up to 5.0V. You cannot correctly measure an input signal that  greater than your reference voltage. Therefore you add a voltage divider. A simple divide by 2 using two equal value resistors allows for an input voltage from 0V to 6.6V. This gives some room in case your 5V source is higher than expected. You can convert the digital value from the ADC to a floating point number that represents the external voltage by: 

        float fVolt;
        unsigned int value;
    
        ...
        ADCSequenceDataGet(ADC0_BASE,3,&value); 
        fVolt = (float)value * 2.0 * 3.30 / 4096.0;
    

    If you change the resistor divide ratio, change the 2.0 to the new correct value. If you change the reference voltage, change the 3.30 to the new value.

    Jame shin said:
    Q1> Should 3.3V change the R divider ratio of the op amp to minimize ADC quantization error?

    It is probably not worth the effort. With divide by 2, the max voltage is 6.6V and the quantization error is 1.6mV. The smallest divider you can use and still support 5V input is 1:1.6. That would give a maximum input voltage of 5.28V and a quantization error of 1.3mV.  The 0.3mV difference is likely to be lost in other noise. Do you really need that much accuracy?

    Jame shin said:
    How do you calculate the mA/ADC bit

    For the example with a maximum current of 1.5A. If you choose a 0.01 Ohm precision shunt resistor, the voltage across that resistor at 1.5A is 0.015V. Using the INA198, that voltage is multiplied 100 times, so the voltage into the ADC is 1.5V.  (You can use a 0.02 Ohm shunt to get better resolution, but do you need it?)

    To change the digital value from the ADC into a floating point number that represents the current in Amps, use:

        float fAmp;
        unsigned int value;
        ...
        ADCSequenceDataGet(ADC0_BASE,3,&value); 
        fAmp = (float)value / 0.01 * 100.0 * 3.30 / 4096.0;
    
    

    If you use a different resistor, change the 0.01 to the new resistor value.

    Note that in both the voltage and the current equations, the C-compiler will combine all of the constant numbers into one floating point constant such there is really only one floating point multiplication done. Since the TM4C123 has a hardware floating point unit, the computation is relatively quick.

    For the circuit with the 0.7A maximum current, you can use 0.01, 0.02 or 0.04 Ohms. Just make sure that the maximum current times the value of the shunt resistor times 100 does not exceed 3.3V.

  • Hello, Bob

    You see exactly and have insight.

    I has a afraid behind the psychological inner side that does not know the whole

    I am stable through your answers during the process

    I grow through your clear answer. Thank you.

    The time difference of each country comes 2020 first.

    Greetings first.

    Best wishes for a Happy New Year.

    Best Regards,
    Jame,Shin