<?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: Analog High Speed reading with quadrature encoding</title>
		<link>http://forums.leaflabs.com/topic.php?id=783</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:17:53 +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=783" rel="self" type="application/rss+xml" />

		<item>
			<title>newyorkbrass on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4785</link>
			<pubDate>Wed, 25 May 2011 09:36:54 +0000</pubDate>
			<dc:creator>newyorkbrass</dc:creator>
			<guid isPermaLink="false">4785@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I am going to post there. I would like to really see example of integrating the native standard firmware lib with the libmaple. like adding the directories, libraries, linking. a full end-to-end example. i suspect such an example would reduce many of the questions on this forum.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4782</link>
			<pubDate>Wed, 25 May 2011 03:42:54 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">4782@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;newyorkbrass,&#60;/p&#62;
&#60;p&#62;are you talking about the ST standard firmware library?  it should mostly work (although no guarantees), especially if you're just messing with a peripheral that has scanty libmaple support, instead of, say, redoing the clock configuration.&#60;/p&#62;
&#60;p&#62;if there's something in particular you'd like to see support for in libmaple, you may want to add it to the (new) missing features page on the wiki:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://wiki.leaflabs.com/index.php?title=Missing_Features&#34; rel=&#34;nofollow&#34;&#62;http://wiki.leaflabs.com/index.php?title=Missing_Features&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>newyorkbrass on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4777</link>
			<pubDate>Tue, 24 May 2011 22:49:19 +0000</pubDate>
			<dc:creator>newyorkbrass</dc:creator>
			<guid isPermaLink="false">4777@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Is the STM code compatible with the maple? Is there a documentation on how it differs? Is there a way to integrate the code? i.e. if I write to the registers - will i get unexpected results? What registers &#60;strong&#62;can't&#60;/strong&#62; I touch?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4745</link>
			<pubDate>Mon, 23 May 2011 20:19:29 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">4745@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;josiah47 -&#60;br /&#62;
&#60;blockquote&#62;I am having a feeling that you think im building a balancing robot... I mean a balancing machine for balancing tools, like a wheel balancer for you car but a little more advanced.&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Doh! You are right, I did misunderstand. Sorry&#60;br /&#62;
Your post makes much more sense to me now :-)&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;So I guess I can keep track of the encoder with the digital inputs&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Yes.&#60;br /&#62;
If you set the timers into the right mode and feed the signal into timer channels (takes a bit of work reading the STM32F RM0008 manual) then the timer will do some of the work for you.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;If the maple is fast enough I will just upgrade the ambient lights with IR so I don't have to touch the hardware of the current machine and I can do some testing while it still operates on the old stuff.&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Yes. that should reduce the noise from ambient light.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josiah47 on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4739</link>
			<pubDate>Mon, 23 May 2011 16:47:42 +0000</pubDate>
			<dc:creator>josiah47</dc:creator>
			<guid isPermaLink="false">4739@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I am having a feeling that you think im building a balancing robot... I mean a balancing machine for balancing tools, like a wheel balancer for you car but a little more advanced. &#60;/p&#62;
&#60;p&#62;So I guess I can keep track of the encoder with the digital inputs and if there is 2 adc chips, allow one channel per chip to speed/precise things up more.&#60;/p&#62;
&#60;p&#62;If the maple is fast enough I will just upgrade the ambient lights with IR so I don't have to touch the hardware of the current machine and I can do some testing while it still operates on the old stuff.&#60;/p&#62;
&#60;p&#62;So then I would have to keep track of the degrees on one digital input and the index on another and read 2 analogs, no need to have a B channel for direction, well at least in this point in time, I will use it for real time rotary feed back to tell operator where to take material off.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4737</link>
			<pubDate>Mon, 23 May 2011 16:08:16 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">4737@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;josiah47 -&#60;br /&#62;
