Encoders notes

End stops

To know the position of a motor shaft, consider the following 3D printer. When does it *know* the bed reached it’s end?

Incremental Encoders

If we want to know in more detail the position of a motor shaft, consider a spinning disc and an infrared sensor. How many pulses will we read for a 360 degrees turn?


Quadrature position encoders

By adding another sensor, we can also measure the direction of the motor. Clockwise or Counter- clockwise.


Higher position can also be achieved when using quadrature encoders:



Absolute position encoders


Gray encoder

A researcher invented a simple but useful solution to noise in encoders. Here you can find an extract from Gray’s Patent:



gray-decimal gray



Final Projects

A growing industry


In different categories



Final Project Guidelines

  • Each student / team of two students will present their creation within 10 minutes
  • Block diagram with all the electronic components
  • Sketch of how it looks like
  • Functional Diagram (either finite state machine, flowchart or pseudo-code)
  • Proof of concept: mechanics, electronics and software
  • Be ready to be asked: why is it a robot? why not a machine? is it alive? is it intelligent? does it help humanity? does it explore any frontier of current knowledge?

Robot Design


Robot Design (1)


Class 6 and 7

How intelligent can robots be?

Solve this maze: Link

Win this game: Link

What is Artificial Intelligence (A.I.) ? What is the Turing Test? Go vs Chess? Link

Who was Kasparov?

What is Watson and why should you care?  Explanation – Tech Details


Service Robotics

Case study of HAL: http://www.slideshare.net/Funk98/robotic-exoskeletons-becoming-economically-feasible

Agriculture Robotics

http://www.unibots.com/Agricultural_Robot_Designs.htm (make sure to see the amount of information in the PDF of economic feasibility)

Industrial Robotics



Additional Resources

Social Robotics: Link  – Video1 – Video2 – Video3 – Explanation

Home Robots: Video1 –Video2

Robot Insects: VideoExplanation

4 legs evolution: Video1 – Video2 – Video3

Quadrotors: Video1 – Video2 – Video3

Swarm Robots: Video1

Soft robotics: Video2

Modular Robotics Video3

Snake – like robots Video4


Frontiers in robotics and AI – Journal



RECENT NEWS: GO is not longer a human domain. ( NEWS LINK ) ( Google DeepMind )

Class 5

Robots are taking important roles in our lives. One of the most well knowns are the Kiva Robots . There are many social implications and these are not the only ones used in warehousing. But also it is part of our course to understand how these machines operate and are using the sensors to guide themselves through the shelves.

We discussed about the impact of introduction of robotics, but somehow we left outside all the new opportunities that this brings to the game. Some robots are specifically designed to interact with other workers. For example, Baxter has many degrees of freedom and also has a human form factor to move precisely and while helping on tedious tasks. But of course there are many other improvements in hazardous environments like the car industry.

What would happen if the car is in the function of self driving and a door is opened? There should be a way to establish these different behaviors…

Robot Operative System

The ROS is a general purpose system that helps the most advanced robots work:




Finitie State Machine

A finitestate machine (FSM) or finitestate automaton (plural: automata), or simply a state machine, is a mathematical model of computation used to design both computer programs and sequential logic circuits. It is conceived as an abstract machine that can be in one of a finite number of states.

Here there is an interesting example of how a state machine can be used in automation (robot joke?)

Read further: Why developers should use state machines ?

Using the concept of function and state machine, we created in class our very humble autonomous LDR/LED system. Code is hosted in Github: here



Simple Finite State Machine


Just another example:



We rewrote the Example 5 into an Example 6, using SWITCH CASE syntax. But States could be many, depending the complexity of our application.

From other robot fans we can learn more about their state machines and the functions they use them for.



Using the basic work frame given in Example 7, we can build a state machine with several inputs and different actions. For this we define 4 different scenarios:

  • environmental light
  • strong light on the left sensor
  • strong light on the right sensor
  • strong light on both sensors

Instead of using real motors, we are using LEDs to simulate the states.


See it working with two LDR’s (simulator)


We connect the real motors with the functions, such as an example.


Code example is hosted here: Example


Bits and Bytes

Bit & Bytes

What can we do with FSM? 

FSM robot

FSM robot


