<?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[Better response time using &quot;Pin Button&quot;]]></title><description><![CDATA[<p dir="auto">Hi,<br />
Just sharing my experience with using optocouplers as end-of-travel detectors using a stepper motor that drives a lead screw (that drives something else).<br />
The optocoupler is located at the end of the travel, and when it is blocked by a small plastic sheet that travels with the lead nut, it is supposed to stop the motor.<br />
I'm driving the stepper motor using the "stepmotor driver V1.1" module connected to a TAB5 controller, and programming with Uiflow2 V2.3.8 .<br />
The driver module has 4 input lines to be used for feedback of the moving object location using microswitches or optocouplers, exactly what I needed.<br />
The issue is that these lines are connected to the TAB5 through a simple I2C controller located on the driver module, and this makes it too slow to respond, so the motor is stopped after the traveler passed the optocoupler. And I'm using a pretty slow travel speed, just a few millimeters per second.<br />
The solution for this is to use the built-in pin buttons of the esp32 of the tab5.<br />
These pin buttons are much faster than the built-in lines of the driver module, I couldn't measure their response time, and as far as I'm concerned, they stop the motor immediately as the plastic sheet arrives at the optical slit of the optocoupler.<br />
I was a bit surprised to see that the built-in lines in the driver module are so slow, perhaps using a faster than the Uiflow2 programing language can squeeze faster response times from them, but I suspect it is not the case, since the delay is due to the extra serial communication between the esp32 and the i2c controller on the driver module.<br />
See attached photos for the code using pin buttons:</p>
<ol>
<li>
<p dir="auto">Define pin buttons on setup:<br />
<img src="/assets/uploads/files/1764928598476-55915bd9-94f4-48b9-81be-788abdef8084-image.png" alt="55915bd9-94f4-48b9-81be-788abdef8084-image.png" class=" img-fluid img-markdown" /></p>
</li>
<li>
<p dir="auto">Call for update in main loop and define operations when called:<br />
<img src="/assets/uploads/files/1764928662393-769629b5-ddd8-407a-8a5c-33501a9bfb95-image.png" alt="769629b5-ddd8-407a-8a5c-33501a9bfb95-image.png" class=" img-fluid img-markdown" /></p>
</li>
</ol>
<p dir="auto">In my case I use two optocouplers, one for each end of the travel.<br />
Their callbacks stop the motor and reverse the motor direction.</p>
]]></description><link>https://community.m5stack.com/topic/7932/better-response-time-using-pin-button</link><generator>RSS for Node</generator><lastBuildDate>Sat, 14 Mar 2026 23:50:51 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7932.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Dec 2025 10:04:47 GMT</pubDate><ttl>60</ttl></channel></rss>