working with the s110 & karel controller robot system me 4135 robotics and control r. r. lindeke

59
Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Upload: willis-matthews

Post on 11-Jan-2016

236 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Working with the S110 & Karel Controller Robot System

ME 4135 Robotics and Control

R. R. Lindeke

Page 2: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Outline of the Study:

The System: Robot Control Cabinet and System Teaching/Controlling the System

A study of Karel as a programming environment: Looping I/O Subroutines Interrupters

Page 3: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

The S110 Arm:

5 DoF Indirect Drive Articulator: Exhibits the d2 offset characteristics Max speed is: 1500 mm/sec at the tool

center point (notice arm speed not joint speed controller!)

Capable of Optimal (Joint) motion; Linear motion and Circular motion

Page 4: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Working Map of the Robot:

Page 5: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Working Data: S110 -- 5Axis

Axis Desc. Range Std. Speed High Speed

1 Waist Rotation

300 deg 90 deg/sec Same

2 Shoulder Bend

85 deg 90 deg/sec Same

3 Elbow Bend 65 deg 90 deg/sec Same

4 Wrist Pitch 250 deg 240 deg/sec

5 Wrist Roll 380 deg. 380 deg/sec

Payload: 10 kg (22 lb)

Repeatability 0.2 mm At max. speed/ext.

Weight: 350 kg (770 lb)

Page 6: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Working with the System:

In Karel systems, the Program development is separate from the Geometry development!

In Karel, we develop natural language (Pascal/C) programs that require strict structural rules be followed

Each “Program” requires 3 files types (name.kl, name.pc and name.var) for complete execution

Page 7: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Using the Controller: UIP tools Power ON < ----- > Power Off (as required) REMOTE ON – External Controller is “in

Charge” -- REMOTE OFF – Standard Operating Panel is “in Charge”

MEMORY PROTECT ON – No Programming Changes can be done -- MEMORY PROTECT OFF – Programs can be changed (edited or positions and variables are as last written ie. updated)

FAULT RESET BUTTON – Repowers Servos after robot faults are cleared

CALIBRATE PUSH BUTTON – Moves Arm to Oriented Position – Like the A1’s

CYCLE START – Runs or Restarts (Paused) Programs

HOLD Button – Pauses Program by decelerating to a stop (THE WAY PROGRAMS SHOULD BE TERMINATED ‘IN THE MIDDLE’)

Page 8: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

U.I.P. LCD Screen: Were it all happens!

Page 9: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Starting up in KAREL:

On the controller LCD, Press Soft key (S.K.) F1 to activate KCL

Then S.K.: Develop Then S.K.: Default and enter a program

name Then S.K.: EDIT to enter editor After entering editor for the first time, with a

new program we enter the letter I (insert) to generate a line for starting the program (inserts a line after the current line)

Page 10: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Writing the 1st Program:

All program begin with a Define Line: PROGRAM NAMED_1

All programs end with the line: END NAMED_1

Because Karel is Disciplined in design, we must define all variables (and initialize them) before use

Requires a variable definition section

All executable code follows a BEGIN statement (on a separate line)

Page 11: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

A 1st Program structure:PROGRAM NAMED_1-- comments as desired-- more-- moreCONST -- optional-- as neededVARidentifer: type (Position and Integer among others)identifer: type-- as neededBEGIN -- Program steps as required ….$SPEED = RATE – rate an integer variable, mm/sec at tool center pointWITH $SysVar = XXXX, <$SysVar = YYY> MOVE TO POS_1DELAY 20…-- Continue, note this symbol – introduces a comment line…END NAMED_1

Page 12: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Variable Types in Karel: Acceptable DATA_TYPES

Simple types are: Integer, Real, Boolean, String[length] Structured types are: Array[size], Position, Vector, Path

Example:Dick, Jane, Spot: PositionWORDY: STRING[10]RATE, W: INTEGERDIST1: REALPATH_A: Path TABLE_1: Array[12] OF INTEGER

-- Format is “IDENTIFIER (name):DATA_TYPE”

