Sensors and Sensing Motors, Encoders and Motor Control

Similar documents
Sensors and Sensing Motors, Encoders and Motor Control

CIS009-2, Mechatronics Signals & Motors

Robot Actuators. Motors and Control. Stepper Motor Basics. Increased Resolution. Stepper motors. DC motors AC motors. Physics review: Nature is lazy.

Lab Exercise 9: Stepper and Servo Motors

Computer Numeric Control

Assembly Language. Topic 14 Motion Control. Stepper and Servo Motors

Page ENSC387 - Introduction to Electro-Mechanical Sensors and Actuators: Simon Fraser University Engineering Science

Step vs. Servo Selecting the Best

Administrative Notes. DC Motors; Torque and Gearing; Encoders; Motor Control. Today. Early DC Motors. Friday 1pm: Communications lecture

L E C T U R E R, E L E C T R I C A L A N D M I C R O E L E C T R O N I C E N G I N E E R I N G

2.017 DESIGN OF ELECTROMECHANICAL ROBOTIC SYSTEMS Fall 2009 Lab 4: Motor Control. October 5, 2009 Dr. Harrison H. Chin

Experiment Of Speed Control for an Electric Trishaw Based on PID Control Algorithm

DC motor control using arduino

combine regular DC-motors with a gear-box and an encoder/potentiometer to form a position control loop can only assume a limited range of angular

MICROCONTROLLERS Stepper motor control with Sequential Logic Circuits

ME375 Lab Project. Bradley Boane & Jeremy Bourque April 25, 2018

Elements of Haptic Interfaces

Comparative Study of PID and Fuzzy Controllers for Speed Control of DC Motor

Basic NC and CNC. Dr. J. Ramkumar Professor, Department of Mechanical Engineering Micro machining Lab, I.I.T. Kanpur

MAE106 Laboratory Exercises Lab # 5 - PD Control of DC motor position

Teaching Mechanical Students to Build and Analyze Motor Controllers

Design of stepper motor position control system based on DSP. Guan Fang Liu a, Hua Wei Li b

Penn State Erie, The Behrend College School of Engineering

Based on the ARM and PID Control Free Pendulum Balance System

Upgrading from Stepper to Servo

Technical Cognitive Systems

7 Lab: Motor control for orientation and angular speed

Sensors and Sensing Force, Torque, Tactile and Olfaction

Mechatronics Engineering and Automation Faculty of Engineering, Ain Shams University MCT-151, Spring 2015 Lab-4: Electric Actuators

ACTUATORS AND SENSORS. Joint actuating system. Servomotors. Sensors

Feedback Devices. By John Mazurkiewicz. Baldor Electric

ServoStep technology

Sensors and Sensing Force, Torque, Tactile and Olfaction

EE 308 Spring Preparation for Final Lab Project Simple Motor Control. Motor Control

Automatic Control Systems 2017 Spring Semester

Introduction to Robotics

Introduction to BLDC Motor Control Using Freescale MCU. Tom Wang Segment Biz. Dev. Manager Avnet Electronics Marketing Asia

EasyMotion User s Manual Ver

Actuators. EECS461, Lecture 5, updated September 16,

Latest Control Technology in Inverters and Servo Systems

Lock Cracker S. Lust, E. Skjel, R. LeBlanc, C. Kim

Motomatic Servo Control

Job Sheet 2 Servo Control

Engineering Reference

Brushed DC Motor Microcontroller PWM Speed Control with Optical Encoder and H-Bridge

ANGULAR POSITION CONTROL OF DC MOTOR USING SHORTEST PATH ALGORITHM

A Searching Analyses for Best PID Tuning Method for CNC Servo Drive

The Discussion of this exercise covers the following points: Angular position control block diagram and fundamentals. Power amplifier 0.

DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING BANGLADESH UNIVERSITY OF ENGINEERING & TECHNOLOGY EEE 402 : CONTROL SYSTEMS SESSIONAL

Design of double loop-locked system for brush-less DC motor based on DSP

EE152 Final Project Report

Glossary. Glossary Engineering Reference. 35

Lab 11. Speed Control of a D.C. motor. Motor Characterization

CSE 3215 Embedded Systems Laboratory Lab 5 Digital Control System

Chapter 7: The motors of the robot

Draw the symbol and state the applications of : 1) Push button switch 2) 3) Solenoid valve 4) Limit switch ( 1m each) Ans: 1) Push Button

Position Sensors. The Potentiometer.

