Showing posts with label Electronics. Show all posts
Showing posts with label Electronics. Show all posts

2016/11/21

C vs C++, performance on AVR

The aim of this post is to fight the generalized belief of C++ being too slow of a language for embedded environments. This belief goes around, saying that microcontrollers should still be programmed in C, or even in assembler. Probably you don't agree with me right now. The idea of C being much more efficient than C++ is so extended that it almost seems like sacrilege to debate it. That's why I'm about to make a series of comparisons between both languages, throwing in some real and objective numbers (code size, execution time, etc). After we prove that not only can C++ compete with good old C, we'll see it's actually a better alternative. For that, besides performance metric, I will compare things like safety, code readability or portability.

2013/01/26

Hacking a servo: Part I

Motivation

Servos are probably the most popular actuator in DIY robotics today. Cheap, easy to use and easy to control, they are almost everything you want for your little robot. However, they're also quite limited, since they don't provide any feedback, or any information about how they're performing. This makes servos open loop systems, resulting in robots showing typical open loop issues.
Basically, your robot tells its servos to move to some position, and hopes they do it. Never knows whether servos have come to its target or they are stuck in the middle. Even when a servo doesn't get stuck, it's hard to predict where it actually is due to varying loads and initial conditions.
Most of the time, this is solved using an external sensor, like a potentiometer.
But some times there is no room for extra sensors in your robot, and even if there is, why bother when the servo has its own potentiometer inside?