Page 13: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

System Variable Exist too – they control movement of the arm – and other things

$TERMTYPE – We will choose one of: Fine – target is closely approached COARSE – target is also closely approached NoSettle – Like G11 on the RC control! NoDecel – Like G12 on the RC Control!

$MOTYPE – We have available 3 types JOINT – an optimal mode of motion LINEAR – a mode that tracks straight lines between the positions or

NODES Circular – a mode that interpolates circles between positions

$SPEED The speed of the tool tip measured in mm/sec (MAX is 1500). In code we state: $SPEED = RATE Here the arm speed takes on the value of the variable RATE (or

can be a constant) As a Variable, it can be entered and changed using the Teach

Pendant, or within the program code

Page 14: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

KAREL has some useful tools to Work with Relative Geometries: MOVE AWAY – a function that moves the TCP

away from the current TCP position by a real number of millimeters along the negative ZTOOL (approach) direction

MOVE NEAR – a function that move close to (near!) a defined position along the negative ZTOOL (approach) direction by a real number of millimeters

CURPOS – a function that extracts the current arm geometry and stores it into a Position Variable

PATHPOS – a function that extracts a path node’s geometry and puts it into a Position Variable

SHIFT – a function that changes a defined position by adding a vector (which is also defined) to the current value of the Position Variable – orientation is unchanged

Page 15: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Completing Program Entry (in the Editor): After the Program has been written, Type

“S” to check program syntax Then press “E” to exit and compile the code

This creates a file called NAMED_1.pc

After successful Compilation we must load the program and variable files to continue work:

using the teach pendent running the program Type LO AL [NAMED_1] on UIP or use KCL S.K. for

Load then S.K. All

Page 16: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

One of the Coolest Things – Karel Coding while Working Off-line Employs a soft EMULATOR called: KFLOPPY.

The emulator works with an RS232 interface between the S100 Control and a local PC.

The Emulator is a “Command” program requires us to open a Command Window on the PC – actually it is best to open 2!

In the first Command Window type: cd .. then type: cd/KAREL then type: KFLOPPY

Finally, press F3 (PC’s function key) to execute the Emulator (the PC is treated as a Floppy ‘storage device’ w.r.t. the Main Karel Controller)

To bring a program to the PC, start the emulator, set up the proper directory for storing the file that will be downloaded

Page 17: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Working Offline, cont.

Return to the S110 UIP Choose KCL S.K. then type: Copy[/OVERWRITE]

BM:FILENAME.KL FD: type OVERWRITE if the program already resides on the PC in the chosen

directory this will copy the current version of filename to the PC. Once the Editing of the code is completed on the PC and we wish

to upload the completed code to the S100 Control: Choose KCL S.K. then type: COPY/OVERWRITE

FD:FILENAME.KL BM: this will copy the current version of filename from the PC to the S100

Control. NOTE: To use this changed version we must re-edit and “E” – compile –

then reloaded program before it can be used In the Second Command window we type CD .. Type EDIT to open the structure-less text Editor

this will allow Mouse navigation and line number identity Note: restrict any typed line to about 50 characters in length so compilation

errors are not induced.

Page 18: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Using the Teach Pendent: General View

Page 19: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Teach Pendent : LCD info

Page 20: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Teach Pendent: Motion Details

Page 21: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Defining Geometry:

Done separately from program generation! Require Position or Path variables to be initialized

as a program variable and then loaded into working memory – as discussed earlier

Specific geometry is programmed using the teach pendent

After desired geometries are driven to, programmed and checked, they MUST BE SAVED!

No auto-save of geometries in the KAREL environment!

Page 22: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Positional Programming (T.P.)

Step 1: Compile and load the program on the Control

Step 2: Enable TP; Press KCL S.K. select default and enter desired program name

Step 3: Press Previous Menu 2 times, Choose F1 S.K.: TEACH

Step 4: Uses Cursor scroll keys to highlight Position Variables

Step 5: Move Robot to desired position – highlight the desired pos_name Variable; Press SHIFT + F1 (RECORD S.K. in Teach menu)

