<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: ADC speed and input impedance</title>
		<link>http://forums.leaflabs.com/topic.php?id=12092</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:17:35 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=12092" rel="self" type="application/rss+xml" />

		<item>
			<title>pyrohaz on "ADC speed and input impedance"</title>
			<link>http://forums.leaflabs.com/topic.php?id=12092#post-26852</link>
			<pubDate>Sun, 16 Jun 2013 15:10:53 +0000</pubDate>
			<dc:creator>pyrohaz</dc:creator>
			<guid isPermaLink="false">26852@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Ah yes, I see! Considering that my loop completes in a few ms, Would the fastest way to do it be set address at 0 (the values 0 to 7), increment this every time the loop executes, write the address and set conversion, once the loop has gone round, read the converted value, store then increment the address and do the process again?&#60;/p&#62;
&#60;p&#62;I see what you mean about using DMA with the external addressing, that might be a bit annoying to do, i've not even delved into the world of DMA yet!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "ADC speed and input impedance"</title>
			<link>http://forums.leaflabs.com/topic.php?id=12092#post-26753</link>
			<pubDate>Sat, 15 Jun 2013 04:24:14 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">26753@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;pyrohaz - &#60;em&#62;&#34;...  I would consider using the adc interrupts but that may interrupt my main interrupt (and my main interrupt takes priority).&#34;&#60;/em&#62;&#60;/p&#62;
&#60;p&#62;If they are ordinary mechanical pots, then you can likely be a bit 'sloppy' with reading their values, i.e.  a millisecond or two either way isn't going to make much difference, is it? So running the ADC 'conversion completed' interrupt at a lower priority is likely okay. Though, you might also be able to break 'analogRead' into two parts, one to start the conversion, and the other to retrieve the result, and call it in your main loop. This would remove the need for an interrupt.&#60;/p&#62;
&#60;p&#62;Hacking the code should be doable. The actual work is something like:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;uint32 analogRead(uint8 pin) {
    if (pin &#38;gt;= NR_ANALOG_PINS)
        return 0;

    return adc_read(PIN_MAP[pin].adc);
}

