I see that you are planning to use motors with integrated encoders. I've been using a much smaller motor, but with encoders to help me with waypoint navigation and speed regulation. Right now I'm using the Arduino PID controller library. It's quite easy to use and after a bit of tuning it was giving me reasonable results.
I've recently made a modification to motor encoder circuit that has doubled the accuracy of my wheel encoders and given me even better performance. It's a simple mod, and think you may find it useful.
The motor encoders (as you know) run with quadrature encoding. Allowing you to determine the direction of rotation. As I control the direction of rotation of my motors, this seemed to be of little use to me. Therefore I just ran one of the two encoder lines to the Nano's interrupt pin (one encoder line from each of the two motors to each of the Nano's two interrupts).
Let's try to make this drag on much longer... The mod is to connect each of the two encoder lines from a motor to the inputs of an exclusive OR logic gate (74LS86)
This produces a pulse stream that is double the frequency, compared to just using the single line.
Not sure if you're interested, but a while back I purchased a couple of rotary encoders from eBay - They have 600 pulses / rev and only cost ~$17AUD each for me, and certainly much cheaper for the USD tinkerers! Not sure of their exact cost these days, but might save you some screwing around with logic gates that won't even come close in the end 🙂
Thanks @frogandtoad, but I'm now sure how I would attach the encoders to my motors. My current encoders are integral to the motor's frames. On the plus, I am getting 1400 pulses per revolution and all is working just fine.
Let's try to make this drag on much longer... The mod is to connect each of the two encoder lines from a motor to the inputs of an exclusive OR logic gate (74LS86)
This produces a pulse stream that is double the frequency, compared to just using the single line.
I am working on adding PID control to my robot and I saw your post. I like the addition of 74LS86 to give you a higher frequency. Are there any updates or advice you might have?
@huckohio not too much to add. Doubling the encoder frequency is still working well for me, on ARDVARC. The only thing you need to keep an eye on is overloading the interrupts. If your encoders are already fast, your processor may have difficulty keeping up.
One recent change, I've made, is to use the remaining two gates to invert my "direction" signal. I connect two sets of encoders (one left and one right) to two of the XOR gates. Leaving two gates unused. Now... the H-bridge I'm using requires two signals that indicate direction. A FORWARD and a NOT_FORWARD. I feed my FORWARD signal to one of the spare XOR gate inputs and tie the other input high. This gives me the inverted signal at the gate's output. In my original robot, I used a pair of 2N2222s to perform the inversion.
And a question back to you... are you using a library for PID control? I was using Beaureguard (sp?) PID_v1 library. It worked well with my earlier robot but is giving me problems with the new one. I spent two days digging around without any joy. I'm at the point now of thinking I maybe I should try to write my own PID controller.
And a question back to you... are you using a library for PID control? I was using Beaureguard (sp?) PID_v1 library. It worked well with my earlier robot but is giving me problems with the new one. I spent two days digging around without any joy. I'm at the point now of thinking I maybe I should try to write my own PID controller.
The only thing you need to keep an eye on is overloading the interrupts. If your encoders are already fast, your processor may have difficulty keeping up.
@huckohio there seems to be a number of libraries available. I'll try to put a list together, a little later. I'll also be looking at the match between my math(s) skills and the code for PID controlling 🙂 First off however, I need to get to Costco.
@huckohio straight lines is the reason I went to PID. I was originally planning to "orient" ARDVARC by running a straight line (a la line following) and having it learn how much power to feed each of the two motors to keep them in sync. After a night's sleep I thought better of it.
I'll take a closer look at which revision I'm using. I'm loading the .h file for the earlier one, but not shore which link files are being used. I'm using platformio/vscode to develop my code and am certainly not full skilled in it yet.
Regarding your original post I have a question.Your wave forms make it clear how you are doubling your clicks per revolution.Nice.I’m wondering howyou are able to measure the distance covered if you are moving backwards?Do you have a clever way of decrementing your counters?This is the code that I’ve plagiarized, but only encoder A is connected to an interrupt pin.
See, the human mind is kind of like... a pinata. When it breaks open, there's a lot of surprises inside. Once you get the pinata perspective, you see that losing your mind can be a peak experience.
Jane Wagner - The Search for Signs of Intelligent Life in the Universe
@thrandell I took the cheap and dirty road. I assume that the only way for the robot to move is under power. I know which way the wheels are turning, as I am the cause of any movement. This is not a solution for travel on uneven ground, unless you have brakes.
You could change your current code to only check direction when A is high. Just store the direction in a variable. When A is low, increment or decrement according to the stored direction variable. Any error should be limited to one tick.
At least I think that would work <insert a shoulder shrug>.
We use cookies on the DroneBot Workshop Forums to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.