Sensors and Actuators

PYKC 7 March 2019 EA2.3 Electronics 2 Lecture 18-1

PART 2 - ACTUATORS. 6.0 Stepper Motors. 6.1 Principle of Operation

Introduction to Servo Control & PID Tuning

Shaft encoders are digital transducers that are used for measuring angular displacements and angular velocities.

Lab 5: Inverted Pendulum PID Control

Time Response Analysis of a DC Motor Speed Control with PI and Fuzzy Logic Using LAB View Compact RIO

Position and Velocity Sensors

9/28/2010. Chapter , The McGraw-Hill Companies, Inc.

A COMPARISON STUDY OF THE COMMUTATION METHODS FOR THE THREE-PHASE PERMANENT MAGNET BRUSHLESS DC MOTOR

SRV02-Series Rotary Experiment # 3. Ball & Beam. Student Handout

MEM01: DC-Motor Servomechanism

Software Operational Manual

Effective Teaching Learning Process for PID Controller Based on Experimental Setup with LabVIEW


CS545 Contents XIV. Components of a Robotic System. Signal Processing. Reading Assignment for Next Class

Control Strategies for BLDC Motor

9 Things to Consider When Specifying Servo Motors

Modeling, Simulation and Implementation of Speed Control of DC Motor Using PIC 16F877A

MOBILE ROBOT LOCALIZATION with POSITION CONTROL

UNIVERSITY OF JORDAN Mechatronics Engineering Department Measurements & Control Lab Experiment no.1 DC Servo Motor

DC Motor Speed Control using PID Controllers

Active Vibration Isolation of an Unbalanced Machine Tool Spindle

Rotary Motion Servo Plant: SRV02. Rotary Experiment #02: Position Control. SRV02 Position Control using QuaRC. Student Manual

BLuAC5 Brushless Universal Servo Amplifier

Motor control using FPGA

DESIGN OF A TWO DIMENSIONAL MICROPROCESSOR BASED PARABOLIC ANTENNA CONTROLLER

Application Note Using MagAlpha Devices to Replace Optical Encoders

Embedded Systems Lab Lab 7 Stepper Motor Application

Programming PIC Microchips

Getting Started Sizing & Selecting Servos: Understanding the need for a system solution

LSM&DSD Brushless Servo Drive Package

Motion Control Glossary

Experiment 9. PID Controller

Where: (J LM ) is the load inertia referred to the motor shaft. 8.0 CONSIDERATIONS FOR THE CONTROL OF DC MICROMOTORS. 8.

Automobile Prototype Servo Control

ME 461 Laboratory #5 Characterization and Control of PMDC Motors

MODEL BASED DESIGN OF PID CONTROLLER FOR BLDC MOTOR WITH IMPLEMENTATION OF EMBEDDED ARDUINO MEGA CONTROLLER

Categories of Robots and their Hardware Components. Click to add Text Martin Jagersand

BLuAC5 Brushless Universal Servo Amplifier

Lab 23 Microcomputer-Based Motor Controller

CHAPTER 4 CONTROL ALGORITHM FOR PROPOSED H-BRIDGE MULTILEVEL INVERTER

Basic Tuning for the SERVOSTAR 400/600

Transcription:

Sensors and Sensing Motors, Encoders and Motor Control Todor Stoyanov Mobile Robotics and Olfaction Lab Center for Applied Autonomous Sensor Systems Örebro University, Sweden todor.stoyanov@oru.se 05.11.2015 T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 1 / 27

Outline 1 Motors 2 Encoders 3 Motor Control 4 Embedded Control 5 Practice: Arduino T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 2 / 27

Motors Outline 1 Motors 2 Encoders 3 Motor Control 4 Embedded Control 5 Practice: Arduino T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 2 / 27

Motors Motor Basics A motor is a device which transforms input energy into kinetic energy. Input energy could be chemical (e.g. gasoline engine), but we are interested in electro-magnetic motors. First electric motors were invented in the 19th century. Hungarian physicist Ányos Jedlik demonstrated the first electric motor. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 2 / 27

Motors Motor Basics A motor is a device which transforms input energy into kinetic energy. Input energy could be chemical (e.g. gasoline engine), but we are interested in electro-magnetic motors. First electric motors were invented in the 19th century. Hungarian physicist Ányos Jedlik demonstrated the first electric motor. Figure : Image source: wikipedia T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 2 / 27

