TI-RSLK. Texas Instruments Robotics System Learning Kit

Similar documents
LM5022 Isolated Flyback Converter

DSS Bit Exact Output. Application Report. 1 Display Subsystem (DSS) Overview. Prasad Konnur, Sivaraj R, Brijesh Jadav

CC13x0 Low Data Rate Operation

Bootstrap Circuitry Selection for Half-Bridge Configurations

TI Designs: TIDA Power Supply Reference Design for Automotive Microcontroller in Gateway and Body Control Module

TI Designs: TIDA Mono Color LED Matrix With Fast Refresh Rates and Ghosting Reduction Reference Design

TLK10081 EVM Quick Start Guide Texas Instruments Communications Interface Products

The photograph below shows the PMP9730 Rev E prototype assembly. This circuit was built on a PMP9730 Rev D PCB.

1 Photo. 7/15/2014 PMP10283 Rev A Test Results

AM43xx EMIF Tools. Application Report. Trademarks. Siva Kothamasu

TIDA V Stepper Motor Controller with Integrated Current Sense Reference Design

Single Cell Battery Power Solution

Test Report PMP Test Data For PMP /20/2015

A System Evaluation of CAN Transceivers

TIDA Test Report

The photographs below show the top and bottom view of the PMP11282Rev A board, which is built on PMP11064 Rev B PCB. Top Side

ESD Protection Layout Guide

TIDA Test Report

Systems ATE report. All output measurements are taken with 1uF and a 0.1uF MLCC across the DUT output.

Introduction to USB Type-C & Power Delivery

Clock and Timing Solutions

Achieve Bidirectional Control and Protection Through Back-to-Back Connected efuse Devices

Jump Start Upgrading Your Digital Cluster Design with Jacinto TM 6 Platform

TIDA DS125BR820 40GbE/10GbE QSFP Reference Design User s Guide

Error Detection in SRAM

RTOS power management: Essential for connected MCU-based IoT nodes

PMP11140 TPS40400 / CSD85301Q2 Test Report 12V to 1.8V 3A / 4A Texas Instruments

INCLUDING MEDICAL ADVICE DISCLAIMER

IndoTraq Development Kit 1: Command Reference

LOW VOLTAGE 16-BIT I 2 C I/O EXPANDER WITH INTERRUPT AND RESET

FUNCTION TABLE (each buffer/driver) INPUTS OUTPUT L H H L L L H X Z POST OFFICE BOX DALLAS, TEXAS 75265

Terms of Use. Changes. General Use.

Mile Terms of Use. Effective Date: February, Version 1.1 Feb 2018 [ Mile ] Mileico.com

8.7. Finite state machines with statically-allocated linked structures Stepper motor controller L 293

Stereo Dac Motherboard application information

Footprint Comment LibRef Designator Description Quantity C1, C2, C3, C5, C6, C7, C8, 0603C Cap Cap. C9, C11, C16, C17, C18, C19, Capacitor 17

FPC202 Dual Port Controller With Expanded I/Os

HYCU SCOM Management Pack for F5 BIG-IP

MyCreditChain Terms of Use

SAM4 Reset Controller (RSTC)

Link Replicator for Fibre Channel, Gigabit Ethernet, and HDTV Data Rates Check for Samples: SN65LVCP15

AT03262: SAM D/R/L/C System Pin Multiplexer (SYSTEM PINMUX) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

1.5 C ACCURATE DIGITAL TEMPERATURE SENSOR WITH SPI INTERFACE

Ecma International Policy on Submission, Inclusion and Licensing of Software

Embedded processor security What s at stake? Where to start?

Stacking the REF50xx for High-Voltage References

DATASHEET 4D SYSTEMS. 4D Raspberry Pi Serial Adaptor TURNING TECHNOLOGY INTO ART. 4D-Serial-Pi-Adaptor

DATASHEET 4D SYSTEMS. 4D Arduino Adaptor Shield TURNING TECHNOLOGY INTO ART. 4Display-Adaptor-Shield

Workshop 4 Installation INSTALL GUIDE. Document Date: February 4 th, Document Revision: 1.1

DATASHEET 4D SYSTEMS. 4D Raspberry Pi Serial Adaptor TURNING TECHNOLOGY INTO ART. 4D-Serial-Pi-Adaptor

TERMS & CONDITIONS. Complied with GDPR rules and regulation CONDITIONS OF USE PROPRIETARY RIGHTS AND ACCEPTABLE USE OF CONTENT