Page 23: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Positional Programming (T.P.)

Step 6: On Controller interface Panel (UIP) on KCL sub-menu press MISC S.K., then press WHERE S.K., verify that both TP and UIP show same geometry

Step 7: On new choices press DONE S.K., this automatically (but temporally) stores the position geometry and cursors to the next position name, repeat 4 – 5 – 6 for all positions

Step 8: Once all positions have been ‘programmed’ press SAVE S.K. to store all the defined geometries into the file called: file_name.VR

NOTE: if you didn’t SAVE after defining your positions and then the robot system is powered down – all would be lost!!!

Page 24: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Modifying/Editing Variables (T.P.)

Step 1: Compile and load all, enable TP; Press KCL S.K. select default and enter desired program name

Step 2: Press Hard Key: DISPLAY SELECT; from Menu Displayed, Select S.K. F2: VARS

Step 3: Press S.K. F2, PROGVAR – new menu; use cursor arrows to move to desired data name

Step 4: Press S.K. F5, KCL; Press S.K. F4, DATA Step 5: Press S.K. F1, SET Step 6: Key in the desired value (use number

keypad), Press ENTER key STEP 7: Remember to SAVE data if desired (for a

permanent record!)

Page 25: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Developing Path Variables (T.P.)

Step 1: Add PATH_NAME:PATH to the Variables section of your program

Step 2: Compile and load all, enable TP; Press KCL S.K. select default and enter desired program name

Step 3: Press Hard Key: Display Select; From Menu that is displayed, Press S.K. F2, VARS

Step 4: Press S.K. F1: POSVAR; Cursor arrows to the path name desired; Press Hard Key: PREV MENU

Page 26: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Developing Path Variables (T.P.) Step 5: Press S.K. F1: TEACH; Press S.K.

F5, MORE Step 6: Press SHIFT + APPEND (S.K. F2),

this creates a node point PATH_NAME[1] (uninitialized)

Step 7: Move robot to desired position, again cursor to the PATH_NAME[1] label; Press SHIFT + Record (S.K. F1) – this is in the Teach submenu

Step 8: On new choices press the DONE S.K., this automatically appends and positions cursor for a new node, repeat steps 7 and 8 to add all nodes.

Page 27: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Other Tools for Paths (T.P.)

To maneuver through the nodes and add new nodes by inserting or appending,

Press TEACH S.K. (F1), press TEACH S.K. (F1) then

Press MORE S.K. (F5): Display shows: Delete (F1), Append (F2), Insert (F3) and

INDEX (F4). To use these keys press SHIFT + Fi (they work like this):

Append: Adds node at end of list Delete: Removes currently highlighted Node (renumbers the

rest) Index: after entering a node value moves you to that node Insert: Inserts a node ahead of the currently highlighted node

and re-numbers the existing nodes

Page 28: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Focusing on KAREL: Moving Commands

MOVE TO POS_1 (MOVE TO PATH_NAME [j]) WITH – allows local override of motion controls –

$speed, $termtype, $motype Path Motion:

MOVE ALONG PATH_NAME [i .. n] i can be greater or less than n! Allows smooth path following

Circular Motion: MOVE TO OTHER VIA LT_ONE

forms 3 point arc from current position to OTHER (position Variable) passing thru position variable LT_ONE

Page 29: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Program Control In KAREL: We will study three looping

Techniques: For – Do loops

A fixed number of repeats that is automatically incremented (decremented) by the program manager

Do – While loops Performs boolean evaluation at the beginning of a

loop and enters only if expression is true

Repeat – Until loops Executes loop once and checks for repeat if a

boolean evaluation is not yet true

Page 30: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Focus on Karel: Looping Commands (For Loops)

FOR CT_VAR = INITIAL_VALUE TO {or DOWN TO} FINAL VALUE DO STATEMENTS

ENDFOR Using this structure, the CT_VAR is

automatically incremented by Program Control Useful if we KNOW how many times we wish to

