<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Precise pulse duration]]></title><description><![CDATA[<p dir="auto">I am trying to to do a pulse of a given duration (e.g. 2.000 ms) on a digital output. Ideally, I don't want to stop the code with a <code>while True</code>:</p>
<p dir="auto">At the moment, I am trying with Timer.Alarm but I have the feeling that I am not getting an accurate timing.</p>
<pre><code class="language-python">p_out = Pin('P19', mode=Pin.OUT)

def pulse_off(timer):
    p_out(0)

# Perform a pulse of 2000ms
p_out(1)
pulse_timer = Timer.Alarm(self.pulse_off, ms=2000, periodic=False)
</code></pre>
<p dir="auto">Could anyone give some advice on the most accurate way to perform a pulse? Thank you in advance!</p>
]]></description><link>https://forum.pycom.io/topic/3285/precise-pulse-duration</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Mar 2026 01:28:52 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/3285.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 May 2018 07:43:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Precise pulse duration on Wed, 23 May 2018 07:43:42 GMT]]></title><description><![CDATA[<p dir="auto">I am trying to to do a pulse of a given duration (e.g. 2.000 ms) on a digital output. Ideally, I don't want to stop the code with a <code>while True</code>:</p>
<p dir="auto">At the moment, I am trying with Timer.Alarm but I have the feeling that I am not getting an accurate timing.</p>
<pre><code class="language-python">p_out = Pin('P19', mode=Pin.OUT)

def pulse_off(timer):
    p_out(0)

# Perform a pulse of 2000ms
p_out(1)
pulse_timer = Timer.Alarm(self.pulse_off, ms=2000, periodic=False)
</code></pre>
<p dir="auto">Could anyone give some advice on the most accurate way to perform a pulse? Thank you in advance!</p>
]]></description><link>https://forum.pycom.io/post/19860</link><guid isPermaLink="true">https://forum.pycom.io/post/19860</guid><dc:creator><![CDATA[berni]]></dc:creator><pubDate>Wed, 23 May 2018 07:43:42 GMT</pubDate></item><item><title><![CDATA[Reply to Precise pulse duration on Wed, 23 May 2018 08:02:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1369">@berni</a> The RMT class could be used for that.</p>
]]></description><link>https://forum.pycom.io/post/19861</link><guid isPermaLink="true">https://forum.pycom.io/post/19861</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Wed, 23 May 2018 08:02:35 GMT</pubDate></item><item><title><![CDATA[Reply to Precise pulse duration on Wed, 23 May 2018 08:07:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1369">@berni</a><br />
Indeed RMT would be the best way to generate pulses, <a href="https://docs.pycom.io/chapter/tutorials/all/rmt.html" target="_blank" rel="noopener noreferrer nofollow">https://docs.pycom.io/chapter/tutorials/all/rmt.html</a>.</p>
<p dir="auto">The maximum single pulse width is ~ 100ms but you should be able to chain multiple together</p>
]]></description><link>https://forum.pycom.io/post/19862</link><guid isPermaLink="true">https://forum.pycom.io/post/19862</guid><dc:creator><![CDATA[jmarcelino]]></dc:creator><pubDate>Wed, 23 May 2018 08:07:14 GMT</pubDate></item><item><title><![CDATA[Reply to Precise pulse duration on Wed, 23 May 2018 08:35:30 GMT]]></title><description><![CDATA[<p dir="auto">Thank you <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/98">@robert-hh</a> and <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/212">@jmarcelino</a>! I will give it a go and report back. :-)</p>
]]></description><link>https://forum.pycom.io/post/19863</link><guid isPermaLink="true">https://forum.pycom.io/post/19863</guid><dc:creator><![CDATA[berni]]></dc:creator><pubDate>Wed, 23 May 2018 08:35:30 GMT</pubDate></item></channel></rss>