Thanks Tyler. Your article stimulated an interest in intelligence control for me.
Thanks, Tim, I might do that. Noise was already being smoothed with a rolling average (100-point), but it wasn't enough and averaging so many points was causing problems of its own. My next step would be circuit isolation from heater and some RC filter.
Filtering only helps for noise that's well outside of the desired bandwidth of the control loop -- if the noise is within five to ten times the desired bandwidth, then you need to get rid of it at the source.
That means figuring out if the problem is the sensor choice, it's location, the cabling, or the signal conditioning electronics. You mentioned separating grounds -- that's a Really Good place to start, but it may not be the end.
(It may be that you'll get too deep into this than is reasonable for a class project, too -- getting the utmost out of a control loop is like peeling an onion -- you take a layer off, the problems get a bit smaller, you cry, and then you have to do it all over again.)
- Tim Wescott
In fact, calculators have the same floating point limitations as computers, which makes sense, because calculators are simple computers. Try adding 0.1 to 1,000,000,000 and you'll get 1,000,000,000, not 1,000,000,000.1 (unless your calculator uses 64-bit numbers, which can precisely display up to about 18 digits); or try cos(0.00001) and you'll get 1, not 0.99999999995. They seem to be more accurate because they can limit their outputs. It's worth noting that having a hardware FPU does not guarantee greater precision than using a floating point library, as Arduinos do. The highest precision operations are actually done in software. Take a look at Java's BigDecimal for a great example and explanation.
You are correct in thinking that there could be a loss of precision when working with base-10 numbers in a binary system. The IEEE 754 standard defines 5 binary and 3 decimal floating point formats, where the latter can store decimal numbers exactly. Since the libm.a floating point library (Arduino/avr-gcc, etc.) likely uses the "binary32" format, it does not represent decimal number exactly, and is accurate to about 7 digits. Any format is no more precise than the value of the least significant bit ("LSB") (big-endian only; MSB value for little-endien) in the significand. For binary32 numbers, this is 2^-23 times the exponent, which is related to its magnitude. A quick search found a library that may be able to introduce the decimal32/64/128 formats to an Arduino platform, [here]: GitHub.com/toddtreece/esp8266-Arduino/.../decimal (it is for the ESP8266, a 32-bit Xtensa system, however, so it wouldn't work out of the box, if at all, on the 8-bit AVR/etc. systems we are using).
Tyler,
This is a great write up, good explanation and documentation. Thank you. If I have time I’m going to refactor this into my project. I just spent the last while programming the basics of dead reckoning for a two-wheeled, differential steering rover and of course the core of it involved the use of sine and cosine and lots of floats. I’ve read several articles admonishing the use of floats on micro controllers. It’s understandable as you’ve noted due to their limited memory, processing power, and lack of floating point unit. I plowed ahead anyway and with no noticeable performance problems yet. The encoder interrupts are firing about 750/s and I’m calculating coordinates and orientation 10/s. My only concern would be sacrificing precision. Dead-reckoning is known for error accumulation anyway.
Glad you could use it!
You can add another factor of ten or two to increase precision. (The above code is the float output multiplied by 1000.) Would just need to be a bit more careful about overflow when doing math with the output, especially multiplication. E.g. 'sinx' output may be as high as +10000, so don't multiply by more than 32 if using int, ~200000 if using long. Really, manually keeping track of these ranges is a pain in the ass, especially when debugging it (without a debugger/JTAG/etc), so if your application works with floats, I'd just use them... until it doesn't work. :)
Also, IntegerGeometry.h and IntegerGeometry.cpp were promoted to the master branch after a bit more review.
Wow. How did you get so skilled in graphics, Tyler? Was it part of an engineering education? I wonder if I could import parts from Tinkercad into Photoshop. And what made that awesome animation? Fusion360? Nice work.
Hi Tyler. How many degrees of freedom does your robotic arm have? Thank you.
Hey, thanks. I've picked up on graphics by fiddling with it over the past decade, a photograhy hobby, and a bit of perfectionism. Fusion360 did the animation. It's actually not great at doing animations, but it does do the 'explode' bit well. The arm has 3 DOFs, 4 if including the claw.
I just tried linking in a larger library, SdFat, with multiple directories, using junctions (mklink /j <target> <source>). I've spent about 30 minutes fighting with Eclipse to build/link the thing, and it's still not working. Gonna give ParticleIO VSCode a shot for the next 30 minutes, to change the pace.
Yep, everything is moved over now and working, using PlatformIO's version of the SdFat and QuickStats libraries. Thanks Peter!
This is a really good description of Eclipse setup. Thanks!
I have never used Eclipse, but i use NetBeans and having a good IDE is immensely helpful. I have not got to the point in my project where I am looking at whether the Arduino IDE is enough to do the coding, But I will definitely be looking into Eclipse if I find it is not.
I had trouble adding a library that wasn't in the Arduino Downloads Manager, so I wrote about it here: Using Private Arduino Libraries with Eclipse.
Tyler,
I was in the same boat looking for a more robust alternative to the Arduino IDE so your post Switching from the Arduino IDE to Eclipse came at the right time. Eclipse is a great IDE and I was happy to hear there was an Arduino extension. I followed your directions as well as watching Doug Schaefer’s video demonstration.
I was also frustrated by the shortcomings in the Eclipse C++ IDE for Arduino that you mention in this blog post. The steps necessary to include your own libraries makes the product feel like a not-fully-baked solution.
I just posted a summary of my IDE explorations and the solution I think I’m going to go with. I’d be interested to get your take on this.
Thanks for your helpful information…
Peter
Nicely written Tyler. As for your article on control theory, is control theory onerous math ... and avoidable? What applications do we need control theory for ... and why is it so vital?
Thank you.
Control theory does get into pretty gnarly math. Laplace and z-Transforms combined with linear algebra (non-linear if you're a masochist). You don't need it for this course, and can avoid it for many applications, even some of those that use a control system. That's what PID Without a PhD is all about. I've been trying to write a blog post all week that derives the optimal PID coefficients for moving my robotic arm, but have been stumped by the math to the point of giving up on that approach. (And I've already done a fair amount of that type of math before, having taken control systems courses.) The theory is important when you need to improve control performance.
The Landing is a social site for Athabasca University staff, students and invited guests. It is a space where they can share, communicate and connect with anyone or everyone.
Unless you are logged in, you will only be able to see the fraction of posts on the site that have been made public. Right now you are not logged in.
If you have an Athabasca University login ID, use your standard username and password to access this site.
We welcome comments on public posts from members of the public. Please note, however, that all comments made on public posts must be moderated by their owners before they become visible on the site. The owner of the post (and no one else) has to do that.
If you want the full range of features and you have a login ID, log in using the links at the top of the page or at https://landing.athabascau.ca/login (logins are secure and encrypted)
Posts made here are the responsibility of their owners and may not reflect the views of Athabasca University.
We block sites that track your web browsing without your permission. If a link is greyed out, click once to enable sharing, once more to share.