<?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: Driving servo using maple</title>
		<link>http://forums.leaflabs.com/topic.php?id=147</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:12:18 +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=147" rel="self" type="application/rss+xml" />

		<item>
			<title>poslathian on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147&amp;page=2#post-1395</link>
			<pubDate>Thu, 23 Sep 2010 15:12:43 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1395@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;OHHH.... I was wondering what open drain pwm was for. Good idea.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147&amp;page=2#post-1382</link>
			<pubDate>Wed, 22 Sep 2010 12:35:24 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1382@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Ooops - I should add, I am driving servos, and PWM into a motor drive IC (L293D). so I'm going to use open drain for both, on alternative pin-mappings (just to add some extra fun).
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147&amp;page=2#post-1381</link>
			<pubDate>Wed, 22 Sep 2010 03:51:20 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1381@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;perry &#38;amp; crenn - Thank you very much for checking this. You're very helpful. That's saved me futzing around for a day or two.&#60;/p&#62;
&#60;p&#62;You have saved tomorrow (that &#60;em&#62;almost&#60;/em&#62; sounds poetic or profound, or a James Bond sequel :-)&#60;/p&#62;
&#60;p&#62;The RM0008 manual about GPIO pins is a bit hard going, but clamping to Vdd + diode drop is what I read from Figure 14 on page 147. The value of Vdd+0.3V is defined in the STM32F103x8/xB datasheet (13587.pdf at st.com) in &#34;5.2 Absolute maximum ratings&#34; Table 6. Elsewhere I think a datasheet or manual says 4 or 5mA maximum current for the protection diode, so I was planning on 1K current limiting.&#60;/p&#62;
&#60;p&#62;I am using 5V tolerant pins.&#60;br /&#62;
I don't know which servos will end up being used, so I chose to use 5V tolerant pins. It seemed safer to pull-up to 5V rather than hope a servo works reliably at 3.3V.&#60;/p&#62;
&#60;p&#62;Thanks again.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>perry on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147&amp;page=2#post-1372</link>
			<pubDate>Tue, 21 Sep 2010 19:27:41 +0000</pubDate>
			<dc:creator>perry</dc:creator>
			<guid isPermaLink="false">1372@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;hey guys,&#60;/p&#62;
&#60;p&#62;I tested the patch on a PWM output on open drain pulled up to 5V and it seems to work fine. I'd advise using a 5V tolerant pin; using a non 5v pin seemed to make the stm32 clamp the current and only pulled it up to about 3.6v using a 470ohm resistor i had lying around.&#60;/p&#62;
&#60;p&#62;patch applied:&#60;br /&#62;
&#60;a href=&#34;http://github.com/leaflabs/libmaple/commit/943006daefeca420749768a4d4e9810a258f2b92&#34; rel=&#34;nofollow&#34;&#62;http://github.com/leaflabs/libmaple/commit/943006daefeca420749768a4d4e9810a258f2b92&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-1367</link>
			<pubDate>Tue, 21 Sep 2010 06:39:22 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">1367@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;This is the code I wrote when testing the Maple with a servo:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.crennsmind.com/Code/Maple/Servo/Servo_Control.txt&#34; rel=&#34;nofollow&#34;&#62;http://www.crennsmind.com/Code/Maple/Servo/Servo_Control.txt&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I used a 5V tolerant pin just in case I got feedback from the servo (even though it's highly unlikely, if at all possible) but I don't think that's an issue. The servo didn't make a fuss about the 3.3v signal (used Vin from the Maple to power the Servo since it had no load on the servo) and seemed to work well. The upper and lower limits were calculated with the known period and range of the timer's counter. I'll attempt to port the servo library over in the next few days (after I get back from my trip) but the above code should get you started.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-1355</link>
			<pubDate>Mon, 20 Sep 2010 13:58:12 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1355@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Please post if you get some clarity on this. I am going to start pocking at it too later in the week, and I'd hate to just reproduce your results, but a week later :-)&#60;/p&#62;