The Travel Tree Terms and Conditions

OCTOSHAPE SDK AND CLIENT LICENSE AGREEMENT (SCLA)

SN64BCT757 OCTAL BUFFER/DRIVER WITH OPEN-COLLECTOR OUTPUTS

Entrust WAP Server Certificate Relying Party Agreement

CMSIS DAP Setup. Document Version History Document Version ngxtechnologies.com 2

DATASHEET 4D SYSTEMS. 4D Raspberry Pi Serial Adaptor TURNING TECHNOLOGY INTO ART. 4D-Serial-Pi-Adaptor

RE866 Interface User Guide

LMR14050 LMZ20502 LMZ20502

HSKT TM Technology Specifications

Recommended Pick & Place Tools (Nozzles) for LEDs of OSRAM Opto Semiconductors Application Note

Wolverine - based microcontrollers. Slashing all MCU power consumption in half

Ecma International Policy on Submission, Inclusion and Licensing of Software

Using LPC11Axx EEPROM (with IAP)

icelynx-micro IEEE 1394a-2000 Consumer Electronics Solution

Bar Code Discovery. Administrator's Guide

Funding University Inc. Terms of Service

Class Composer General Terms of Use

Protecting the TPS25810 from High Voltage DFPs

ESS Utility Android App User Guide

Debugging Shared Memory Systems

TERMS OF SERVICE AGREEMENT

End User License Agreement

MERIDIANSOUNDINGBOARD.COM TERMS AND CONDITIONS

October 2002 PMP Portable Power SLVU074

Techniques for Profiling on ROM-Based Applications

AT&T Release Notes. Enhanced Web Real-Time Communication (WebRTC) API. Publication Date: August 2015

LOGO LICENSE AGREEMENT(S) CERTIPORT AND IC³

IETF TRUST. Legal Provisions Relating to IETF Documents. February 12, Effective Date: February 15, 2009

Winnebago Industries, Inc. Privacy Policy

SUPPORT MATRIX. Comtrade OMi Management Pack for Citrix

Moore FSM & State Table. Lecture 4 Supplemental Material. Assembly Implementation of Traffic Light Controller

CALSTRS ONLINE AGREEMENT TERMS AND CONDITIONS

IETF TRUST. Legal Provisions Relating to IETF Documents. Approved November 6, Effective Date: November 10, 2008

Beta Testing Licence Agreement

QPP Proprietary Profile Guide

Entrust SSL Web Server Certificate Subscription Agreement

Oracle Binary Code License Agreement for Java Secure Sockets Extension for Connected Device Configuration 1.0.2

COUNT RefDes Value Description Size Part Number MFR

AT11512: SAM L Brown Out Detector (BOD) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

February 2003 PMP EVMs SLVU081

Z.com Hosting Service Order

SDLC INTELLECTUAL PROPERTY POLICY

CAUTION This device is sensitive to ElectroStatic Discharge (ESD). Therefore care should be taken during transport and handling.

APPLICATION NOTE. AT05567: TC Capture on External Interrupt with the Event System on SAM D20. Preface ASF PROJECT DOCUMENTATION

HV Solar MPPT DC-DC GUI Overview. Getting Started Guide

EZ430-C9. Getting Started with Kionix EZ430-C9 Evaluation Board for the Texas Instruments MSP430 USB Stick Development Tool

AT10942: SAM Configurable Custom Logic (CCL) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

Terminal I/O Profile Client Implementation Guide

Terms Of Use AGREEMENT BETWEEN USER AND DRAKE MODIFICATION OF THESE TERMS OF USE LINKS TO THIRD PARTY WEB SITES USE OF COOKIES

Transcription:

TI-RSLK Texas Instruments Robotics System Learning Kit

Module 7 Lecture: Finite State Machines -Theory 1 Finite State Machines - Theory SWRP161

Finite State Machines - Theory You will learn in this module C programming fundamentals Arrays Pointers Structures Time delays Develop debugging techniques such as Watch windows Breakpoints Heart beats Solve problems with finite state machines States, tables, graphs, input, outputs Mealy versus Moore Design controller for a line tracking robot Traffic light controller Line-following robot 2 Finite State Machines - Theory SWRP161