Motors Brush Motors Brush motors were the predominant type of motor until the 1960s. The design includes three key components: the stator, the rotor and the commutator. Stator is typically implemented as a permanent magnet. Rotors are coils which act as magnets when electricity flows through them. The commutator is a mechanical device used for switching the direction of electric current. S + - N T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 3 / 27

Motors Brush Motors Brush motors were the predominant type of motor until the 1960s. The design includes three key components: the stator, the rotor and the commutator. Stator is typically implemented as a permanent magnet. Rotors are coils which act as magnets when electricity flows through them. The commutator is a mechanical device used for switching the direction of electric current. S + - N T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 3 / 27

Motors Brush Motors Brush motors were the predominant type of motor until the 1960s. The design includes three key components: the stator, the rotor and the commutator. Stator is typically implemented as a permanent magnet. Rotors are coils which act as magnets when electricity flows through them. The commutator is a mechanical device used for switching the direction of electric current. S + - N T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 3 / 27

Motors Brushless Motors Brush motors have a major disadvantage: the mechanical components wear off and generate sparks. Digital logic circuits invented in the 60s allowed for brushless commutator designs. Typical brushless motors use a smaller and lighter permanent magnet, suspended in a magnetic field generated by static coils. The commutator is typically implemented using semiconductor elements. switch logic + - T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 4 / 27

Motors Brushless Motors Brush motors have a major disadvantage: the mechanical components wear off and generate sparks. Digital logic circuits invented in the 60s allowed for brushless commutator designs. Typical brushless motors use a smaller and lighter permanent magnet, suspended in a magnetic field generated by static coils. The commutator is typically implemented using semiconductor elements. switch logic + - T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 4 / 27

Motors Brushless Motors Brush motors have a major disadvantage: the mechanical components wear off and generate sparks. Digital logic circuits invented in the 60s allowed for brushless commutator designs. Typical brushless motors use a smaller and lighter permanent magnet, suspended in a magnetic field generated by static coils. The commutator is typically implemented using semiconductor elements. switch logic + - T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 4 / 27

Stepper Motors and Servos Motors Motors in robotics and automation applications often have to be actuated to achieve particular rotational increments. Most popular designs for this application are stepper motors and servos. Stepper motors are brushless motors with a cogwheel-like tooth design. By using a higher number of stators, stepper motors can be commanded to actuate one tooth at a time and can achieve and hold desired number of rotational ticks. Servos are typically implemented as a brushless motor, coupled with a rotary encoder and a microcontroller. We will discuss servos more in the lab. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 5 / 27

Stepper Motors and Servos Motors Motors in robotics and automation applications often have to be actuated to achieve particular rotational increments. Most popular designs for this application are stepper motors and servos. Stepper motors are brushless motors with a cogwheel-like tooth design. By using a higher number of stators, stepper motors can be commanded to actuate one tooth at a time and can achieve and hold desired number of rotational ticks. Servos are typically implemented as a brushless motor, coupled with a rotary encoder and a microcontroller. We will discuss servos more in the lab. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 5 / 27

Stepper Motors and Servos Motors Motors in robotics and automation applications often have to be actuated to achieve particular rotational increments. Most popular designs for this application are stepper motors and servos. Stepper motors are brushless motors with a cogwheel-like tooth design. By using a higher number of stators, stepper motors can be commanded to actuate one tooth at a time and can achieve and hold desired number of rotational ticks. Servos are typically implemented as a brushless motor, coupled with a rotary encoder and a microcontroller. We will discuss servos more in the lab. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 5 / 27

Motors Actuating Motors: Pulse Width Modulation DC motors are actuated with a fixed input voltage. In order to move slower or faster, we could change the set input voltage (between 0 and V max ) In digital circuits it is typically easier to use pulse width modulation to achieve control values. Wider pulses integrate to larger area under the curve and longer duty cycles. This is also safer for the motor. 30% 50% T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 6 / 27

Motors Torque, RPM and Gears In some applications the motor output is directly linked to the driven mechanical system (direct drive). However, it is also common to drive output through a system of gears. Given two gears A and B with radius r a and r b, the contact point moves at the same tangetial speed: v = r a ω a = r b ω b The number of teeth on each gear n a and n b is proportional to the circomference, and thus to the radius of the gear. Therefore: ω a = n b ω b n a Conversely, the exertable torques τ a and τ b are proportional to the arm lengths r a,r b, and thus: τ b = n b τ a n a T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 7 / 27