static inline int adc_read(int channel) {
    /* Set channel  */
    ADC_SQR3 = channel;

    /* Start the conversion  */
    CR2_SWSTART_BIT = 1;

    /* Wait for it to finish  */
    while(SR_EOC_BIT == 0)
        ;

    return ADC_DR;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;So spilt this into two functions, one to start the conversion on a pin, and the other to wait for and retrieve the value (&#60;code&#62;while(SR_EOC_BIT == 0)&#60;/code&#62;), and you can let the ADC sample as long as it needs, and read the value when its convenient.&#60;/p&#62;
&#60;p&#62;&#60;em&#62;&#34;Could DMA be used to sample the pots and store their 12bit value directly in an array/variable?&#34;&#60;/em&#62;&#60;br /&#62;
Yes. &#60;/p&#62;
&#60;p&#62;The simplest setup might be to start the conversion as normal, and let DMA store the converted value. I'm not sure how much processing time that would save, but I suspect that once DMA is configured correctly, it might be pretty efficient. &#60;/p&#62;
&#60;p&#62;If the Maple-mini's own ADC pins were used, then sampling 8 signals would be relatively straightforward (though still some deep peripheral code hacking). Each ADC has 'scan modes' which can scan a set of pins, and store the values in memory using DMA. Without scan mode, DMA alone would store the value for the &#60;em&#62;same pin&#60;/em&#62; into memory.&#60;/p&#62;
&#60;p&#62;However, for your circuit, with an external multiplexer, doing an ADC conversion for all the 'multiplexer channels' using only DMA would be a bit more complex. The MCU will need to send set the 'multiplexer channel number' on some digital output (GPIO) pins too. So as wel as using ADC 'scan mode' and DMA, there would need to be a second DMA channel set up to push the 'multiplexer channel number' to the GPIO output pins. Doable, but it might be unpleasant to debug.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pyrohaz on "ADC speed and input impedance"</title>
			<link>http://forums.leaflabs.com/topic.php?id=12092#post-26751</link>
			<pubDate>Sat, 15 Jun 2013 02:51:11 +0000</pubDate>
			<dc:creator>pyrohaz</dc:creator>
			<guid isPermaLink="false">26751@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks for the reply! I agree with the unnecessary oversampling of pots, my only reason being that I don't want to lock up the rest of my code waiting for adc samples to come in (i say lock up but reading a 8 analog ins with address changes takes a few us!) I would consider using the adc interrupts but that may interrupt my main interrupt (and my main interrupt takes priority).&#60;/p&#62;
&#60;p&#62;Could DMA be used to sample the pots and store their 12bit value directly in an array/variable? I'll have a look at table 47 now, thanks!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "ADC speed and input impedance"</title>
			<link>http://forums.leaflabs.com/topic.php?id=12092#post-26746</link>
			<pubDate>Fri, 14 Jun 2013 20:46:09 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">26746@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;pyrohaz - &#60;em&#62;&#34;I'm using the 4051 multiplexer to connect 8 pots to my maple mini.&#34;&#60;/em&#62;&#60;/p&#62;
&#60;p&#62;I assume the other ADC inputs are used for some other purpose?&#60;/p&#62;
&#60;p&#62;However, to cover another approach ...&#60;br /&#62;
The Maple Mini's STM32F103 has two independent ADCs. If speed is important, you might want to consider using both of them. libmaple does &#60;strong&#62;not&#60;/strong&#62; support the second ADC, so you'd need to do some low-level hacking on the library. That might stop the suggestion from being relevant.&#60;/p&#62;
&#60;p&#62;If using both ADCs is relevant, you might want to use two analogue multiplexer chips (or a 4052), into two ADC inputs. Then the option of using both ADcs would be available. &#60;/p&#62;
&#60;p&#62;More usefully, if you could arrange it by sampling and converting through alternate ADCs, each ADC would have a much longer sample time. Looking at Table 47 &#34;RAIN max for fADC = 14 MHz&#34; in the STM32F103xB datasheet, the sample time could be about 14 ADC cycles using two ADC's, and 14 cycles corresponds to an ADC Rain of 11.4K, which could remove the need for an op amp buffer.&#60;/p&#62;
&#60;p&#62;&#60;em&#62;&#34;...  Would it be worth putting an op amp buffer between my 4051 and the maple so I can go for the 1.5 adc clock?&#34;&#60;/em&#62;&#60;/p&#62;
&#60;p&#62;If you are really trying to go that fast, then Yes, it'll need the buffer.&#60;br /&#62;
But why are you trying to sample pots that fast? If they are mechanical pots, then it seems about 1000x faster than I'd imagine would be usable; when a typical pot moves the signal contains a lot of noise.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pyrohaz on "ADC speed and input impedance"</title>
			<link>http://forums.leaflabs.com/topic.php?id=12092#post-26745</link>
			<pubDate>Fri, 14 Jun 2013 20:19:41 +0000</pubDate>
			<dc:creator>pyrohaz</dc:creator>
			<guid isPermaLink="false">26745@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I meant propagation speed in the above post, not propagation time!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pyrohaz on "ADC speed and input impedance"</title>
			<link>http://forums.leaflabs.com/topic.php?id=12092#post-26737</link>
			<pubDate>Fri, 14 Jun 2013 10:14:16 +0000</pubDate>
			<dc:creator>pyrohaz</dc:creator>
			<guid isPermaLink="false">26737@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hey,&#60;/p&#62;
&#60;p&#62;I'm using the 4051 multiplexer to connect 8 pots to my maple mini. I want to be able to read these as fast as possible. Propagation time for the chip is 1MHz from address to output, I won't need to go THAT fast fortunately.&#60;/p&#62;
&#60;p&#62;The main thing i'm wondering about is the impedance? Each of my pots will be 10k so worst case scenario will be 10k input impedance I assume? Accuracy isn't a major problem. Would it be worth putting an op amp buffer between my 4051 and the maple so I can go for the 1.5 adc clock?&#60;/p&#62;
&#60;p&#62;Cheers,&#60;br /&#62;
Harris
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