Abstraction Software abstraction: Define a problem Minimal set of basic concepts Abstract principles / processes Separation of policy and mechanisms Interfaces define what it does (policy) Implementations define how it works (mechanisms) Straightforward, mechanical path to implementation Finite State Machine Rules 1. Simple structure: Input->Process->Output 2. Information is encoded by being in a state. 3. FSM controllers are very simple: e.g., output, wait, input, go to next state. 4. Complexity is captured in the state graph 5. There is a 1-1 mapping between state graph and the software implementation Three advantages of abstraction are: Faster to develop Easier to debug (prove correct) and Easier to change 3 Finite State Machines - Theory SWRP161

Finite State Machine (FSM) What is a Finite State Machine? Set of inputs, outputs, states and transitions State graph defines input/output relationship What is a state? Description of current conditions What you believe to be true What is a state transition graph (or table)? Graphical interconnection between states What is a controller? Software that inputs, outputs, changes state Accesses the state graph 4 Finite State Machines - Theory SWRP161

Finite State Machine (FSM) What is a Finite State Machine (FSM)? Inputs (sensors) Outputs (actuators) Controller State transition graph Controller loop 1. Output 2. Wait 3. Input 4. Next 5 Finite State Machines - Theory SWRP161

Traffic Light Controller State Transition Graph (STG) State Transition Table (STT) State \ Input 00 01 10 11 gon (100001,30) gon waitn gon waitn waitn (100010,5) goe goe goe goe goe (001100,30) goe goe waite waite waite (010100,5) gon gon gon gon 6 Finite State Machines - Theory SWRP161

