<?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: a few questions</title>
		<link>http://forums.leaflabs.com/topic.php?id=1511</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:20:03 +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=1511" rel="self" type="application/rss+xml" />

		<item>
			<title>gbulmer on "a few questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1511#post-10023</link>
			<pubDate>Thu, 29 Mar 2012 10:13:17 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">10023@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@ThomasB - I was planning to publish on my blog, at ourduino.wordpress.com&#60;/p&#62;
&#60;p&#62;I have been too quiet there, and that, and a couple of questions I've answered at other web sites seemed to be useful.&#60;/p&#62;
&#60;p&#62;@EpicZero - Timer is the name of a complete, independent peripheral.  TIM2 is different from TIM5.&#60;br /&#62;
One Timer has one counter, and (TIM2 to TIM5) four channels. Channels do not have timers.&#60;br /&#62;
Use the word 'counter'(or TIme-base unit:-) for the part of the timer which counts, and don't use the word 'timer' for that. Then, I think your post might be clearer (to me).&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;... put a calculation to always happen on a set interval, use PWM on the motors, and use a servo for something else ...&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Okay&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;... all running in perfect timer harmony.&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;What does that mean?&#60;/p&#62;
&#60;p&#62;IMHO, you will want (likley need) the flexibility to adjust:&#60;br /&#62;
1. the 'set interval' (which equates to counter frequency), independently of the other two uses&#60;br /&#62;
2. the counter frequency driving the DC motors, independently of the other two uses&#60;br /&#62;
3. the counter frequency driving the servo, independently of the other two uses&#60;/p&#62;
&#60;p&#62;A Timer has one counter. So that will use at least three Timers.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;... I can't just test this by trial and error on my own ... &#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;The base rule is &#34;plan to throw one away&#34;; maybe put a 'matrix board' area on so it is easy to re-route and patch.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>EpicZero on "a few questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1511#post-10021</link>
			<pubDate>Thu, 29 Mar 2012 09:37:55 +0000</pubDate>
			<dc:creator>EpicZero</dc:creator>
			<guid isPermaLink="false">10021@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;wow! thanks everyone for all the info. absorb++;&#60;/p&#62;
&#60;p&#62;I plan to use an RX/TX pair for an XBee for very basic call/response debug to help me tune my autonomous robot as it races around a track. I'm using the clk pin next to the RX/TX pair for something else on the robot that is non transmission related,and I just didn't want to interfere with my ability to use those particular RX/TX pins for serial. &#60;/p&#62;
&#60;p&#62;As for the motors, thanks a bunch for all the info, I'll make sure I'm on the same timer but different channels for the motors. I plan to change the motor speeds constantly for steering, so I was worried that I might choose 2 incompatible PWM pins where one would interfere with the other and the robot wouldn't steer properly or just not work on one side, etc. The reason I can't just test this by trial and error on my own is I simply won't have time for testing pin selections since I am etching a circuit board on a tight deadline, so I thought I would do as much research as I could on my own and also ask you all and hope and pray and pray some more that I get it right the first time. Whatever pins I choose are going to be etched into a shield for the robot, and I wanted to be sure I wont have to go back and change/patch too many traces afterwards to maximize the time spent tuning and making it faster, especially since i don't have a lot of time.&#60;/p&#62;
&#60;p&#62;I have a very low level idea of how timers and interrupts work, but I wasn't sure how the channels played into it, if they were the separations of the different counts/event triggers on one timer(does that make sense?), or if each channel had 4 different timers, etc.&#60;/p&#62;
&#60;p&#62;so it goes:&#60;br /&#62;
--Timer #-&#124;&#60;br /&#62;
channel 1 &#124;&#60;br /&#62;
channel 2 &#124;&#60;br /&#62;
channel 3 &#124;&#60;br /&#62;
channel 4 &#124;&#60;br /&#62;
----------&#60;/p&#62;
&#60;p&#62;and each channel is a possible event that happens every time the timer hits a particular number, that I can specify, correct? and then the timer overflows later when it hits it's own set particular number, and either goes back down the way it came or starts over at 0. And the scale and clock determine how fast or slow all of this happens. Is this right? &#60;/p&#62;
&#60;p&#62;My ultimate plan (if I have time for it)is to put a calculation to always happen on a set interval, use PWM on the motors, and use a servo for something else, all running in perfect timer harmony. Should I separate them all into 3 different timers?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ThomasB on "a few questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1511#post-10012</link>
			<pubDate>Thu, 29 Mar 2012 00:44:18 +0000</pubDate>
			<dc:creator>ThomasB</dc:creator>
			<guid isPermaLink="false">10012@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@gbulmer&#60;br /&#62;
Very good explanation.&#60;br /&#62;
I'm just busy with a document for some low level uController explanations (just for my hobby website). I would like to 'steal' your last post for it, if allowed&#60;br /&#62;
(will mention your full name if I become aware of it ;)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "a few questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1511#post-9947</link>
			<pubDate>Wed, 28 Mar 2012 18:19:07 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">9947@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@EpicZero - Let me try an explanation. Timers are very flexible, so I will focus on the 'core', and accept that it is only a subset of the picture. So you might need to ask some more questions.&#60;/p&#62;