&#60;p&#62;Clive1 and I exchanged another round of posts over at ST.com. He hadn't tried &#60;em&#62;exactly&#60;/em&#62; the permutation of behaviour, but seemed pretty comfortable that their is a good chance it should work.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-1353</link>
			<pubDate>Mon, 20 Sep 2010 13:19:45 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1353@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;iPerry, I will have to try this. From digging in to the docs more closely, it would appear that AF OpenDrain is unique to I2C, the timers offer no such feature. Which is annoying, considering the circuit that drives the pin either PP or OD is downstream from the alternate function input. &#60;/p&#62;
&#60;p&#62;This may be a docs bug, will try your code.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>perry on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-1342</link>
			<pubDate>Sun, 19 Sep 2010 16:05:48 +0000</pubDate>
			<dc:creator>perry</dc:creator>
			<guid isPermaLink="false">1342@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi guys,&#60;/p&#62;
&#60;p&#62;There is an alternate function open drain mode--it's in the library but I accidentally left it out as an option in the wirish interface. I don't have a maple with me to test it at the moment but if somebody can apply the following patch and test it, I'll commit it into libmaple.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;perry@mescaline ~/work/libmaple $ (master) git diff
diff --git a/wirish/io.h b/wirish/io.h
index e779604..4aa1eef 100644
--- a/wirish/io.h
+++ b/wirish/io.h
@@ -47,7 +47,8 @@ typedef enum WiringPinMode {
     INPUT_PULLUP,
     INPUT_PULLDOWN,
     INPUT_FLOATING,
-    PWM
+    PWM,
+    PWM_OPEN_DRAIN,
 } WiringPinMode;

