<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>8-bit MicrocontrollersのトピックRe: ADC-Negative values!!</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179135#M12812</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Fredy,&lt;BR /&gt;&lt;BR /&gt;If the analog signal goes negative and is centered around the ground to your CPU It will only be able to see the excursions above ground which is only the top half of your analog signal.&amp;nbsp; You will probably need an op-amp for scaling and offfset correction.&amp;nbsp; This will allow your signal to be centered in the middle of the range of your ADC so your ADC can see the entire AC waveform.&lt;BR /&gt;&lt;BR /&gt;Peter&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Jan 2008 09:05:47 GMT</pubDate>
    <dc:creator>PeterHouse</dc:creator>
    <dc:date>2008-01-14T09:05:47Z</dc:date>
    <item>
      <title>ADC-Negative values!!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179134#M12811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have already adc in gp32 and&amp;nbsp; works fine, but I need to obtain binary negative values when I put a analog&amp;nbsp; signal with positive a negative values, I only can see de positve side.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Somebody knows how I can represent negative values??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fredy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2008 08:23:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179134#M12811</guid>
      <dc:creator>fredycolombia</dc:creator>
      <dc:date>2008-01-14T08:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: ADC-Negative values!!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179135#M12812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Fredy,&lt;BR /&gt;&lt;BR /&gt;If the analog signal goes negative and is centered around the ground to your CPU It will only be able to see the excursions above ground which is only the top half of your analog signal.&amp;nbsp; You will probably need an op-amp for scaling and offfset correction.&amp;nbsp; This will allow your signal to be centered in the middle of the range of your ADC so your ADC can see the entire AC waveform.&lt;BR /&gt;&lt;BR /&gt;Peter&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2008 09:05:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179135#M12812</guid>
      <dc:creator>PeterHouse</dc:creator>
      <dc:date>2008-01-14T09:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: ADC-Negative values!!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179136#M12813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Fredy,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;To further elaborate on the comments of Peter -&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;There seems to be two possibilities using a single op amplifier for each channel, one using an inverting configuration, and the other using a non-inverting configuration.&amp;nbsp; If you are not already familiar with these terms, most text books on analog topics should cover these basic configurations.&amp;nbsp; To keep things simple, the op amp will need to be of the output "rail-to-rail" type, and operate from the same supply as the MCU.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;For the non-inverting configuration, the input signal would be applied to the non-inverting :smileyplus: input.&amp;nbsp; There will be a feedback resistor between&amp;nbsp;output and inverting :smileyminus: input,&amp;nbsp;plus a source resistor typically returned to ground.&amp;nbsp; However, to provide the necessary voltage offset in this case, the source resistor will need to be returned to a fixed, &lt;U&gt;negative&lt;/U&gt; reference voltage, equal to one half the positive Vdd value, assuming equal resistor values.&amp;nbsp; Because the non-inverting input will swing negative, the amplifier will need a negative supply voltage.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;For the inverting configuration, the input signal will be applied to the source resistor.&amp;nbsp;and a&amp;nbsp;fixed, &lt;U&gt;positive&lt;/U&gt; reference voltage would be applied to the non-inverting :smileyplus: input.&amp;nbsp; Again, assuming equal value resistors, the reference voltage would be one half the Vdd voltage.&amp;nbsp; For this method, your code will need to allow for the ADC input voltage swing towards zero as the input voltage increases above zero, and vice versa.&amp;nbsp; This method also has the disadvantage of a lower input resistance (the source resistor value) compared with the non-inverting method.&amp;nbsp; However, I prefer this method, where possible, because the reference voltage can be derived directly from Vdd, using a voltage divider.&amp;nbsp; Additionally, the amplifier does not require a negative supply voltage.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;For either method, since the resistor values will have a tolerance (1 percent resistors should be used), the input voltage level may differ slightly from one-half Vdd, when the input voltage is zero.&amp;nbsp; If the offset error can be predetermined, and a correction value stored in non-volatile memory, the firmware can compensate for the error.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2008-01-14&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;11:26 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2008 20:15:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179136#M12813</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-01-14T20:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: ADC-Negative values!!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179137#M12814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;hi,&lt;BR /&gt;&lt;BR /&gt;ahhh, I understand, I need to add a dc level to my analog signal.&lt;BR /&gt;So if I use inverting configuratión,&amp;nbsp; the output is conected to one channel and I don´t need more channels ¿right?&lt;BR /&gt;When the analog&amp;nbsp; signal&amp;nbsp; go&amp;nbsp; to a&amp;nbsp; level under 2.5v (my offset), the adc in CPU give me&amp;nbsp; a negative values or&amp;nbsp; I have to do something with my code&amp;nbsp; to obtain this values ?&lt;BR /&gt;&lt;BR /&gt;regards.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by fredycolombia on &lt;SPAN class="date_text"&gt;2008-01-14&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;08:53 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2008 09:50:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179137#M12814</guid>
      <dc:creator>fredycolombia</dc:creator>
      <dc:date>2008-01-15T09:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: ADC-Negative values!!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179138#M12815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Fredy,&lt;BR /&gt;&lt;BR /&gt;Configured this way, the ADC will give you a reading of 1/2 full scale when your input signal is at 0 (2.5v), the ADC will read 0 for a full scale signal excursion (0v) in the negative range, and will read full scale for a full scale excursion (5v) in the positive direction.&lt;BR /&gt;&lt;BR /&gt;If you want positive and negative numbers you will have to subtract half of the adc full scale reading from all of your input readings.&amp;nbsp; If you are using an inverting amplifier and want the "true" polarity of your input signal, you could then swap the signs with a only little more numerical manipulation.&lt;BR /&gt;&lt;BR /&gt;Good Luck,&lt;BR /&gt;&lt;BR /&gt;Peter&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2008 10:10:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179138#M12815</guid>
      <dc:creator>PeterHouse</dc:creator>
      <dc:date>2008-01-15T10:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: ADC-Negative values!!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179139#M12816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Fredy,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;If using the inverted configuration, and assuming an 8-bit result, the ADC reading would need to be manipulated as follows.&amp;nbsp; I have assumed a fixed offset value, but this could alternatively be a variable, subject to&amp;nbsp;calibration for zero input.&amp;nbsp; The offset value is subtracted from the ones complement of the reading.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp;OFFSET&amp;nbsp; 0x80&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;signed char result;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;result = (~AD1RL) - OFFSET;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The manipulation is slightly more complex if using a 10-bit result, which must be handled as a 16-bit value.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define OFFSET&amp;nbsp; 0x200&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;int result;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;result = (~(AD1R | 0xFC00)) - OFFSET;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2008 11:20:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179139#M12816</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-01-15T11:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: ADC-Negative values!!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179140#M12817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;hi all,&lt;BR /&gt;this is a very useful information for my project with usb, I really be so thankful.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;fredy&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2008 08:27:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/ADC-Negative-values/m-p/179140#M12817</guid>
      <dc:creator>fredycolombia</dc:creator>
      <dc:date>2008-01-17T08:27:42Z</dc:date>
    </item>
  </channel>
</rss>