FSM Data Structure in C (Index into array) const struct State { uint32_t Out; // 6-bit output uint32_t Time; // 1 ms units uint32_t Next[4]; // list of next states }; typedef const struct State State_t; #define gon 0 #define waitn 1 #define goe 2 #define waite 3 State_t FSM[4] = { {0x21, 30000, {gon,waitn,gon,waitn}}, {0x22, 5000, {goe,goe,goe,goe}}, {0x0C, 30000, {goe,goe,waite,waite}}, {0x14, 5000, {gon,gon,gon,gon}} }; 7 Finite State Machines - Theory SWRP161

FSM Engine in C (Index into array) void main(void) { uint32_t cs; // index of current state uint32_t input; // car sensor input Traffic_Init(); // initialize ports and timer cs = gon; // initial state while(1){ // 1) set lights to current state's Out P4->OUT = (P4->OUT&~0x3F) (FSM[cs].Out); // 2) specified wait for this state Clock_Delay1ms(FSM[cs].Time); // 3) input from car detectors input = (P5->IN&0x03); // 4) next depends on state and input cs = FSM[cs].Next[input]; } } Friendly 9 SysTick Mask 8 Finite State Machines - Theory SWRP161

FSM Data Structure in C (Pointer) const struct State { uint32_t Out; // 6-bit output uint32_t Time; // 1 ms units const struct State *Next[4]; // next states }; typedef const struct State State_t; #define gon &FSM[0] #define waitn &FSM[1] #define goe &FSM[2] #define waite &FSM[3] State_t FSM[4] = { {0x21,30000,{goN,waitN,goN,waitN}}, {0x22, 5000,{goE,goE,goE,goE}}, {0x0C,30000,{goE,goE,waitE,waitE}}, {0x14, 5000,{goN,goN,goN,goN}} }; 9 Finite State Machines - Theory SWRP161

FSM Engine in C (Pointer) void main(void) { State_t *pt; // pointer to current state uint32_t input; // car sensor input Traffic_Init(); // initialize ports and timer pt = gon; // initial state while(1){ // 1) set lights to current state's Out P4->OUT = (P4->OUT&~0x3F) (pt->out); // 2) specified wait for this state Clock_Delay1ms(pt->Time); // 3) input from car detectors input = (P5->IN&0x03); // 4) next depends on state and input pt = pt->next[input]; } } Friendly 9 SysTick Mask 10 Finite State Machines - Theory SWRP161

Mealy versus Moore Moore FSM Output value depends on current state Significance is the state Input: when to change state Output: how to be or what to do while in that state Mealy FSM Output value depends on input and current state Significance is the state transition Input: when to change state Output: how to change state Inputs: Car sensors Outputs: Traffic lights Inputs: Control Outputs: Retro, Ignition 11 Finite State Machines - Theory SWRP161

Summary Abstraction Define a problem Concepts / principles / processes Separation of policy and mechanisms Interfaces define what it does (policy) Implementations define how it works (mechanisms) Finite State Machines Inputs (sensors) Outputs (actuators) Controller State graph States Implementations define how it works (mechanisms) 12 Finite State Machines - Theory SWRP161

Module 7 Lecture: Finite State Machines Line Follower 1

Finite State Machine Example You will learn in this lecture Design controller for a line tracking robot Two sensor inputs Two motor outputs 2

Simple Line Tracker Two Sensors 1,1 on line 1,0 off to the right 0,1 off to the left 0,0 lost Two Motors 1,1 go straight 1,0 turn right 0,1 turn left Left, Right Left, Right 3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

Left sensor = 0 22

100% 50% Left sensor = 0 Slow down right wheel 23

100% 50% Left sensor = 0 Slow down right wheel 24

100% 100% Go straight 25

26

27

28

Right sensor = 0 29

50% 100% Slow down left wheel Right sensor = 0 30

50% 100% Slow down left wheel Right sensor = 0 31

Slow down left wheel Right sensor = 0 32

50% 100% Slow down left wheel Right sensor = 0 33

100% 100% Go straight 34

35

States State Motor Center 1,1 Left 0,1 Right 1,0 Motors respond in 100ms, so run FSM every 50ms 36

Simple Line Tracker Two Sensors 1,1 on line 0,1 off to the left 1,0 off to the right 0,0 lost Left, Right 37

State Transition Table State Motor In=0,0 In=0,1 In=1,0 In=1,1 Center 1,1 Center Left 1,0 Center Right 0,1 Center Left 1,0 11 11 Center 1,1 11 Right 0,1 State_t fsm[3]={ {0x03, 1, { Center }}, {0x02, 1, { Center }}, {0x01, 1, { Center }} }; On the line, so go straight 38

State Transition Table State Motor In=0,0 In=0,1 In=1,0 In=1,1 Center 1,1 Left Left 1,0 Center Right 0,1 Left 1,0 01 01 Center 1,1 Right 0,1 State_t fsm[3]={ {0x03, 1, { Left, }}, {0x02, 1, { Center, }}, {0x01, 1, { }} }; Off to left, so toggle right motor, turn right 39

State Transition Table State Motor In=0,0 In=0,1 In=1,0 In=1,1 Center 1,1 Left 1,0 Left Right 0,1 00 Left 1,0 Center 1,1 Right 0,1 State_t fsm[3]={ {0x03, 1, { Center }}, {0x02, 1, { Left, Center }}, {0x01, 1, { Center }} }; Way off to left, so stop right motor, turn right 40

State Transition Table State Motor In=0,0 In=0,1 In=1,0 In=1,1 Center 1,1 Right Left 1,0 Right 0,1 Center State_t fsm[3]={ Left 1,0 Center 1,1 10 10 Right 0,1 {0x03, 1, { Right }}, {0x02, 1, { }}, {0x01, 1, { Center }} }; Off to right, so toggle left motor, turn left 41

State Transition Table State Motor In=0,0 In=0,1 In=1,0 In=1,1 Center 1,1 Left 1,0 Right 0,1 Right Left 1,0 Center 1,1 00 Right 0,1 State_t fsm[3]={ {0x03, 1, { }}, {0x02, 1, { }}, {0x01, 1, { Right, }} }; Way off to right, so stop left motor, turn left 42

State Transition Table State Motor In=0,0 In=0,1 In=1,0 In=1,1 Center 1,1 Right Left 1,0 Right Right 0,1 Left 10 Left 1,0 Center 1,1 00 Right 0,1 01 State_t fsm[3]={ {0x03, 1, { Right, }}, {0x02, 1, { Right }}, {0x01, 1, { Left, }} }; Weird things that shouldn t happen 43

State Transition Table State Motor In=0,0 In=0,1 In=1,0 In=1,1 Center 1,1 Right Left Right Center Left 1,0 Left Center Right Center Right 0,1 Right Left Center Center 10 11 00 11 00 00 01 10 Left 1,0 01 Center 1,1 10 11 Right 0,1 01 State_t fsm[3]={ {0x03, 1, {Right, Left, Right, Center }}, {0x02, 1, {Left, Center, Right, Center }}, {0x01, 1, {Right, Left, Center, Center }} }; Motors respond in 100ms, so run FSM every 10ms 44

45 Robot Implementation struct State { uint32_t out; // 2-bit output uint32_t delay; // time to delay in 1ms const struct State *next[4]; // Next if 2-bit input is 0-3 }; typedef const struct State State_t; #define Center &fsm[0] #define Left &fsm[1] #define Right &fsm[2] State_t fsm[3]={ {0x03, 50, { Right, Left, Right, Center }}, // Center {0x02, 50, { Left, Center, Right, Center }}, // Left {0x01, 50, { Right, Left, Center, Center }} // Right }; State_t *Spt; // pointer to the current state uint32_t Input; // 00=off, 01=right, 10=left, 11=on uint32_t Output; // 3=straight, 2=turn right, 1=turn left int main(void){ Clock_Init48MHz(); Motor_Stop(); // initialize DC motors Spt = Center; while(1){ Output = Spt->out; 13 Timers // set output from FSM Motor_Output(Output); // do output to two motors Clock_Delay1ms(Spt->delay); // wait Input = Reflectance_Center(1000); // read sensors Spt = Spt->next[Input]; // next depends on input and state } } 12 Motors 9 SysTick 6 GPIO

Summary Abstraction Define a problem Concepts / principles / processes Separation of policy and mechanisms Interfaces define what it does (policy) Implementations define how it works (mechanisms) Finite State Machines Inputs (sensors) Outputs (actuators) Controller State graph States Implementations define how it works (mechanisms) 46

IMPORTANT NOTICE FOR TI DESIGN INFORMATION AND RESOURCES Texas Instruments Incorporated ( TI ) technical, application or other design advice, services or information, including, but not limited to, reference designs and materials relating to evaluation modules, (collectively, TI Resources ) are intended to assist designers who are developing applications that incorporate TI products; by downloading, accessing or using any particular TI Resource in any way, you (individually or, if you are acting on behalf of a company, your company) agree to use it solely for this purpose and subject to the terms of this Notice. TI s provision of TI Resources does not expand or otherwise alter TI s applicable published warranties or warranty disclaimers for TI products, and no additional obligations or liabilities arise from TI providing such TI Resources. TI reserves the right to make corrections, enhancements, improvements and other changes to its TI Resources. You understand and agree that you remain responsible for using your independent analysis, evaluation and judgment in designing your applications and that you have full and exclusive responsibility to assure the safety of your applications and compliance of your applications (and of all TI products used in or for your applications) with all applicable regulations, laws and other applicable requirements. You represent that, with respect to your applications, you have all the necessary expertise to create and implement safeguards that (1) anticipate dangerous consequences of failures, (2) monitor failures and their consequences, and (3) lessen the likelihood of failures that might cause harm and take appropriate actions. You agree that prior to using or distributing any applications that include TI products, you will thoroughly test such applications and the functionality of such TI products as used in such applications. TI has not conducted any testing other than that specifically described in the published documentation for a particular TI Resource. You are authorized to use, copy and modify any individual TI Resource only in connection with the development of applications that include the TI product(s) identified in such TI Resource. NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE TO ANY OTHER TI INTELLECTUAL PROPERTY RIGHT, AND NO LICENSE TO ANY TECHNOLOGY OR INTELLECTUAL PROPERTY RIGHT OF TI OR ANY THIRD PARTY IS GRANTED HEREIN, including but not limited to any patent right, copyright, mask work right, or other intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information regarding or referencing third-party products or services does not constitute a license to use such products or services, or a warranty or endorsement thereof. Use of TI Resources may require a license from a third party under the patents or other intellectual property of the third party, or a license from TI under the patents or other intellectual property of TI. TI RESOURCES ARE PROVIDED AS IS AND WITH ALL FAULTS. TI DISCLAIMS ALL OTHER WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED, REGARDING TI RESOURCES OR USE THEREOF, INCLUDING BUT NOT LIMITED TO ACCURACY OR COMPLETENESS, TITLE, ANY EPIDEMIC FAILURE WARRANTY AND ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHTS. TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY CLAIM, INCLUDING BUT NOT LIMITED TO ANY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON ANY COMBINATION OF PRODUCTS EVEN IF DESCRIBED IN TI RESOURCES OR OTHERWISE. IN NO EVENT SHALL TI BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, COLLATERAL, INDIRECT, PUNITIVE, INCIDENTAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES IN CONNECTION WITH OR ARISING OUT OF TI RESOURCES OR USE THEREOF, AND REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to fully indemnify TI and its representatives against any damages, costs, losses, and/or liabilities arising out of your noncompliance with the terms and provisions of this Notice. This Notice applies to TI Resources. Additional terms apply to the use and purchase of certain types of materials, TI products and services. These include; without limitation, TI s standard terms for semiconductor products http://www.ti.com/sc/docs/stdterms.htm), evaluation modules, and samples (http://www.ti.com/sc/docs/sampterms.htm). Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265 Copyright 2018, Texas Instruments Incorporated