Encoder 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



Week 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


Neurons in software


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


With a middle layer, a XOR can be represented.


Example: Arduino as a neuronal network

Artificial neural network with XOR

Robot Operative System

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

Industrial robotics link

Service robotics link

A growing industry

Investment in industrial robotics

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


Final Project Guidelines

  • Each student / team of two students will present their creation within 10 minutes
  • Block diagram with all the electronic components
  • Sketches of the physical appearance, not only to see how it looks like but the C.O.G.
  • 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?
  • Three aspects will be evaluated: Concept ( the story behind ), Design ( sketches and iterations) and Functionality ( actual prototype and diagrams )


Week 6

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 a lot to learn from Tilden and why is it so challenging this design philosophy. Here there are some videos online.



Example of robot programming from MIT Media Lab “Mobile Robots: From Inspiration to Implementation”


Additional Resources

Exoskeleton: Case study – Video

Agriculture Robotics: Economic feasibility , Video

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

Robots that can sweat: Video

Frontiers in robotics and AI – Journal


Slides used in class: Week 6

Week 5

Social robotics

Examples brought from the participants of the class

Social Robotics: LinkVideo1 – Video2 – Video3 – Explanation

Machine states: why and how?

Robots are taking important roles in our lives. We saw in a previous class 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…


Related topic: Why self driving cars must be programmed to kill


Finite 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

Review: 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)


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


A complex behavior as a set of sub-behaviors

Subsumption and A.I. in Robots

Behavioral Trees

Subsumption and behaviors

Subsumption and behaviors


Slides used in class for week 5


Solar panel tracking light coded in class



Week 4

Some inspiration for the final projects

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 Structures


Live demo: 

Materials: aluminum, plastic, cardboard, paper, tape, hot glue

Center of gravity

Screws – washers – nuts

Resources for digital prototyping:



123D Make (discontinued)

123D Design (discontinued)


Follow up from last class:

Code for light follower: LINK

Code for light follower with low pass filter: LINK

Code for PID braking: LINK (not tested)

Link for this week slides


Week 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.


Image from https://www.ald.softbankrobotics.com


Image from https://www.ald.softbankrobotics.com


Pseudocode and Flowcharts


Extensive explanation about how to draw flowcharts: Link

About feedback loops:

Image from Wikipedia

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.

Overview of functions 





(Image from Wikipedia) Servomotors

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 desired setpoint. The controller attempts to minimize the error over time by adjustment of a control variable, such as the position of a control valve, a damper, or the power supplied to a heating element, to a new value determined by a weighted sum


PID – Image from Wikipedia


PID over and undershooting – Image from Wikipedia


Filters & implementations

Discard wrong values

Low Pass

High Pass


PID trainer based on the Arduino library: link

Arduino library

Code example of a simple filter with Arduino: link

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

Code example with PID link

Code Examples hosted at Github

Slides we used in class

Week 2

Thoughts about robot origins

GolemTalos & Galatea


Industrial Robotics



Industrial robots and comments from 1983

Updated definition from the dictionary: link

Categories: cartesian, cylindrical, polar and articulated.

Production line for silicone injection with workers: link

This is how a Tesla is manufactured today: link


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

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


Light sensor


Active Infrared sensor


Active ultrasonic sensor 


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

Behavior examples

And there was light…

Stay on the table!

Watch out!

Light follower

Line following

Obstacle avoiding

Coded in class

Code for Ultrasonic Ranger


Slides for week #2: link



Week 1

Robots – – – so cool !

Image from pixabay.com

Astronauts – Image from pixabay.com

Drones - Courtesy from pixabay.com

Drones – Image from pixabay.com

Doctor & colleague - Image from Pixabay.com

Doctor & colleague – Image from Pixabay.com

What is a robot?

Robot? - Courtesy from freeimages.com

Courtesy from freeimages.com


First developments opening the path to robotics were self operating machines, called automaton. They opened the door to more complex systems, with a quick evolution from remote controlled systems to analog neural robots to digitally programmable robots.

The word ‘robot’ was first used to denote a fictional humanoid in a 1921 play R.U.R. by the Czech writer, Karel Čapek. During the play, robots reduce cost of manufacturing to one fifth of what it used to be and it triggers a sequence of apocalyptic events.

Čapek and Rossumovi Univerzální Roboti - Image from Wikipedia

Rossumovi Univerzální Roboti – Image from Wikipedia


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.

There are 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.

State of the art

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. You are encouraged to use the Arduino Reference.


We will be using the Arduino UNO board, that has been heavily modified for it’s use in robotics by adding a motor driver. 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

We can operate our robots with alkaline batteries. But lithium based 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.


Sample code

GitHub link with one code example OR


Test your board first, blinking an LED would be enough

If the motors move in some random direction, try the following:

– strip out the code to make it only move forward, nothing else
– take out the wires of M3 and M4
– the robot would be spinning still, invert the wires of M1 and see the result
With that working, add the back function and turn. Later add motors M3 and M4.