&#60;blockquote&#62;There are two ambient light from the 1980s with two receivers.&#60;br /&#62;
one light and receiver fro degrees and the other pair for the index&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;That is pretty much what these have:&#60;br /&#62;
&#60;a href=&#34;http://www.philohome.com/nxtway/nxtway.htm&#34; rel=&#34;nofollow&#34;&#62;http://www.philohome.com/nxtway/nxtway.htm&#60;/a&#62;&#60;br /&#62;
Inside the lego NXT motors is an optical encoder wheel and two optical sensors to generate a quadrature signal. It generates about 720 pulses, but it when I was experimenting with them, the NXT 'brick' didn't use the full quadrature signal resolution, it only used half the pulses, I think (the firmware may be smarter now, but it wasn't in 2007)&#60;/p&#62;
&#60;p&#62;Maple is faster than the processor in the Lego NXT.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;I think if the usb will slow things down i'll just do the processing OB and then send over the data when test is done.&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;I'd be very tempted to do that too.&#60;/p&#62;
&#60;p&#62;It could probably run at about 1KHz control loop.&#60;br /&#62;
At 1KHz, an object would only free fall 0.01mm during the cycle (less than a human hair). So that is probably fast enough.&#60;/p&#62;
&#60;p&#62;If all the work is done, and then the data is sent over USB in a single print/write it may work fine (instead of doing lots of prints, use sprintf to build one string and print that entire string up the USB in one print/write step).
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josiah47 on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4731</link>
			<pubDate>Mon, 23 May 2011 15:21:41 +0000</pubDate>
			<dc:creator>josiah47</dc:creator>
			<guid isPermaLink="false">4731@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;There are two ambient light from the 1980s with two receivers.&#60;br /&#62;
one light and receiver  fro degrees and the other pair for the index&#60;/p&#62;
&#60;p&#62;there is a disc with holes in it for the light to pass through it, very old tech. this needs updating to a rotary encoder.&#60;/p&#62;
&#60;p&#62;I think if the usb will slow things down i'll just do the processing OB and then send over the data when test is done.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4725</link>
			<pubDate>Mon, 23 May 2011 14:48:20 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">4725@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I re-read your post. I think you say the current system uses '... lights and light sensors to detect angle ...'.&#60;br /&#62;
What light sensors are you using? Are you removing ambient light by measuring the light sensor value with the light on and off?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4721</link>
			<pubDate>Mon, 23 May 2011 13:45:14 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">4721@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;josiah47 -&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;the speed is about 1250rpm max, so the would be about 7500 adc reads per second, 360 x 1250 / 60 seconds. I would get so many sample ex. 5 x 360, verify each sample if needed, and then return that data back to the PC to display the results, I don't know if it could do this real time?&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;The STM32F is capable of a maximum of 1 million samples/ADC (and it has two ADC's, so theoretically twice that). BUT the normal libmaple analogRead deliberately throttles the ADC back to about 150K samples/second.&#60;/p&#62;
&#60;p&#62;The reason it is so much slower than the theoretical maximum is little to do with the rate at which it can convert the analogue value. The issue is the time it takes to sample and hold the analogue input voltage. If you are using a piece of electronics with a relatively high output impedance, that means that it would take a long time (relatively) to charge up the sample and hold electronics inside the Maple's STM32F103. So libmaple takes the safe approach of allowing a reasonable amount of time (about 6uSecs) to sample the signal. Hence you don't need to have a very deep understanding of electronics in order to get reasonable results 'out of the packet'. Trying to sample at 1million samples/second, without sorting out the electrical impedance will make things much worse (I'll skip that for now).&#60;/p&#62;
&#60;p&#62;7500 samples/second is so slow that this isn't a problem for Maple (it can go 20x faster than that 'out of the packet'). It is so far within the capability of Maple, that IMHO trying to use DMA is probably pointless complexity. As you say, take a few samples, and do a bit of 'box-car integration' or filtering to reduce the noise. KISS.&#60;/p&#62;
&#60;p&#62;I think all the processing and control can be done on Maple.&#60;br /&#62;
As evidence, here is a balancing robot built with an Arduino: &#60;a href=&#34;http://hacknmod.com/hack/make-a-mini-segway-using-the-arduino/&#34; rel=&#34;nofollow&#34;&#62;http://hacknmod.com/hack/make-a-mini-segway-using-the-arduino/&#60;/a&#62;&#60;br /&#62;
An Arduino can do less than 10,000 samples/second, about 15x slower than a Maple with standard libmaple.&#60;/p&#62;
&#60;p&#62;To put this in context, something in free fall will travel, from rest about 2.2x10^-10 metres in the time it takes to do an analogRead on a Maple.&#60;/p&#62;
&#60;p&#62;This &#60;a href=&#34;http://hypertextbook.com/facts/1999/BrianLey.shtml&#34; rel=&#34;nofollow&#34;&#62;http://hypertextbook.com/facts/1999/BrianLey.shtml&#60;/a&#62;&#60;br /&#62;
says a human hair has a diameter in the range 17 to 181x10^-6 metres&#60;br /&#62;
so an object would move, about 10^-5 of the diameter of a fine human hair in the time it takes Maple to do an analogRead (and this is a much worse case than balancing, where a component of gravity is 'absorbed' by the lever), so the rate of sampling is not the issue.&#60;/p&#62;
&#60;p&#62;The issue is the bandwidth of the sensor system, and the amount of noise in it.&#60;br /&#62;
&#60;a href=&#34;http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1221664564/15&#34; rel=&#34;nofollow&#34;&#62;http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1221664564/15&#60;/a&#62;&#60;br /&#62;
talks about that Arduino example, and it samples at 250Hz. Sampling a signal at a much higher rate than its bandwidth isn't going to improve the signal, though it might let you remove noise.&#60;/p&#62;
&#60;p&#62;The hardest part might be pumping the data up the wire to a host PC over USB. USB is only polled by the host, at best, every millisecond, so you might find USB much more of a disruption to the program than all the analogRead and calculations.&#60;/p&#62;
&#60;p&#62;(full disclosure: I am not a member of LeafLabs staff)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4719</link>
			<pubDate>Mon, 23 May 2011 10:53:24 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">4719@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The datasheet for the Maple's STM32F103RB claim a 1uS sample rate, which is at most 1MHz -- or 1 million samples per second. That aught to be more than enough for your needs. Some other things to look into are the DMA controllers available on the STM32. You can configure DMA to sample the ADC and dump samples directly into SRAM. The DMA controller can also trigger an interrupt to tell you the conversion is done, which would be perfect for you. Do a bunch of samples, without wasting CPU, then once all samples are complete process them. The STM32's 72MHz ARM Cortex-M3 core will have no problem crunching those bits for you.&#60;/p&#62;
