Working with the S110 - PowerPoint PPT Presentation

1 / 64
About This Presentation
Title:

Working with the S110

Description:

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 ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 65
Provided by: rlin
Category:

less

Transcript and Presenter's Notes

Title: Working with the S110


1
Working with the S110 Karel Controller Robot
System
  • ME 3222 Controls and Mechatronics Lab
  • R. R. Lindeke

2
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

3
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

4
Working Map of the Robot
5
Working Data S110 -- 5Axis
6
Working with the System
  • In Karel systems, the Program development is
    separated 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

7
Using the Controller User Interface Panel tools
  • Power ON lt ----- gt 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
  • 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)

8
U.I.P. LCD Screen Were it all happens!
These are S.K.s!
9
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 (Capitol eye
    for insert) to generate a line for starting the
    program (note Insert places a line after the
    current line in the program)

10
Writing the 1st Program
  • All programs 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)

11
A 1st Program structure
  • PROGRAM NAMED_1
  • -- comments as desired
  • -- more
  • -- more
  • CONST -- optional
  • -- as needed
  • VAR
  • IDENTIFER TYPE (Position and Integer among
    others)
  • IDENTIFER TYPE
  • -- as needed
  • BEGIN
  • -- Program steps as required .
  • SPEED RATE rate an integer variable, mm/sec
    at tool center point
  • WITH SYSVAR XXXX, ltSYSVAR YYYgt MOVE TO
    POS_1
  • DELAY 20
  • -- Continue, note this symbol -- introduces a
    comment line
  • END NAMED_1

12
Variable Types in Karel
  • Acceptable DATA_TYPES
  • Simple types are Integer, Real, Boolean,
    Stringlength
  • Structured types are Arraysize, Position,
    Vector, Path
  • Example
  • DICK, JANE, SPOT POSITION
  • WORDY STRING10
  • RATE, W INTEGER
  • DIST1 REAL
  • PATH_A PATH
  • TABLE_1 ARRAY12 OF INTEGER
  • -- Format is IDENTIFIER (a name)DATA_TYPE

Number of Characters in a Word
Number of Elements in Array
13
System Variable are very important they control
movement of the arm and program execution
  • TERMTYPE We will choose one of
  • FINE target is closely approached
  • COARSE target is also closely approached
  • NOSETTLE Here, when the controller first senses
    that we are at the target the controller begins
    execution of the next command!
  • NODECEL Here, when the controller first senses
    that we have entered the deceleration zone for a
    target position the controller begins execution
    of the next command!
  • MOTYPE We have available 3 types
  • JOINT an optimal mode of motion, smooth curves
    between positions
  • LINEAR a mode that tracks straight lines
    between the positions or nodes on paths, computed
    in real time
  • CIRCULAR a mode that interpolates arc between
    positions in real time
  • SPEED
  • The speed of the tool tip measured in mm/sec (MAX
    is 1500).
  • In code we state SPEED RATE or SPEED 500
  • Here the arm speed takes on the value of the
    variable RATE (or it can be a constant)
  • As a Variable, it can be entered and changed
    using the Teach Pendant, or within the program
    code to offer more flexibility in execution

14
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 (the control is self-aware)
  • MOVE NEAR a function that move close to (near!)
    a defined position. The stopping point is along
    the negative ZTOOL (approach) direction by a real
    number of millimeters that is stated in the
    command

15
KAREL has some other useful Geometric tools
  • CURPOS a function that extracts the current arm
    geometry and stores it into a Position Variable
  • PATHPOS a function that extracts a path nodes
    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

16
Completing Program Entry (in the Editor)
  • After the Program has been written, the operator
    Types S to force a check of program syntax
  • Then the operator types 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

17
Karel Coding can be produced when 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 (PCs 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

18
Working Offline, cont.
  • Return to the S110 UIP
  • Choose KCL S.K. then type Copy/OVERWRITE
    BMFILENAME.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.

19
Working Offline, cont
  • 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.

20
Working Offline, cont
  • 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
    FDFILENAME.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
    1.re-edit and 2. E recompile then 3.
    reloaded program before it can be used

21
Working with the Geometry Control, IN PARALLEL
  • When we start our program, it makes sense to
    define all required (preplanned) working
    Geometries
  • Both Positions and Paths
  • Additionally, we will define any anticipated
    integer and real variables
  • Before uploading the Karel program for coding
    off-line, we should compile the skeletal
    program and load it into working memory

22
We Then Begin Programming Positions Using The
Teach Pendent
  • This speeds up program development
  • On the teach pendent we move the arm then store
    desired configurations to position names (and
    save) using the predefined geometries and
    variable values
  • While any geometry programmed during a session is
    immediately available, they will not be written
    to a permanent record without our action (SAVE)!

23
Using the Teach Pendent General View
24
Teach Pendent LCD info
25
Teach Pendent Motion Details
26
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!

27
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)