iterate like populating an array, traversing individual nodes on a Path, etc.

However, Initial and Final values can be variables which the program can change!

Page 31: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Focus on Karel: Looping Commands (Do While Loops) WHILE (Boolean expression) DO

STATEMENTS ENDWHILE Note the Boolean expression is

evaluated before the loop is entered A Boolean Expression is one that

Evaluates to true or false true = Numerically Positive Number or the

keyword TRUE false = Numerical Zero or keyword FALSE

Page 32: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Boolean Expressions in KAREL

Examples of Boolean Expressions that will “work” in KAREL:

(Count <= MAX_NUM) – here it could be infinite if we don’t increment Count as part of the statements in the looping structure

(DIN 1) – executes While loop as long as the input port 1 is “On” – a logic high event;

Will allow the escape from a repeat loop when the input port goes on This makes the condition true and is useful for

handshaking communication within Karel

Page 33: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Focus on Karel: Looping Commands (Repeat Until Loops)

REPEAT UNTIL (boolean Expression) Looping is executed until the boolean expression

is true – will always execute once since testing is performed at the end of the loop structure.

Same Rules Apply for the (boolean) expression as with Do While

Structurally: REPEAT

STATEMENTS UNTIL (A Boolean Expression)

Page 34: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Program Control In KAREL:

Karel also supports the Case Structure It evaluates an integer variable Then executes the appropriate set of

statements as determined by the value

Page 35: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Focusing on KAREL: Case Statements:

SELECT GP_COUNT OF CASE (1):

STATEMENTS CASE (2):

STATEMENTS CASE (6):

STATEMENTS all appropriate cases defined ELSE:

STATEMENTS ENDSELECT NOTE: The value of GP_COUNT (an integer

variable) must be defined before executing the Select (case) statement!

Page 36: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Focusing on KAREL: Two types of Subroutines

PROCEDURES: A sequence of Program statements invoked, by name, like a single Program Statement:

PRO_NAME(var1, var2)

FUNCTIONS: A sequence of Program statements (they can be a series of computations) invoked like a single program statement, by name, but that RETURNs a single value to the calling variable:

DICKY = FUN_NAME(var1,var2)

In either case the programmer can send values (as pointers) into the routine as defined in the Routine definition statement

Page 37: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

General Ideas on Subroutines:

They Are Used To “MODULARIZE” KAREL Programs

They are Similar In Structure To Programs They Have A Name They Can Have Local Variables And Constants They Require An End Routine_Name statement

Routines MUST be Declared Within a Program (Functions before they are used!)

Routines Can NOT Include Other Routine Declarations

(but then, why would we need to?)

Page 38: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Why We use These Routines: They can be used over and over

throughout a program (whenever they are needed they are called) so we find that entering the same code only once reduces entry errors that are often hard to “De-Bug”

They provide consistency and maintainability (vs typing duplicate codes in many places) – we need only make a single change within our definitional section and every instance (ie. Call to the Function) is automatically updated!

Their Good for Staying Dry and NOT Getting Lost

Page 39: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

BUILDing A PROCEDURE ROUTINE PRO_NAME <(parameter list)> --

parameter list is optional -- comment

VAR – optional and as needed, any variables declared here are “local”

-- NOTE: no local Path Variables or variables from another program

CONST – optional section as needed --

BEGIN STATEMENTS

END PRO_NAME NOTE: The optional parameter list is use to PASS Variables

from the main program to the “subroutine” Note: Procedures are little programs built within other

programs!

Page 40: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

BUILDing A FUNCTION ROUTINE FUN_NAME <(parameter list)>: return_type

-- parameter list is optional VAR – optional and as needed, any variables declared

here are “local” -- NOTE: no local Path Variables or variables from another

program CONST – optional section as needed

-- BEGIN

STATEMENTS -- Somewhere we must include a RETURN<(VALUE)>

statement END FUN_NAME

NOTE: The optional parameter list is use to PASS Variables from the main program to the “subroutine”

Note: Routines are little programs built within other programs!