Motors Torque, RPM and Gears A high input to output gear ratio (n a > n b ) reduces the exerted torque and increases the angular velocity. More commonly, gear trains with a higher number of output teeth are used and the gear ratio is reported as n b : 1. Gear systems are characterized also by: efficiency: the ratio of useful torque transmitted (some torque is always lost due to friction and inertia) backclash: how much the output shaft can be rotated back before the input shaft moves backdrivability: can rotations on the output shaft drive back the motor. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 7 / 27

Motors Motor Data Sheets Parameters of motors to check when designing your application: Operating voltage Maximum load current Maximum short-term current Maximum torque Maximum rpm Gear ratio T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 8 / 27

Encoders Outline 1 Motors 2 Encoders 3 Motor Control 4 Embedded Control 5 Practice: Arduino T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 9 / 27

Encoders Encoder Basics The rotary encoder is one of the basic sensors in robotics A rotary encoder is typically mounted on a motor shaft or gear output shaft and used to count the numbers (and fractions) of rotation. Encoder output is typically used as feedback for motor control in servo systems. Wheel encoder readings are used in vehicle kinematic models to deduce the relative position and orientation of mobile robots (odometry). T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 9 / 27

Encoders Potentiometers A potentiometer consists of a resistor and a movable contact element. When the contact element moves, it divides the resistor in to two resistance elements R 1 and R 2. The terminals are connected over a load resistor R L and the voltage over R L is calculated as V L = R 1 R 1 +R 2 V in This is a typical voltage divider circuit. Knowing V in and R 1 + R 2, we can deduce the position of the contact element from the measured voltage V L. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 10 / 27

Encoders Optical Encoders: Incremental Potentiometers don t allow for continuous rotation. Optical encoders can provide continuous rotation measurements using light sensitive elements and an encoded disk. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 11 / 27

Encoders Optical Encoders: Incremental Incremental optical encoders use one disk with equally spaced black lines to generate multiple signal pulses. A second disk is added at a 90 o phase offset to add for direction variance. light source detector light source detector T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 11 / 27

Encoders Optical Encoders: Incremental Incremental optical encoders use one disk with equally spaced black lines to generate multiple signal pulses. A second disk is added at a 90 o phase offset to add for direction variance. light source detector light source detector A B T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 11 / 27

Encoders Optical Encoders: Incremental Incremental optical encoders use one disk with equally spaced black lines to generate multiple signal pulses. A second disk is added at a 90 o phase offset to add for direction variance. light source detector light source detector A B T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 11 / 27

Encoders Optical Encoders: Absolute Absolute encoders solve the problem of initialization errors in incremental encoders. Each tick of the encoder has a unique optical bit word. With gray codes neighboring words have only 1 different bit, adding robustness to measurement error. 10100000 T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 12 / 27

Encoders Optical Encoders: Absolute Absolute encoders solve the problem of initialization errors in incremental encoders. Each tick of the encoder has a unique optical bit word. With gray codes neighboring words have only 1 different bit, adding robustness to measurement error. 01100000 10100000 T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 12 / 27

Encoders Optical Encoders: Absolute Absolute encoders solve the problem of initialization errors in incremental encoders. Each tick of the encoder has a unique optical bit word. With gray codes neighboring words have only 1 different bit, adding robustness to measurement error. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 12 / 27

Encoders Magnetic Encoders Sensors based on magnetic field strength can also be used to implement rotary encoders. Typical magnetic encoders use the Hall effect which produces voltage potential proportional to the proximity of a magnet. A small disc permanent magnet is fixed on the rotating shaft, while four hall sensors provide 360 degree sensitivity. + - T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 13 / 27

Encoders Magnetic Encoders Sensors based on magnetic field strength can also be used to implement rotary encoders. Typical magnetic encoders use the Hall effect which produces voltage potential proportional to the proximity of a magnet. A small disc permanent magnet is fixed on the rotating shaft, while four hall sensors provide 360 degree sensitivity. + + - + - + + - + + - - - Hall voltage + - T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 13 / 27

Encoders Magnetic Encoders Sensors based on magnetic field strength can also be used to implement rotary encoders. Typical magnetic encoders use the Hall effect which produces voltage potential proportional to the proximity of a magnet. A small disc permanent magnet is fixed on the rotating shaft, while four hall sensors provide 360 degree sensitivity. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 13 / 27

