Skip to Content
Learning Robotics using Python - Second Edition
book

Learning Robotics using Python - Second Edition

by Lentin Joseph
June 2018
Beginner to intermediate
280 pages
6h 58m
English
Packt Publishing
Content preview from Learning Robotics using Python - Second Edition

Quadrature encoder interfacing code

This code will print the count of the left and right motor encoder via a serial port. The two encoders are in a 2X decoding scheme, so we will get 4,200 CPR. In the first section of the code, we are defining pins for two channel outputs of two encoders and we are declaring the count variable for two encoders. The encoder variable uses a volatile keyword before the variable data type. The main use of volatile is that the variable with the volatile keyword will store in RAM memory, whereas normal variables are in CPU registers. Encoder values will change very quickly, so using an ordinary variable will not be accurate. In order to get accuracy, we will use volatile for encoder variables, as follows:

//Encoder ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Robotics using Python

Learning Robotics using Python

Lentin Joseph
Python Robotics Projects

Python Robotics Projects

Prof. Diwakar Vaish

Publisher Resources

ISBN: 9781788623315Supplemental Content