&#60;p&#62;A timer is the 'whole enchilada' - it is the subject of a chapter in RM008.&#60;br /&#62;
There are several variations, with some extra features, so lets concentrate on the General purpose timers TIM2 to TIM5. The other General purpose timers are variations on those.&#60;/p&#62;
&#60;p&#62;At it's core, a TIM2-TIM5 timer is one counter and four channels. (There is more logic around it, but let's go with this first.)&#60;/p&#62;
&#60;p&#62;The counter is driven to count up, down, or up and down. It is the hardware equivalent of &#60;code&#62;for (uint16 i=0; i&#38;lt;overflow; i++)&#60;/code&#62;&#60;br /&#62;
To make the waveform generated for PWM symmetrical (which is a 'good thing'), the counter counts up, then down, then up, then down, ....&#60;/p&#62;
&#60;p&#62;Each channel can behave as an input or an output. Let's focus on output because that is how PWM signals are created. &#60;/p&#62;
&#60;p&#62;In TIM2 to TIM5, each channel drives one output pin (this actually depends on the integrated circuit package, some packages don't have enough pins, so the designers decided not to connect all channels to the outside world). &#60;/p&#62;
&#60;p&#62;The state of the channel's output pin changes when the channel 'match value' equals the timer's counter value. So a channel is like an &#60;code&#62;if&#60;/code&#62; test, which changes the state of the pin.&#60;/p&#62;
&#60;p&#62;So a timer looks like this (in PWM modes):&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;while (1) {
    for (int counter=0; counter&#38;lt;overflow; ++counter) {
        if (channel1.match == counter) {
            channel1.pin = ! channel1.pin;
        }
        if (channel2.match == counter) {
            channel2.pin = ! channel2.pin;
        }
        if (channel3.match == counter) {
            channel3.pin = ! channel3.pin;
        }
        if (channel4.match == counter) {
            channel4.pin = ! channel4.pin;
        }
    }

    for (int counter=overflow; counter&#38;gt;0; --counter) {
        if (channel1.match == counter) {
            channel1.pin = ! channel1.pin;
        }
        if (channel2.match == counter) {
            channel2.pin = ! channel2.pin;
        }
        if (channel3.match == counter) {
            channel3.pin = ! channel3.pin;
        }
        if (channel4.match == counter) {
            channel4.pin = ! channel4.pin;
        }
    }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The expression &#60;code&#62;channel.pin = ! channel.pin&#60;/code&#62; represents the pin toggling between high, then low, then high, ...&#60;/p&#62;
&#60;p&#62;So a timer is all of that, and more.&#60;/p&#62;
&#60;p&#62;2. It actually doesn't matter if two DC motors are on the same timer. All Maple TIM2-TIM5 timers are initialised to the same frequency, so when you are beginning, it doesn't matter. &#60;/p&#62;
&#60;p&#62;In general DC motors will be on different channels because you'll want to drive them at different speeds (and it is virtually impossible to drive ordinary DC Motors at the same speed from one PWM signal. Manufacturing tolerances are too wide to enable that)&#60;/p&#62;
&#60;p&#62;3. What are you planning to put on the Rx/Tx pins? If it is a UART (e.g. normal asynchronous communication) it doesn't use the CLK pin.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "a few questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1511#post-9946</link>
			<pubDate>Wed, 28 Mar 2012 17:53:42 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">9946@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;1. The channels are actually a vital part of the timers. As timers can count at a certain rate, you can set a channel to create a event based when the counter in the timer reaches a certain value, this is how you create a PWM signal with one of the channels. Or if you wanted to measure a PWM signal, you could set the channel into input capture and have it trigger on the rising or falling edges (or switch between them) to work out the peroid of that PWM signal as well as the duty cycle.&#60;/p&#62;
&#60;p&#62;2. If you want to drive 2 motors always at the same speed, you can use the same channel on the same timer. If you want to maintain the same driving frequency, you can use the same timer but different channels on that timer to drive the 2 motors, this is probably what you're wanting. You can also have 2 seperate timers doing this, but this means that the PWM signals will be out of sync unless you sync them (see the Reference Manual on timers for this).&#60;/p&#62;
&#60;p&#62;3. There is normally a CLK pin that is dedicated for the USARTS (Serial RX/TX Combos) that can be used, I'm not sure how to use it thought. Is the CLK pin actually needed for what you need? I've done USART communications at 1MB before without issues and without the CLK pin.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>EpicZero on "a few questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1511#post-9942</link>
			<pubDate>Wed, 28 Mar 2012 09:58:31 +0000</pubDate>
			<dc:creator>EpicZero</dc:creator>
			<guid isPermaLink="false">9942@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Ok here goes and thank you in advance:&#60;/p&#62;
&#60;p&#62;1. Can someone explain the difference between channels and timers? The timer/interrupt documentation is great but I guess I have a hard time figuring out how channels work and exactly what they are and how/when they are used etc.&#60;/p&#62;
&#60;p&#62;2. If i want to drive 2 motors with PWM, should they be on the same channel or the same timer or what? they are for a differential steering robot. I just want to make sure I choose the correct pins for pwm to my motor driver.&#60;/p&#62;
&#60;p&#62;3. If I PWM output a pin which is the CLK for one of the 3 serial rx/tx combos, will that basically mess up the serial output/input for it's associated rx/tx pins?&#60;/p&#62;
&#60;p&#62;Thanks again
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
