<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Working with ArduPID for Motor Speed Control - ESP32 &amp; ESP8266				            </title>
            <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/</link>
            <description>Discussion board for Robotics, Arduino, Raspberry Pi and other DIY electronics and modules. Join us today!</description>
            <language>en-US</language>
            <lastBuildDate>Sun, 12 Apr 2026 19:29:48 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Working with ArduPID for Motor Speed Control</title>
                        <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/5/#post-39924</link>
                        <pubDate>Tue, 09 May 2023 22:25:42 +0000</pubDate>
                        <description><![CDATA[Maybe it is very late to react here so I don&#039;t know is anybody is really interested in reading it. But many folk have helped me here a lot with trying to get things working as I wanted. It w...]]></description>
                        <content:encoded><![CDATA[<p>Maybe it is very late to react here so I don't know is anybody is really interested in reading it. But many folk have helped me here a lot with trying to get things working as I wanted. It was a big struggle and I have been a bit quite last weeks but that was for one part due to work but also I need to dive into the matter to get this working, and I'm pretty happy that I got to a point that this motor control I got under "control".<br /><br />I have a bit different hardware setup now. a different motor driver board and different encoders (which came with the motors). But besides of that I read a lot about PID tuning and dived a bit more into how these PID libs working.<br /><br />One of the big issues I had was that I never even came close to the speed setpoint I gave to the controller. I I seem to have managed it. I will show here a picture and try to explain what it show.</p>
6798
<p>The red line is the desired setpoint we see it here go up from zero to the desired value at the moment I have connection But there is not yet power supply to the motor driver board. At the moment I turn on the power supply we see the green and magenta line go up. The green and magenta lines are the speed measurements. So these values need to end up on the red line which is the setpoint. <br />This seems to work there is indeed a big overshoot and I think I know how to reduce this but that is for later work (I will explain). I'm verry happy that the control circuit reaches its setpoint. This is done with a PID controller and a Arduino NANO 33 IoT. In fact it is only a PI controller and tuning without the Ki I get a huge difference between setpoint and measured value tuning the I makes me come to this result.<br /><br />This huge overshoot I could reduce more by working with the Kd gain but I have waited with that for now cause these tests were done unloaded. I mean by that that the wheels don't feel any inertia from the wight of the bot. I will tune it more. I just wanted to share that I was eventually able to make a PID control working with a Arduino and encoders. There is a bit more to tune I know.<br /><br />Now how I appriached this is that I count in a interval of 100ms the amount of pulses the enconder counts (with interrupts) with this value I comput the rpm value. This value I use for the PID regulation, but the PID regulation has also a time to do its calculations. And this is a important thing to take into acount. <br />The library I used has a setting where you can set it's sample time and it basicallly meanse how many times per second it computes it's algorithm and send new outputs. This MUST match with the speed you sample the speed. And this was a bit of tuning.<br /><br />Maybe for many people this is a easy thing to tackle for me it took a while and learned a lot of things  Again the overshoot I can reduce I think and maybe it is not even to much of an issue when seeing the bot driving I will see</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/esp32-esp8266/">ESP32 &amp; ESP8266</category>                        <dc:creator>ElectricRay1981</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/5/#post-39924</guid>
                    </item>
				                    <item>
                        <title>RE: Working with ArduPID for Motor Speed Control</title>
                        <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/5/#post-38464</link>
                        <pubDate>Sat, 04 Mar 2023 15:00:00 +0000</pubDate>
                        <description><![CDATA[Hi @robotbuilder,

It was more about understanding the algorithms hidden in the libraries.

Thanks for clarifying ... I tried to give my understanding of how the terms originated, which ...]]></description>
                        <content:encoded><![CDATA[<p>Hi @robotbuilder,</p>
<blockquote>
<p>It was more about understanding the algorithms hidden in the libraries.</p>
</blockquote>
<p>Thanks for clarifying ... I tried to give my understanding of how the terms originated, which may have detracted from describing the need to look at the algorithms.</p>
<p>I totally agree with your comment, and hence I suggested implementing PID as explicit code.</p>
<p>Best wishes, Dave</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/esp32-esp8266/">ESP32 &amp; ESP8266</category>                        <dc:creator>DaveE</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/5/#post-38464</guid>
                    </item>
				                    <item>
                        <title>RE: Working with ArduPID for Motor Speed Control</title>
                        <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/5/#post-38460</link>
                        <pubDate>Sat, 04 Mar 2023 14:44:25 +0000</pubDate>
                        <description><![CDATA[@davee 
It was more about understanding the algorithms hidden in the libraries.Perhaps assembler is a bit low level although it used to be my language of choice before the Windows OS came a...]]></description>
                        <content:encoded><![CDATA[<p>@davee </p>
<p>It was more about understanding the algorithms hidden in the libraries.<br /><br />Perhaps assembler is a bit low level although it used to be my language of choice before the Windows OS came along. <br /><br />Arduino c++ uses functions such as pinMode() digitalRead() attachInterrupt() and so on to make programming the microprocessor much easier so you don't have to understand how it works at the hardware level.</p>
<p> </p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/esp32-esp8266/">ESP32 &amp; ESP8266</category>                        <dc:creator>robotBuilder</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/5/#post-38460</guid>
                    </item>
				                    <item>
                        <title>RE: Working with ArduPID for Motor Speed Control</title>
                        <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38456</link>
                        <pubDate>Sat, 04 Mar 2023 14:16:41 +0000</pubDate>
                        <description><![CDATA[Hi @electricray1981,
  This note will not directly help your motors rotate at the same speed, but I hope it gives a little perspective to different programming approaches that you can gener...]]></description>
                        <content:encoded><![CDATA[<p>Hi @electricray1981,</p>
<p>  This note will not directly help your motors rotate at the same speed, but I hope it gives a little perspective to different programming approaches that you can generally find helpful.</p>
<p>---</p>
<p>  When @robotbuilder mentioned "highest level" and  "lower level", I think the "high" and "low" level referred to the programming level.</p>
<p>In the past, programming in assembly language, and before that machine level, where you are manually specifying the individual machine level instructions of the processor was referred to low level programming. Here the human programmers have to imagine exactly what the processor will do, often delving down to the bit level of 1s and 0s.</p>
<p>High level programming meant programming in a language that was more 'human centric', and tried to hide the '1s and 0s' world of the machine processing. One of the older and more successful 'high level' languages, which is still in use, is Fortran ... apparently named from FORmula TRANslation. This provided a means of readily implementing mathematical formulas in a form that was similar to the original mathematical expression.</p>
<p>It should be noted that languages like Fortran began the shift away from emphasising efficiency of the program from the machine's perspective, by also considering the cost in time, labour, etc. of the programmer. That is, the execution time of a Fortran program may have been longer than a carefully hand optimised assembler program that performed the same task, but the Fortran program would have required far less human effort to write and test it.</p>
<p>Of course, this dates back to the 1960s, perhaps earlier, and things have hugely expanded since then, so the relatively simple distinction between high and low level languages and programming is a lot more blurred.</p>
<p>For example, the C programming language was specifically designed to provide 'high level' abstraction from the machine's internals that assembly language approach demanded, whilst retaining (at least) the majority of flexibility and direct access to the processor's internal structure needed in some cases. The extension of C into C++ has further expanded the language into the 'high level' domain, whilst retaining the 'low level' operations for the programmer who needs it.</p>
<p>In more recent times, the 'low' and 'high' level terms seem to be applied not only to programming languages, but also some of the related tools, code libraries, and so on, which provide access to computing functions. It could be suggested that using a spreadsheet like Excel, or CAE program based on Spice to simulate an electronic circuit, are examples of a very high level approach, though I suspect some people might think this is over stretching the definition.</p>
<p>However, I think it illustrates the range of choices that are now available. The spreadsheet enables someone who does not know what a 'traditional' computer programme looks like, and struggles with basic mathematical operations like division, (at least without using a calculator,) to perform relatively complex arithmetical tasks, such as calculating their company and personal financial accounts.</p>
<p>This means that the high level approach can be greatly empowering. However, the 'danger' is that the user does not understand the implications of the task they are requiring the machine to do, and may not realise when it is inappropriate or even failing. We have all read of cases of a single person living a small house, has been sent an electricity bill equivalent to millions of dollars. Obviously, this is an extreme case, but I hope you see the point.</p>
<p>-------</p>
<p>Hence, I think @robotbuilder ws suggesting you would find it useful to start with a 'low level' approach to your project ... certainly I would support that view.</p>
<p>My view does not mean I suggest you do everything in assembler, but rather that you aim to build at a level that you feel you really understand and can "see" what is happening at the "machine" ... the controller and motors in your case ... level.</p>
<p>e.g. I suggested you code a simple mathematical expression to 'manually' implement the proportional control, because I think it gives a much better understanding and visibility as to what is happening, compared to calling up an obscure library. It might also be more efficient from the processor's viewpoint! When you are ready to build in the I &amp; D parts of the PID, I think the same applies.</p>
<p>Of course, the disadvantage is that it may take you longer to do it this way. In the future, you may justifiably decide you don't need to go to such a low level, and something like using a prewritten library is the more efficient process. That is fine ... but hopefully, your earlier experience will also provide you with the knowledge and experience to avoid the equivalent of sending the multi-million dollar electricity bill!</p>
<p>Good luck and best wishes, Dave</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/esp32-esp8266/">ESP32 &amp; ESP8266</category>                        <dc:creator>DaveE</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38456</guid>
                    </item>
				                    <item>
                        <title>RE: Working with ArduPID for Motor Speed Control</title>
                        <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38453</link>
                        <pubDate>Sat, 04 Mar 2023 13:51:52 +0000</pubDate>
                        <description><![CDATA[@electricray1981 NO, not RTC, I was showing you an example of how to code an ISR. Controlling a motor is NOT basic, working with resistors, capacitors, transistors is basic. Here is a websit...]]></description>
                        <content:encoded><![CDATA[<p>@electricray1981 NO, not RTC, I was showing you an example of how to code an ISR. Controlling a motor is NOT basic, working with resistors, capacitors, transistors is basic. Here is a website where you can practice on the web before building for real.</p>
<p><a href="https://www.falstad.com/circuit/circuitjs.html" target="_blank" rel="noopener">https://www.falstad.com/circuit/circuitjs.html</a></p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/esp32-esp8266/">ESP32 &amp; ESP8266</category>                        <dc:creator>Ron</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38453</guid>
                    </item>
				                    <item>
                        <title>RE: Working with ArduPID for Motor Speed Control</title>
                        <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38450</link>
                        <pubDate>Sat, 04 Mar 2023 11:33:29 +0000</pubDate>
                        <description><![CDATA[@robotbuilder 
No worries everybody is here helping me and I learn from everybody something.]]></description>
                        <content:encoded><![CDATA[<p>@robotbuilder </p>
<p>No worries everybody is here helping me and I learn from everybody something. </p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/esp32-esp8266/">ESP32 &amp; ESP8266</category>                        <dc:creator>ElectricRay1981</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38450</guid>
                    </item>
				                    <item>
                        <title>RE: Working with ArduPID for Motor Speed Control</title>
                        <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38449</link>
                        <pubDate>Sat, 04 Mar 2023 11:27:58 +0000</pubDate>
                        <description><![CDATA[@electricray1981 

I don&#039;t understand your comment fully. I think I&#039;m doing a real basic thing and that is controlling a motor.

After some thought I realized the post probably was of no...]]></description>
                        <content:encoded><![CDATA[<p>@electricray1981 </p>
<blockquote>
<p><br />I don't understand your comment fully. I think I'm doing a real basic thing and that is controlling a motor.<br /><br /></p>
</blockquote>
<p><br />After some thought I realized the post probably was of no help to you but the hour had passed and I couldn't delete it. I won't try and explain as it is really off topic for this thread. We all have to run our own race and do it our way.  If someone can't help you do it your own way then they aren't of much use to you.<br /><br /><br /></p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/esp32-esp8266/">ESP32 &amp; ESP8266</category>                        <dc:creator>robotBuilder</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38449</guid>
                    </item>
				                    <item>
                        <title>RE: Working with ArduPID for Motor Speed Control</title>
                        <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38448</link>
                        <pubDate>Sat, 04 Mar 2023 10:23:49 +0000</pubDate>
                        <description><![CDATA[@zander 

So basically they do the same as what I am doing but they use a Real Time Clock?
 

Some basic proramming I know we have spoken about that the more advanced stuff I am not fam...]]></description>
                        <content:encoded><![CDATA[<p>@zander </p>
<p></p>
<p><a title="ElectricRay1981" href="https://forum.dronebotworkshop.com/participant/electricray1981/">@electricray1981</a> We have all been there, don't worry it will come. I am attaching a couple of screen grabs. I am working with real-time clock code that uses interrupts, have a look at how they do it, and note they did NOT use the fast memory macro IRAM_ATTR so you are well ahead of the game. Also note the use of volatile for the ISR flag, without that it will not work, look it up in Arduino.cc docs to find out why.</p>
<p></p>
<p>So basically they do the same as what I am doing but they use a Real Time Clock?</p>
<p> </p>
<p></p>
<p>Oh, I didn't know you were not a programmer.</p>
<p></p>
<p>Some basic proramming I know we have spoken about that the more advanced stuff I am not familiar with...thats why I'm here to learnmore stuff. The code I wrote for my project is all done by myself no copy paste from other projects, but offcourse I ooked at examples on how to do certain things.</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/esp32-esp8266/">ESP32 &amp; ESP8266</category>                        <dc:creator>ElectricRay1981</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38448</guid>
                    </item>
				                    <item>
                        <title>RE: Working with ArduPID for Motor Speed Control</title>
                        <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38447</link>
                        <pubDate>Sat, 04 Mar 2023 10:18:44 +0000</pubDate>
                        <description><![CDATA[@robotbuilder 
I dont understand your comment fully. I think I&#039;m doing a real basic thing and that is controlling a motor. So in order to let the bot drive straight. IMHO that is a basic th...]]></description>
                        <content:encoded><![CDATA[<p>@robotbuilder </p>
<p>I dont understand your comment fully. I think I'm doing a real basic thing and that is controlling a motor. So in order to let the bot drive straight. IMHO that is a basic thing. Yes I have had different libraries to filter the measurement and yesterday I have tried a different approach on that. Further there are two libraries in my code in orer to use MegunoLink.</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/esp32-esp8266/">ESP32 &amp; ESP8266</category>                        <dc:creator>ElectricRay1981</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38447</guid>
                    </item>
				                    <item>
                        <title>RE: Working with ArduPID for Motor Speed Control</title>
                        <link>https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38445</link>
                        <pubDate>Sat, 04 Mar 2023 05:07:44 +0000</pubDate>
                        <description><![CDATA[@zander 
Yes I kind of think maybe @electricray1981 would benefit by starting much simpler without the libraries to get a feel of how things work at a basic level the way I am doing in anot...]]></description>
                        <content:encoded><![CDATA[<p>@zander </p>
<p>Yes I kind of think maybe <span>@electricray1981 would benefit by starting much simpler without the libraries to get a feel of how things work at a basic level the way I am doing in another thread. At the highest level I guess you would start with ROS without any understanding at all about lower level operations.</span></p>
<p> </p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/esp32-esp8266/">ESP32 &amp; ESP8266</category>                        <dc:creator>robotBuilder</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/esp32-esp8266/working-with-ardupid-for-motor-speed-control/paged/4/#post-38445</guid>
                    </item>
							        </channel>
        </rss>
		