Cricket (Handy Cricket) - PowerPoint PPT Presentation

About This Presentation
Title:

Cricket (Handy Cricket)

Description:

Cricket (Handy Cricket) ... MIT StarLogo, NetLogo, etc. Cricket Logo developed in MIT by Brian Silverman with Fred Martin beginning in 1995 Intro to Cricket Logo ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 21
Provided by: Kyeongs
Learn more at: https://www.cs.rit.edu
Category:
Tags: cricket | handy | netlogo

less

Transcript and Presenter's Notes

Title: Cricket (Handy Cricket)


1
Cricket (Handy Cricket)
  • Kyeongseo Hwang (Mike)
  • Nicholas Ver Hoeve

2
Agenda
  • About Cricket (HW)
  • History of Logo (Built in interpreter)
  • Intro to Cricket Logo
  • Demo

3
About Cricket
LIGHT SENSOR
TOUCH SENSOR
MAG. REED SWITCH
IR SENSOR
DC MOTOR
BREAK BEAM SENSOR
4
History of Logo
  • Logo Developed in BBN (a Cambridge University
    research firm), in 1966
  • By Seymour Papert, Wally Feurzeig
  • Modeled after LISP
  • Now in multiple dialects ExperLogo, ARLogo, MIT
    StarLogo, NetLogo, etc.
  • Cricket Logo developed in MIT by Brian Silverman
    with Fred Martin beginning in 1995

5
Intro to Cricket Logo
  • Procedure definition with inputs and return
    values
  • Global variables and local procedure inputs
  • Control structures if, repeat, and loop
  • 16-bit number system addition, subtraction,
    multiplication, division, remainder, comparison,
    bit-wise operations, random function
  • Motor and sensor primitives
  • Timing functions and tone-playing functions
  • Data recording and playback primitives
  • IR Communications primitives

6
Intro to Cricket Logo
7
Motor Command
  • a, Motor A
  • b, Motor B
  • ab, Motor A and B
  • on Selected motor On
  • off Selected motor Off
  • onfor Selected motor will turn on
    for /10 secs.
  • thisway/ thatway Sets direction
  • rd Reverses the direction
  • setpower set power level

8
Sensor Command
  • switcha
  • return 1 if switched plugged into sensor A is
    pressed
  • switchb
  • return 1 if switched plugged into sensor A is
    pressed
  • sensora
  • Report the value of sensor A 0255
  • sensorb
  • Report the value of sensor B 0255

9
Timing and tone-playing
  • Timing
  • ab, on wait 20 off
  • ab, onfor 20
  • wait
  • timer
  • resett
  • Tone-playing
  • beep
  • note 110 30
  • www.handyboard.com/cricket/program

10
Control Structures
  • repeat times body
  • loop body
  • if condition body
  • ifelse condition body-1 body-2
  • waituntil condition
  • stop(!)
  • output returning_value

11
Numbers
  • 16 bit number system
  • -32768 32767
  • All arithmetic operators separated by a space
  • 3 4
  • Normal expression precedence rules are not used,
    evaluated left to right
  • 3 5 7 ?
  • (3 (4 5)) ?

12
Number Operator (cont)
  • Infix addition
  • - Infix subtraction
  • Infix multiplication
  • / Infix division
  • Infix modulus (remainder after integer
    division).
  • lt Infix LESS-THAN test.
  • Results in 1 if left-hand value is less than
    right-hand value 0 otherwise.

13
Number Operator (cont)
  • gt Infix GREATER-THAN test. Results in 1 if
    left-hand value is greater-than than right-hand
    value 0 otherwise.
  • Infix equality test.
  • Results in 1 if left-hand value is equal to
    right-hand value 0 otherwise.
  • and Infix AND operation (bitwise).
  • or Infix OR operation (bitwise).
  • xor Infix exclusive-OR operation (bitwise).
  • not prefix NOT operation (logical inversion,
    not bitwise).
  • random Reports pseudo-random number from 0 to
    32767.
  • Use the modulus operator to reduce the range
    e.g., (random 100) yields a number from 0 to 99.

14
Procedure Definition with input
  • to flash1
  • repeat 10 a, onfor 5 wait 5
  • end
  • to flash2 n
  • repeat n a, onfor 5 wait 5
  • end
  • global temp
  • to detect
  • settemp sensora
  • if temp lt 30 output 1
  • if temp lt 50 output 2
  • output 3
  • end

15
Variables
  • Global variable
  • global variable-list e.g. global cat dog
  • Stored in RAM -gt data recording and playback
    functions
  • Integer only
  • Global-setting primitive
  • setcar, setdog e.g. setcat 3 setcat cat 1
  • Global Array
  • array clicks 10 clacks 15
  • Array indices start at 0
  • aget name index
  • aset name index
  • No buffer-overrun checking
  • Stored consecutively in memory
  • stored in the Cricket's non-volatile memory

16
Data Recording and Playback
  • to take-data
  • resetdp repeat 2500 record sensora wait 10
  • end
  • resetdp
  • setdp position
  • erase
  • record value
  • Recall

17
Recursion
  • to fact n
  • if n 1 output 1
  • output n fact n 1
  • end -gt repeat fact 3 beep
    wait 1
  • Normal Recursion has uncertain max depth, can be
    as low as 5
  • Supports Tail Recursion
  • converting the recursive call into a goto
    statement
  • to beep-forever
  • beep wait 1
  • beep-forever
  • end

18
Multi-Tasking
  • supports a limited form of multi-tasking
  • One background task
  • repeatedly checks a condition
  • When true it interrupts and processes
  • when switcha beep loop a, onfor
    5 rd
  • only one background task operating at any given
    time.
  • If a when statement is executed after the
    background task has already been started, the
    subsequent when task supercedes the earlier one
  • To stop the background task from operating, use
    the primitive whenoff.

19
Samples
  • Files at www.cs.rit.edu/kxh7583/PLC/
  • Demo the multi-taking
  • IR communication between crickets
  • Background Operation

20
Reference
  • www.handyboard.com/cricket
  • http//gleasonresearch.com/ http//lcs.www.media.m
    it.edu/people/fredm/projects/cricket/redlogo.html
  • http//www.papert.org/
  • http//www.mathsnet.net/logo/turtlelogo/
Write a Comment
User Comments (0)
About PowerShow.com