diff --git a/wirish/wirish_digital.c b/wirish/wirish_digital.c
index c93c786..9dd46ed 100644
--- a/wirish/wirish_digital.c
+++ b/wirish/wirish_digital.c
@@ -58,6 +58,9 @@ void pinMode(uint8 pin, WiringPinMode mode) {
     case PWM:
         outputMode = GPIO_MODE_AF_OUTPUT_PP;
         break;
+    case PWM_OPEN_DRAIN:
+        outputMode = GPIO_MODE_AF_OUTPUT_OD;
+        break;
     default:
         ASSERT(0);
         return;&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-1320</link>
			<pubDate>Sat, 18 Sep 2010 07:07:09 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1320@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I finally got round to asking about Open Drain outputs on PWM.&#60;br /&#62;
One answer was posted by Clive1:&#60;br /&#62;
( &#60;a href=&#34;https://my.st.com/public/STe2ecommunities/mcu/Lists/ARM%20CortexM3%20STM32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fARM%20CortexM3%20STM32%2fCan%20TIM3%20PWM%20outputs%20be%20set%20to%20Open%20Drain&#38;amp;FolderCTID=0x01200200770978C69A1141439FE559EB459D758000626BE2B829C32145B9EB5739142DC17E&#38;amp;TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FARM%20CortexM3%20STM32%2FAllItems%2Easpx&#38;amp;currentviews=41&#34; rel=&#34;nofollow&#34;&#62;https://my.st.com/public/STe2ecommunities/mcu/Lists/ARM%20CortexM3%20STM32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fARM%20CortexM3%20STM32%2fCan%20TIM3%20PWM%20outputs%20be%20set%20to%20Open%20Drain&#38;amp;FolderCTID=0x01200200770978C69A1141439FE559EB459D758000626BE2B829C32145B9EB5739142DC17E&#38;amp;TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FARM%20CortexM3%20STM32%2FAllItems%2Easpx&#38;amp;currentviews=41&#60;/a&#62; )&#60;/p&#62;
&#60;p&#62;&#34;Wouldn't you just program the GPIO pins into the Alternate Function, Open Drain mode? instead of the normal Push-Pull (GPIO_Mode_AF_PP)&#60;/p&#62;
&#60;p&#62;  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 &#124; GPIO_Pin_7;&#60;br /&#62;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;&#60;br /&#62;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;&#60;br /&#62;
  GPIO_Init(GPIOC, &#38;amp;GPIO_InitStructure);&#60;/p&#62;
&#60;p&#62;Presumably you've checked the pins are in the 5V tolerant group?&#34;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-967</link>
			<pubDate>Thu, 02 Sep 2010 22:53:50 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">967@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;bnewbold - much better conservative and correct than misleading !-)&#60;/p&#62;
&#60;p&#62;I find the GPIO part of RM0008 a bit of a slog to read, but I vaguely remember it talking about two 'default' and alternative output drive structures. I'll try to look this weekend, but maybe the open drain interacts with something in the alternative pin drive configuration?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bnewbold on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-962</link>
			<pubDate>Thu, 02 Sep 2010 16:52:33 +0000</pubDate>
			<dc:creator>bnewbold</dc:creator>
			<guid isPermaLink="false">962@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;What I tried was removing anything that looked like it was setting the pin mode from pwm.c and then called setPinMode(OUTPUT_OPEN_DRAIN) before or after calling pwmWrite() and testing for a waveform with a pull up connected. I also looked in the reference manual and found no mention (possible or not possible) on alternative pin modes in the PWM configuration section. It may very well be possible but I don't know how to do it so I edited the docs conservatively.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-945</link>
			<pubDate>Wed, 01 Sep 2010 16:52:22 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">945@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Okay. I should have some time towards the end of this month to do some experiments, and it is important enough that I may try before then. &#60;/p&#62;
&#60;p&#62;Reading the GPIO section, there is an awful lot of stuff to get right, and in the right order. It may be that it does work, but mortals (i.e. everyone that didn't design the chip) can't figure out how. &#60;/p&#62;
&#60;p&#62;I think I'll go to the ST forums and ask.&#60;br /&#62;
CarlO and poslathian, thanks for the &#34;heads-up&#34;, it is important to me to bottom this out.&#60;br /&#62;
(exits muttering &#34;... 20+ servo robot, ... pull-ups, ... rule world ... :-)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CarlO on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-943</link>
			<pubDate>Wed, 01 Sep 2010 16:34:11 +0000</pubDate>
			<dc:creator>CarlO</dc:creator>
			<guid isPermaLink="false">943@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I was just going by what the Maple PWM docs state.  &#60;/p&#62;
&#60;p&#62;from &#60;a href=&#34;http://leaflabs.com/docs/maple/pwm/&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/maple/pwm/&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;pinMode(pin_num, PWM)&#60;br /&#62;
    This command is usually called from setup() to tell the microcontroller that pin_num should be configured to PWM output. PWM implies regular driven OUTPUT (not open drain etc). &#60;/p&#62;
&#60;p&#62;Apparently the Maple library currently only supports Push-Pull when the pin is set up for PWM output, but the STM32 may support other modes.  Is that correct?&#60;/p&#62;
&#60;p&#62;CarlO.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-941</link>
			<pubDate>Wed, 01 Sep 2010 16:13:09 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">941@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I too am uncertain of the validity of this. We fooled around a bit to get OD PWM working and failed, but didnt try THAT hard, nor did we find an official reference to its impossibility. &#60;/p&#62;
&#60;p&#62;incidentally, cant an open drain pin be created with a an npn fet, with &#34;output&#34; at the drain (top) but otherwise floating, and the ground the source and connect the PP output from the pin to the base....
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Driving servo using maple"</title>
			<link>http://forums.leaflabs.com/topic.php?id=147#post-940</link>
			<pubDate>Wed, 01 Sep 2010 15:59:52 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">940@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;HDF - I missed that! &#60;/p&#62;
&#60;p&#62;Can anyone tell me which document says that timer PWM output pins can't operate in open-drain? Is it in the GPIO section, or in the timers?&#60;br /&#62;
In RM0008 (13902.pdf), or somewhere else?&#60;/p&#62;
&#60;p&#62;I am nervous that I may have missed some other pin restrictions now :-(&#60;/p&#62;
&#60;p&#62;I am using a buffer (74HCT04) for level translation for motor drive, but I was assuming I could do PPM for servo's directly from a timer, just using pull-ups.&#60;br /&#62;
Back to the (Eagle) drawing board :-(
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