28
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 didnt SAVE after defining your
    positions and then the robot system is powered
    down all would be lost!!!

29
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!)

30
Developing Path Variables (T.P.)
  • Step 1 Add PATH_NAMEPATH 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

31
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_NAME1 (uninitialized)
  • Step 7 Move robot to desired position, again
    cursor to the PATH_NAME1 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.

32
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

33
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

34
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

35
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.
  • Note, however, that the Initial and Final values
    can be variables which the program can change!

36
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

37
Boolean Expressions in KAREL
  • Examples of Boolean Expressions that will work
    in KAREL
  • (Count lt MAX_NUM) here it could be infinite if
    we dont 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

38
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)

39
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

40
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!

41
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

42
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?)

43
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!

44
BUILDing A PROCEDURE
  • ROUTINE PRO_NAME lt(parameter list)gt -- 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!

45
BUILDing A FUNCTION
  • ROUTINE FUN_NAME lt(parameter list)gt 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 RETURNlt(VALUE)gt
    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!

46
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!!

47
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!!

48
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

49
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

50
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

51
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.)

52
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)

53
CONDITION Types
  • The types are LIMITED, BUT CAN BE RICHLY LINKED,
    see Table 9-2
  • WHEN DO or UNTIL THEN Structures are allowed
  • Action List is Executed When Condition is TRUE

54
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 or
    THEN statement in the Condition Handler definition

55
Using/Defining Condition Handlers
  • BEGIN main program starts here
  • CONDITION1 - - defined within executable
    portion!
  • WHEN DIN12 DO
  • MOVE TO INITIAL - - Cancels current motion
  • DOUT6 TRUE -- turns on output port
  • ENDCONDITION - - notice, the condition is
    defined within the program
  • MARY 0
  • ?program statements as needed
  • WHILE MARY lt 9
  • ? program loop statements as needed
  • MARY CHECK_PORT reads the whole group Input
  • ENABLE CONDITION1 now we monitor Input Port
    12 in background
  • MOVE ALONG PATH_2
  • MOVE ALONG PATH_END
  • DISABLE CONDITION1 stop monitoring Input
    port 12 in background
  • ? program loop statements as needed
  • ENDWHILE
  • MOVE TO INITIAL
  • END DDUBL_2B

56
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 Ins and 64 outs are allowed)
  • They are defined using 2 Bytes of data that are
    written into the USATi system variable
  • Table 9-8 of the System Reference Manual (see
    handout) is the map of I/O information defined
    for the USATi system variable
  • USAT1 to USAT16 define DINs
  • USAT17 to USAT32 define DOUTs

57
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 USAT1 the lowest set of
    8 DINs
  • 0 0 0 1 0 1 0 1 as binary geometry this
    value is
  • 27262524 23222120 24 22 20 21
  • Therefore
  • USAT1 21 (as seen in table 9-8 these are the
    1st 8 DIN channels DIN1 to DIN8
  • 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.

58
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 USAT2 or 4 18

59
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 (GIN1) as 4
    ports wide beginning with DIN4
  • 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)

60
Group I/Os are Defined in USAT Too!
  • Group Definitions require 3 USAT Bytes
  • 1st Byte maps ports to the Rack and Slot (as for
    individual I/Os)
  • 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 (USAT33 -
    USAT47)
  • Karel also supports 5 Group Outputs (USAT48 -
    USAT62)
  • Note An I/O port (or channel) can be defined in
    both an individual and group set at the same time!

61
Using the Grouping Idea
  • Returning to our Example (4 ports starting at ch.
    4)
  • USAT33 21 USAT34 4 USAT35 4
  • In code we can access the value of this Word
    using this command
  • GP_COUNT GIN1
  • note GP_COUNT is an Integer Variable

62
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 023 1 22 (4)
    121 (2) 020
  • This sum is 6 (in Decimal)
  • So after this statement is executed GP_COUNT
    6

63
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

64
Wiring in Karel I/Os
Write a Comment
User Comments (0)
About PowerShow.com