Encoders Interfacing Encoders Encoders are often packaged with their own microcontrollers for low-level logic. Reading encoder measurements from those is device-dependent and follows manufacturer-defined protocols. Occasionally, you may need to read encoder ticks directly in your microcontroller code. The encoder square waves are often tied to interrupts on the microprocessor. Once an interrupt is triggered, you may need to check other input pins to determine direction of the wave, before updating encoder positions incrementally. You will get some practical experience with this in the lab. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 14 / 27

Motor Control Outline 1 Motors 2 Encoders 3 Motor Control 4 Embedded Control 5 Practice: Arduino T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 15 / 27

Motor Control Open-loop Motor Actuation Open loop control is generally a very bad idea in precision applications It may however make sense if you just need to move for a pre-defined time at a pre-defined rate: just set the motor duty cycle to a specific value and hope for the best Motor control however implies you need to have some more sophisticated feedback: usually in terms of encoder ticks, but also load current, force or torque sensors. The most common control framework for simple motor control is the PID controller. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 15 / 27

control action measured signal Motor Control PID Control The Proportional Integral Derivative (PID) control framework scales control outputs in accordance with the error, it s derivative and integral. Motor model predicted setpoint error Given a function, which generates set point values r(t), the objective of the controller is to produce control actions u(t), such that the error e(t) = y(t) r(t) is minimized. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 16 / 27

Motor Control PID Control Proportional term: The proportional term applies a control, directly proportional to the current error e(t) The control action is then u(t) = K p e(t) Pure P-control suffers from overshoots and oscillations around the steady state, as well Amplitude 1.4 1.2 1 0.8 0.6 0.4 0.2 Step Response Kp=100 Kp=200 Kp=400 0 as steady state errors. 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 Time (seconds) T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 16 / 27

Motor Control PID Control Derivative term: The derivative term applies controls, proportional to the derivative of the error. The derivative control action is then u(t) = K d d dt e(t). Derivative terms dampen oscillations and act to smoothen the system behavior. Typically, used in combination with a P-term. Amplitude 1.4 1.2 1 0.8 0.6 0.4 0.2 Step Response Kd=10 Kd=20 Kd=40 0 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 Time (seconds) T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 16 / 27

Motor Control PID Control Integral term: The integral term applies a control, proportional to the sum of all previous errors. The integral control action is then u(t) = K i t 0 e(t)dt. Integral terms decrease the steady state error, as they accumulate even small errors over time to generate high enough controls. Typically used in combination with a P-term. Amplitude 1.5 1 0.5 Step Response Ki=100 Ki=200 Ki=400 0 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 Time (seconds) T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 16 / 27

Motor Control PID Control Step Response 1 Kp=400, Ki=500, Kd=40 0.9 0.8 0.7 Amplitude 0.6 0.5 0.4 0.3 0.2 0.1 0 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 Time (seconds) The full PID equation is then: u(t) = K p e(t) + K i t 0 d e(t)dt + K d e(t) (1) dt T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 16 / 27

Motor Control Tuning of PID Gains Parameter Rise time Overshoot Settling time Steady-state error K p Decrease Increase Small change Decrease K i Decrease Increase Increase Eliminate K d Small change Decrease Decrease No effect Start by tuning K p. Increase until you see steady state oscillations. Add a K d term to decrease overshoot. If there is a steady state error, add a small K i to eliminate it. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 17 / 27

Motor Control Common Modes of Motor Control Position control: use an encoder after the gears to feedback the position for control. Velocity control: use the first time derivative of the encoder position as a control variable. Current control: use the electrical current absorption for control. Force/Torque control: couple the motor with a force or torque sensor and use the output in control space. Common mode for achieving compliance. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 18 / 27

Motor Control Generating smooth motion It is often desireable to generate a smooth trajectory for the driven system (manipulator or wheeled base). Given the position of a motor x(t) (offset from a reference angle in radians) Non-smooth x(t) may require an infinite velocity x (t) = d dt x(t) Similarly, the velocity needs to be smooth, or else we risk infinite acceleration x (t) Ideally, we want a smoothly varying acceleration profile, thus we want to minimize the integral of the jerk x (t) over the motion. Theoretically[1], this occurs when the sixth derivative of x(t) vanishes. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 19 / 27

Motor Control Generating smooth motion We represent x(t) as a fifth order polynomial: With derivatives: x(t) = a 0 + a 1 t + a 2 t 2 + a 3 t 3 + a 4 t 4 + a 5 t 5 (2) x (t) = a 1 + 2a 2 t + 3a 3 t 2 + 4a 4 t 3 + 5a 5 t 4 (3) x (t) = 2a 2 + 6a 3 t + 12a 4 t 2 + 20a 5 t 3 (4) Assuming we start at rest at 0 and want to finish at rest at d in time τ, we know the boundary conditions: x(0) = 0, x(τ) = d (5) x (0) = 0, x (τ) = 0 (6) x (0) = 0, x (τ) = 0 (7) T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 20 / 27