Page 41: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Procedures & Functions In a FUNCTION: When We Encounter A

RETURN Statement -- Control is immediately restored to the calling

PROGRAM or ROUTINE Returns the current value of the return variable

to the calling location – return variable must be of type: return_type as defined in the function definition statement

Note if END statement is encountered in the FUNCTION – ie. No return is found – we get a fatal error!!

Page 42: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Procedures & Functions

In a PROCEDURE: if we encounter a return statement -- Program control will immediately be

restored to the calling program or routine.

Same happens if we encounter the END statement without a return. Note, end statement does not produce an error since no return value is needed!!

Page 43: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

A Comment on Variables

By default, all PROGRAM variables are Global Within a program (even in a sub-routine) any

changes in a variable will be evident everywhere If variables are needed within a subroutine we pass

the values – typecast – through the parameter list defined in the Routine declaration

Note: during definition we set type and order as well as a local name

When we invoke a routine during execution, we place global variable names in the appropriate positions in the parameter list as defined using the call statement

Page 44: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Looking At Program Interrupters In Karel these actions are considered

“Conditions” – or so-called Condition Handlers and are treated as a separate thread during program execution

As a separate thread, they are continuously monitored “In the Background” while the main program thread operates in the foreground

Page 45: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

USES:

Handle program interruptions such as errors, program pauses, program aborts or Emergency Stops that are unexpected (in a time sense) but can be anticipated to occur

They also Monitor and Control PERIPHERAL EQUIPMENT using Port I/O that can happen at unexpected times

They can Detect and Handle Time Out Conditions

Page 46: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

How Employed: They are Specified Condition/Action Pairs Can Be Globally or Locally Defined (local

means they are observed only with a specific instruction)

A Condition must be “ENABLED” before it will be tested

Testing of Conditions occurs under a background scan, a scan done in parallel with your foreground activities (moving, operating tools, communicating, etc.)

Page 47: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

How Employed (cont):

Should be Disabled after their usefulness in a given program area is completed. Purged when they no longer should be used in the program.

Condition Statements are “Queued” to the Background scan in the order they are enabled – not as defined. Each enabled condition is scanned every n

millisecond (n is a function of program and the number of conditions built and enabled)

Page 48: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

CONDITION Types:

The types are LIMITED, BUT CAN BE RICHLY LINKED, see Table 9-2

WHEN or UNTIL Structures are allowed

Action List is Executed When Condition is TRUE

Page 49: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

ACTION:

ANY Number Of Types including Executable Clauses, Assignments to Variables and/or Output ports, Sub-Routines Calls, etc., see Table 9-3

Actions to be performed must Follow the DO statement in the Condition Handler definition

Page 50: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Using/Defining Condition Handlers:BEGIN – main program starts here

CONDITION[1] - - defined within executable portion!WHEN DIN[12] DOMOVE TO INITIAL - - Cancels current motionDOUT[6] = TRUE -- turns on output port

ENDCONDITION - - notice, the condition is defined within the program MARY = 0

program statements as neededWHILE MARY <= 9

program loop statements as neededMARY = CHECK_PORT – reads the whole group InputENABLE CONDITION[1] – now we monitor Input Port 12 in backgroundMOVE ALONG PATH_2MOVE ALONG PATH_ENDDISABLE CONDITION[1] – stop monitoring Input port 12 in background

program loop statements as neededENDWHILEMOVE TO INITIALEND DDUBL_2B

Page 51: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Treating Input/Output in Karel

In the Robot System, The I/O resource is easily configured by the system manager

DIN/DOUT – these are the digital I/O available to Karel – must be defined in tables of 8 channels (up to 64 In’s and 64 outs are allowed)

They are defined using 2 Bytes of data that are written into the $USAT[i] system variable

Table 9-8 of the System Reference Manual (see handout) is the map of I/O information defined for the $USAT[i] system variable $USAT[1] to $USAT[16] define DIN’s $USAT[17] to $USAT[32] define DOUT’s

Page 52: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

To Set DIN or DOUT:

