u/NameruseTaken

Introduction To Binary Protocols In Robotics
▲ 9 r/ArduinoProjects+3 crossposts

Introduction To Binary Protocols In Robotics

Hi fellow robots, as I work on my projects I discover cool new ways to do things and I thought I'd share something I learned with you guys.

Typically in Arduino projects where you need to read and write to connected devices such as sensors and motors, you'd use serial communication. If you wanted to use Python to talk to the Arduino (to control motors or receive feedback), you'd need a way to bridge the language gap between C++ and Python. Most beginner tutorials would teach you to just send strings of characters back and forth that have to be parsed.

But that's a very rigid and cumbersome way of passing information. If the number of decimal places changes, your message could now be a different length. Each character is one byte, so your message could end up being massive if you have large numbers.

This is where it makes sense to use a binary protocol, where you send a fixed "frame" of data represented as bytes and all devices abide by the protocol. The idea is to define the structure of your message and send data as binary representations.

  • The message "type" can be represented by a single byte (eg. 0x01).
  • If the data or payload is a floating point number, it can be represented by 4 bytes regardless of how big it is (up to a limit).

Now you can always send and received fixed message structures and lengths, known as "packets". This is much more elegant because you always know where to expect each piece of information and how big they are, so you don't need to deal with parsing large strings of characters that vary in length. The difference is especially noticeable once you start sending multiple pieces of information in one packet (eg. speed, position, temperature, voltage, current).

I didn't want to make this post too long so this is just a basic overview. If you're interested in more detail with examples to improve your inter-device communication, check out my article.

u/NameruseTaken — 4 hours ago
▲ 11 r/arduino

Servo Motor Calibration

Hi everyone,

I see many people learning about electronics through hobby projects (myself included) and I wanted to start sharing things that I've learned that people might find interesting or useful for their projects.

This post is about servo calibration. When you buy cheap servos, you might not get the accuracy you need because there are variations between each unit. To get around this, you just need to rotate the servo to known positions and record the PWM value that takes the servo to those positions. This mapping yields a relationship between PWM and servo angle for that particular unit.

https://preview.redd.it/85m4u6t6qyvg1.png?width=614&format=png&auto=webp&s=c84575d9f3400ed8c989e47fc465f93f9f1654ca

Check out my article on Medium:

https://medium.com/@ianqyhong/servo-calibration-4ea1d43c46a6

Let me know if you found this interesting, useful, completely useless, or any other feedback!

reddit.com
u/NameruseTaken — 3 days ago
▲ 7 r/ArduinoProjects+2 crossposts

Servo Motor Calibration

Hi everyone,

Long time lurker here. I see many people learning about robotics through hobby projects (myself included) and I wanted to start sharing things that I've learned that people might find interesting or useful for their projects.

This post is about servo calibration. When you buy cheap servos, you might not get the accuracy you need because there are variations between each unit. To get around this, you just need to rotate the servo to known positions and record the PWM value that takes the servo to those positions. This mapping yields a relationship between PWM and servo angle for that particular unit.

Check out my article on Medium:

https://medium.com/@ianqyhong/servo-calibration-4ea1d43c46a6

Let me know if you found this interesting, useful, completely useless, or any other feedback!

reddit.com
u/NameruseTaken — 3 days ago