FSM wall bouncer (Roomba for it's friends)

FSM wall bouncer (Roomba for it’s friends)

And now what?

Subsumption and A.I. in Robots

Behavioral Trees

Subsumption and behaviors

Subsumption and behaviors

Neurons in software


With no middle layers, OR, AND, NAND, NOR are easy to implement.


With a middle layer, a XOR can be represented.



Arduino as a neuronal network

Class 4

Fiction & robotics laws

1. A robot may not injure a human being, or, through inaction allow a human being to come to harm.
2. A robot must obey the orders given it by human beings except where such orders would conflict with the First Law
3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Law.

Different schools of design: B.E.A.M.

Mark Tilden is a recognized roboticist that has challenged the status quo. He is one of the pioneers together with other bright scientists asking themselves the concepts behind a robot. Only scratching the surface, we can take a look at the laws he propose:

1. Protect thyself.
2. Feed thyself.
3. Move thyself to better real estate.

There is so much more to learn from Tilden and why is it so challenging this design philosophy. Here there are some videos online


Projects in the spotlight

Special thanks to our senior fellow Marcela Godoy for most of these suggestions:

Design Process




MIT & Design Steps for robots ( extract from Mobile Robots: from inspiration to implementation)

Avoid “Usually”

What is the robot supposed to do?

What is the simplest way to accomplish the task?

What mechanical platform is needed?

What information does the robot need?

What sensors give this information most effectively?

How can the problem be decomposed into behaviors?

Wish you good fortune.


Mechanics Crash Course

The material you choose is going to be your friend

Sketch first, try even before

Where is your center of gravity ?


Open Structures

Open StructuresOpen StructuresOpen Structures


Resources for digital prototyping:



123D Make

123D Design

Slide Deck used in class: LINK

Class 3

There is a noteworthy educational project that proposes to bring robots to teach. This works inside of the many frontiers humanity is working actively to solve. One of the incentives are the X Prizes.



Details of the sensors and capabilities of a robot used as a teacher.



About feedback loops:

The way that all these robots send their control signals to their motors. But in order to move accurately they need a feedback loop. This proves to be one of the biggest challenges to face.


One way to achieve that control, is not only moving but actually adjusting their position. So we call them servo-motors. They have a big contrast with the DC motors also by the way they are operated.

There are plenty of operational details about how servomotors are used with Arduino. Make sure you understand the difference between an inactive servo and a detached one.



Proportional Derivative Integral Control Loops ( P.I.D. )

From Wikipedia:

A proportional–integral–derivative controller (PID controller) is acontrol loop feedback mechanism (controller) commonly used in industrial control systems. A PID controller continuously calculates an error value as the difference between a measured process variable and a desiredsetpoint. The controller attempts to minimize the error over time by adjustment of a control variable, such as the position of a control valve, adamper, or the power supplied to a heating element, to a new value determined by a weighted sum


Overview of functions 




Filters & implementations


Code example of a simple filter with Arduino: link

Here you can read a practical example about why filters are really needed: link

Pseudocode and Flowcharts


Extensive explanation about how to draw flowcharts: Link


Code Examples hosted at Github

Class 2

Sensors in Robots

-Which physical parameters a robot needs to measure?

-Are those internal or external?

-Do the sensors provide the information or do they need further processing?


Robots are taking important roles in our lives. One of the most well knowns are the Kiva Robots . There are many social implications and these are not the only ones used in warehousing. But also it is part of our course to understand how these machines operate and are using the sensors to guide themselves through the shelves.

Among the different sensors a robot can use to measure the environment, there is a particular application of those sensors to detect positions. We call those encoders. There are different classifications and specific applications.


Further readings:






Microcontroller using digital inputs

Use the tutorial from Arduino to create a simple digital input https://www.arduino.cc/en/Reference/DigitalRead

Further reading: https://www.arduino.cc/en/Tutorial/DigitalPins

Microcontroller using analog inputs


Further reading: https://www.arduino.cc/en/Tutorial/AnalogInputPins


H-Bridges are thoroughly explained at Chapter 7 of Make an Arduino Controlled Robot in our bibliography 


How do we control speed if our outputs are digital?

Arduino pins that are not configured to have an output timer will not be able to work on PWM. Watch out for that.

Pulse Width Modulation might also become interesting by itself. There is plenty of information about how this actually works.


Using our knowledge of PWM now we can adjust the speed of the motors and directions accordingly.





All our code is posted at our Github repository: https://github.com/todocono/NYU-robotics-2016-A/tree/master/ex2

Ultrasound Sensors 

You can find information about the sensor about the HC-SR04 sensor

To measure time, there is a special function that will give us how long a pulse has been: PulseIn

Class 1

Some of the things we have seen this week are the different definitions of robotics. If we take a glance at wikipedia:

A robot is a mechanical or virtual artificial agent, usually an electro-mechanical machine that is guided by a computer program or electronic circuitry. The word ‘robot’ was first used to denote a fictional humanoid in a 1921 play R.U.R. by the Czech writer, Karel Čapek.

To more updated and comprehensive definitions. For example, Carnegie Science Center tells us

Robotics technology consists of machines that can:

  • Sense – Sensors, or feedback devices, allow information about the machine’s surroundings to be recorded as electronic values.
  • Think – This electronic data is then used in complex circuits programmed to produce signals at the other (output) end of the circuit.
  • Act – Acting is the most obvious part of robotics technology. The electronic signals that were produced as a result of sensing and thinking then control whatever the robot is designed to do, like lift a sick person, make a facial expression, or control the motors that allow it to navigate around an obstacle.

One “expert” definition of a robot is given as “a machine with at least three axes of motion (e.g. wrist, elbow, and shoulder), an attached tool, and the ability to be reprogrammed for various tasks.” Not a bad definition, if you like industrial robots.


In any case, among the different classifications there is a huge interest for these machines. Both from the business point of view, just by considering the fast growing of their adoption rate in the industry sector. Or from the human interaction, where we see that there are sectors like health care that are having breakthrough discoveries thanks to robots.

Every year there is an annual Challenge, where all teams around the world try to get over a series of obstacles. The complexity of these tasks have been increasing year after year. Here is a video of the actual competition from 2015:



Main software we will be using is Arduino. All instructions and their syntaxes are explained at the Arduino Reference.


We will be using the Arduino UNO board, that has been heavily modified for it’s use in robotics. References to it’s use can be found at their WIKI documentation.


The kits we will initially be using have their user manual and technical specifications in their WIKI documentation

Batteries and Soldering

Lithium Polymer batteries are very useful. Also dangerous. Read about them

We will solder some of the sensors, here you can find an instructional video.

Connections and Programming

We will complement Arduino with a motor driver called L298p. In order to use it we will need to follow it’s own datasheet.

Our goal is to build a double motor mechanical base that will allow us to move around and avoid obstacles. There is a tutorial that might help you navigate through the actual wiring.

Bibliography and Syllabus

Sample code used in Class 1 is hosted in GitHub