{"action":"created","issue":{"url":"https://api.github.com/repos/arduino/Arduino/issues/1634","repository_url":"https://api.github.com/repos/arduino/Arduino","labels_url":"https://api.github.com/repos/arduino/Arduino/issues/1634/labels{/name}","comments_url":"https://api.github.com/repos/arduino/Arduino/issues/1634/comments","events_url":"https://api.github.com/repos/arduino/Arduino/issues/1634/events","html_url":"https://github.com/arduino/Arduino/pull/1634","id":21307420,"number":1634,"title":"Improved ADC speed on Arduino Due","user":{"login":"cmaglie","id":423515,"avatar_url":"https://avatars.githubusercontent.com/u/423515?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaglie","html_url":"https://github.com/cmaglie","followers_url":"https://api.github.com/users/cmaglie/followers","following_url":"https://api.github.com/users/cmaglie/following{/other_user}","gists_url":"https://api.github.com/users/cmaglie/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaglie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaglie/subscriptions","organizations_url":"https://api.github.com/users/cmaglie/orgs","repos_url":"https://api.github.com/users/cmaglie/repos","events_url":"https://api.github.com/users/cmaglie/events{/privacy}","received_events_url":"https://api.github.com/users/cmaglie/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"cmaglie","id":423515,"avatar_url":"https://avatars.githubusercontent.com/u/423515?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaglie","html_url":"https://github.com/cmaglie","followers_url":"https://api.github.com/users/cmaglie/followers","following_url":"https://api.github.com/users/cmaglie/following{/other_user}","gists_url":"https://api.github.com/users/cmaglie/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaglie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaglie/subscriptions","organizations_url":"https://api.github.com/users/cmaglie/orgs","repos_url":"https://api.github.com/users/cmaglie/repos","events_url":"https://api.github.com/users/cmaglie/events{/privacy}","received_events_url":"https://api.github.com/users/cmaglie/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/arduino/Arduino/milestones/7","html_url":"https://github.com/arduino/Arduino/milestones/Release%201.5.5","labels_url":"https://api.github.com/repos/arduino/Arduino/milestones/7/labels","id":423073,"number":7,"title":"Release 1.5.5","description":"","creator":{"login":"cmaglie","id":423515,"avatar_url":"https://avatars.githubusercontent.com/u/423515?v=3","gravatar_id":"","url":"https://api.github.com/users/cmaglie","html_url":"https://github.com/cmaglie","followers_url":"https://api.github.com/users/cmaglie/followers","following_url":"https://api.github.com/users/cmaglie/following{/other_user}","gists_url":"https://api.github.com/users/cmaglie/gists{/gist_id}","starred_url":"https://api.github.com/users/cmaglie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmaglie/subscriptions","organizations_url":"https://api.github.com/users/cmaglie/orgs","repos_url":"https://api.github.com/users/cmaglie/repos","events_url":"https://api.github.com/users/cmaglie/events{/privacy}","received_events_url":"https://api.github.com/users/cmaglie/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":25,"state":"closed","created_at":"2013-09-09T17:06:05Z","updated_at":"2013-12-04T07:58:36Z","due_on":null,"closed_at":"2013-12-04T07:58:36Z"},"comments":27,"created_at":"2013-10-21T10:43:56Z","updated_at":"2016-02-25T10:26:33Z","closed_at":"2013-11-12T08:57:28Z","pull_request":{"url":"https://api.github.com/repos/arduino/Arduino/pulls/1634","html_url":"https://github.com/arduino/Arduino/pull/1634","diff_url":"https://github.com/arduino/Arduino/pull/1634.diff","patch_url":"https://github.com/arduino/Arduino/pull/1634.patch"},"body":"Proposal to improve ADC reading speed: keep the ADC enabled after every ADC conversion. \r\n\r\nThis will bypass ADC startup time, improving its conversion rate at the cost of slightly increasing power consumption (less than ~~1mA~~ 5mA).\r\n\r\nSee #1418 for more discussion.\r\n"},"comment":{"url":"https://api.github.com/repos/arduino/Arduino/issues/comments/188710428","html_url":"https://github.com/arduino/Arduino/pull/1634#issuecomment-188710428","issue_url":"https://api.github.com/repos/arduino/Arduino/issues/1634","id":188710428,"user":{"login":"dc42","id":2720876,"avatar_url":"https://avatars.githubusercontent.com/u/2720876?v=3","gravatar_id":"","url":"https://api.github.com/users/dc42","html_url":"https://github.com/dc42","followers_url":"https://api.github.com/users/dc42/followers","following_url":"https://api.github.com/users/dc42/following{/other_user}","gists_url":"https://api.github.com/users/dc42/gists{/gist_id}","starred_url":"https://api.github.com/users/dc42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dc42/subscriptions","organizations_url":"https://api.github.com/users/dc42/orgs","repos_url":"https://api.github.com/users/dc42/repos","events_url":"https://api.github.com/users/dc42/events{/privacy}","received_events_url":"https://api.github.com/users/dc42/received_events","type":"User","site_admin":false},"created_at":"2016-02-25T10:26:33Z","updated_at":"2016-02-25T10:26:33Z","body":"Adding capacitance on high impedance inputs actually helps, because it provides a reservoir from which the S/H capacitor can be charged. Let's take the worst case, which is a voltage we want to sample fed through a resistor to an input and no additional capacitance connected to that input. The S/H capacitor inside the ADC is connected to another input at a different voltage, then we switch it over to \"our\" input. We need to wait for it charge or discharge through the resistor, until the voltage on the capacitor is close enough to the input voltage on the other side of the resistor to provide an accurate reading when we start the conversion.\r\n\r\nIt's fairly obvious that the worst case will be when our input is at ADVREF and the previous input is at ground potential, or vice versa. To get an accurate reading, we want the failure of the S/H capacitor to fully charge or discharge to introduce an error of no more than 0.5LSB under these conditions. So for an AVR with a 10-bit ADC, the problem reduces to having a delay long enough that the S/H capacitor C charges from zero up to a voltage that is at least 2047/2048 times the input voltage.\r\n\r\nThe voltage on a capacitor charging from zero through a resistor connected to a constant voltage source is given by the equation V = Vo ( (1 - exp(-t/RC)). Setting V = 2047/2048 * Vo, we get  exp(-t/RC) = 1/2048. Rearranging this gives t = RC ln(2048), so t = RC * 7.62.\r\n\r\nLet's plug the numbers in, assuming C = 14pF as on the datasheet:\r\n\r\nR = 10K -> t = 1.06us\r\nR = 100K -> t = 10.6us\r\nR = 1M -> t = 106us\r\n\r\nThis is the first time I have done this calculation, however the result for R=100K has turned out to be exactly what I determined empirically, which is that a 10us delay is sufficient to get accurate results with 100K source resistance. If we want to allow for manufacturing tolerances in the value of the S/H capacitor, it may be prudent to increase this delay by about 50%.\r\n\r\nNote that at R=1M the ADC accuracy will be degraded, because the datasheet specifies the input resistance of the ADC as being about 100M. But not every application needs 10 bits of accuracy.  The 1us delay needed when R=10K is provided by the ADC itself, because the ADC does the sample and hold 1.5 ADC clocks after it sees the start conversion command."}}