Motor Control Generating smooth motion This leaves us with 6 equations for 6 unknowns, with the solution: ( ( t ) 3 ( t ) 4 ( t ) 5 ) x(t) = d 10 15 + 6 τ τ τ (8) Why minimum jerk? -> keeps the maximum velocity and acceleration within reasonable bounds. In practice, reduces the size of the step sent to the PID controllers. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 21 / 27

Embedded Control Outline 1 Motors 2 Encoders 3 Motor Control 4 Embedded Control 5 Practice: Arduino T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 22 / 27

Embedded Control Microcontrollers Control of actuators is usually implemented on dedicated embedded devices. A microcontroller is essentially a single integrated circuit that provides a processor core, a memory array and input/output operations. Microcontrolers packaged on a printed circuit board with additional ICs and dedicated programming environments are often used used for convenience. Figure : Arduino Due microcontroller board T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 22 / 27

Embedded Control Digital I/O Microcontroller boards like the Arduino have a number of PINs that can be configured for input or output operations Pins for digital I/O can read/write logic values - high or low High values represent a fixed voltage potential relative to the digital ground Low values have zero potential relative to ground When using digital I/O the logic ground for target devices has to be set to the ground terminal of the board. Example applications: reading in binary streams from sensors, detecting switches T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 23 / 27

Embedded Control Analogue I/O Analogue input pins can be configured to measure voltage potentials relative to ground level. Analogue output pins produce a pulse-width modulated (PWM) square wave signal. Depending on the board, the PWM duty cycle and/or the frequency can be modified. Example applications: measuring values from a current sensor, driving a motor. 30% 50% T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 24 / 27

Embedded Control Programming Tips Programming for embedded devices can be tricky. Code needs to be cross-compiled for the controller and then uploaded to the on-board flash memory. Debugging can be difficult as outputs come on the serial port and programs cannot be paused. A useful tool for real-time processing are interrupts, which can trigger code pieces when the states of I/O pins change. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 25 / 27

Practice: Arduino Outline 1 Motors 2 Encoders 3 Motor Control 4 Embedded Control 5 Practice: Arduino T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 26 / 27

Practice: Arduino Sample questions True/False questions: a: An array of four hall effect sensors can be used to implement a magnetic shaft encoder. b: Increasing the D term of a PID controller sharply reduces the rise time. c: Incremental encoders can be coupled with a control algorithm and a motor to create a servo motor drive. d: Increasing the I term of a PID controller can lead to steady state oscillations. e: Absolute optical encoders suffer from the initialization errors effect. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 26 / 27

Practice: Arduino Sample questions Derive / Design a: Draw a diagram to explain how PID control works. Include the equations for computing the control u based on the PID gains and the error e. (3 points) b: You are designing a velocity controller for a motor with an encoder. Given a setpoint velocity v, how would a PID controller look like? Provide equations for computing the control u. (Hint: you need to use the cycle time dt between updates to compute the current velocity) (4 points) c: Given a k p = 5.5, k i = 0 and k d = 2. Your previous measured encoder positions were q t 2 = 310 and q t 1 = 350 ticks, your current position is q t = 380 and your cycle time d t = 0.01 seconds. If your set point velocity is v = 2000 ticks per second, what would be the output u of your controller? T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 26 / 27

Practice Session Task Practice: Arduino For this task we will do some basic Arduino programming. Setup the arduino environment and try out the Blink sketch. You can follow the instructions from the Lab exercise for this part. Download the data sheet for the ELS-505GWA display. Your task is to make a countdown timer, which displays numbers from 9 down to 0, changing every second. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 27 / 27

Practice: Arduino References [1] Neville Hogan. An organizing principle for a class of voluntary movements. The Journal of Neuroscience, 4(11):2745 2754, 1984. T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 27 / 27

Practice: Arduino Sensors and Sensing Motors, Encoders and Motor Control Todor Stoyanov Mobile Robotics and Olfaction Lab Center for Applied Autonomous Sensor Systems Örebro University, Sweden todor.stoyanov@oru.se 05.11.2015 T. Stoyanov (MRO Lab, AASS) Sensors & Sensing 05.11.2015 27 / 27