1st Byte is a physical address in the control including: RACK#/SLOT# -- note we only use rack 1! ALLOWABLE SLOTS: 1-7 or 9, 10

ex: rack 1 slot 5: $USAT[1] – the lowest set of 8 DIN’s: 0 0 0 1 0 1 0 1 – as binary geometry this value is: 27262524 23222120 = 24 + 22 + 20 = 21

Therefore: $USAT[1] = 21 (as seen in table 9-8 these are the 1st 8 DIN

channels – DIN[1] to DIN[8] 2nd Byte is a 7-bit Channel ID with the Least Significant Bit

(LSB) indicating activation state The 7-bit channel number equals the 1st channel of the

DIN/DOUT block used for the group of ports indicated, this number is 1 for lower half, 9 for upper half

Activation state is the way that we can generate an internal logic high as either High Volts or Low volts for input and 1 or 0 for turning on outputs.

Page 53: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Setting Upper Byte (example)

Channels 9-16 of the I/O block in R1 – S5 is to be defined for active high (LSB is 0 when we wish to activate high – the default)

Address: 0001001 + Activation Bit – (Note correct for

channels 9 -16 – would be 0000001 for channels 1 -8) Meaning 26252423222120 + Active State which (here) yields: 23 + 20 = 8 + 1 = 9 for upper half But the activation bit (here 0) acts to left shift the channel

info! Linking the channel Word with the Activation Word

means that the 23 + 20 are “Left Shifted” to become: 27262524232221 + 20 = (now) 24 + 21 = 16 + 2 = 18

Therefore: $USAT[2 or 4] = 18

Page 54: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Karel Also Supports “Group I/O” A group input/output links several

“Channels” together into a binary Word of length equal to the number of channels designated. These Groups can be “read in” or “output to”

using Decimal to Binary arithmetic concepts Example: We define a Group Input (GIN[1])

as 4 ports wide beginning with DIN[4] Here Ports 4, 5, 6, 7 form a binary word of size 4

PORT 4 is LSB Port 7 is the Most Significant Bit (MSB)

Page 55: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Group I/O’s are Defined in $USAT Too! Group Definitions require 3 $USAT Bytes:

1st Byte maps ports to the Rack and Slot (as for individual I/O’s)

2nd Byte indicates 1st channel number in the relevant I/O Block

3rd Byte indicates the number of channels (ports) in the group

Karel supports 5 Group Inputs ($USAT[33] - $USAT[47])

Karel also supports 5 Group Outputs ($USAT[48] - $USAT[62]) Note: An I/O port (or channel) can be defined

in both an individual and group set at the same time!

Page 56: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Using the Grouping Idea:

Returning to our Example (4 ports starting at ch. 4)

$USAT[33] = 21; $USAT[34] = 4; $USAT[35] = 4

In code we can access the value of this “Word” using this command: GP_COUNT = GIN[1] note GP_COUNT is an Integer Variable

Page 57: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Using the Grouping Idea (cont) :

The value of GP_COUNT will be a (decimal) integer that depends on the on-off state of the group input when the command is executed Test Case: Port 6 and Port 5 are “ON” (Logic

High) while ports 4 and 7 are “OFF” As a Binary word: 0 1 1 0 = 0*23 + 1* 22 (4) +

1*21 (2) + 0*20 This sum is 6 (in Decimal)

So after this statement is executed: GP_COUNT = 6

Page 58: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Using The Grouping:

It is commonly used to set values for Case Structures

Grouping of Inputs means that lots of choices can follow from fewer input ports (the same can be said of outputs)

Grouping is a convenient way to increase communication power in Karel

Page 59: Working with the S110 & Karel Controller Robot System ME 4135 Robotics and Control R. R. Lindeke

Wiring in Karel I/O’s:

AC

L2

L1

Din[n]

Din[n]Note: L2common

Dout[m]Note L1 is“common

Dout[m]

ACCoil

“Output”Relay

“Input”Relay

AC/DCCoil

AC/DCR. Switch

SparkArrestor

SparkArrestor