&#60;p&#62;For more information on the DMA controller, I recommend  taking a look at ST's &#60;a href=&#34;http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/APPLICATION_NOTE/CD00160362.pdf&#34;&#62;AN2548: Using the STM32F101xx and STM32F103xx DMA controller&#60;/a&#62; along with the &#60;a href=&#34;http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/an2548.zip&#34;&#62;examples&#60;/a&#62;. The examples are written for ST's standard peripheral library, which isn't supported by the Maple or Libmaple, but it will give you an idea of what needs to be done to get this working. Libmaple itself does support the ADC/DMA functionality, so the implementation isn't too difficult. Libmaple has an &#60;a href=&#34;https://github.com/leaflabs/libmaple/blob/master/examples/test-usart-dma.cpp&#34;&#62;example&#60;/a&#62; of using the DMA with USART which may also be worth taking a look at. In either case, ST does a great job in their reference manual of describing the registers and their functionality.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>josiah47 on "Analog High Speed reading with quadrature encoding"</title>
			<link>http://forums.leaflabs.com/topic.php?id=783#post-4718</link>
			<pubDate>Mon, 23 May 2011 10:14:37 +0000</pubDate>
			<dc:creator>josiah47</dc:creator>
			<guid isPermaLink="false">4718@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello all,&#60;br /&#62;
I am starting a project for a balancing machine for my friend, right now it is running on a 286, with out an encoder but a made up one with lights and light sensors to detect angle and index, also reads 2 analog channels for vibration and matches that up with the angle. I was wondering if you think the Maple is capable of running a program on it to read angle and match that up with the current reading of 2 analog channels so I get data like this:&#60;/p&#62;
&#60;p&#62;Angle    Channel 1    Channel 2&#60;br /&#62;
1            245                356&#60;br /&#62;
2            743                463&#60;br /&#62;
3            342                633&#60;br /&#62;
4            367                367&#60;br /&#62;
5            357                564&#60;br /&#62;
6            244                354&#60;br /&#62;
7            235                245 &#60;/p&#62;
&#60;p&#62;the speed is about 1250rpm max, so the would be about 7500 adc reads per second, 360 x 1250 / 60 seconds. I would get so many sample ex. 5 x 360, verify each sample if needed, and then return that data back to the PC to display the results, I don't know if it could do this real time? Any tips or what direction to start in would be greatly appreciated.&#60;/p&#62;
&#60;p&#62;Thanks
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
