lsp 350: computers & society - lehman...

20
LSP 350: Computers & Society Lecture Notes 31 August 2005 Prof. Katherine St. John Lehman College & the Graduate Center City Universtity of New York Katherine St. John City University of New York 1

Upload: others

Post on 23-May-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

LSP 350: Computers & Society

Lecture Notes

31 August 2005

Prof. Katherine St. John

Lehman College & the Graduate Center

City Universtity of New York

Katherine St. John City University of New York 1

Page 2: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Overview

• First Day Details (web pages)

• Opportunities

• Introduction to Computers

• Checking out & Building Robots

Katherine St. John City University of New York 2

Page 3: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

First Day Details

See course webpages.

Katherine St. John City University of New York 3

Page 4: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Opportunities for Students inTechnology-Related Majors

• Computer Science & Mathematics

Mentorship & Scholarship Program

• Internships (On-Campus & Industry)

• Research Assistantships

Katherine St. John City University of New York 4

Page 5: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Computer Science & MathematicsMentorship & Scholarship Program

• Provides scholarships, a laptop

mentoring and career planning

• Majoring in technology-related field

• Good grades in first year courses

• US Citizen or permanent resident

Funded by the National Science Foundation.

Katherine St. John City University of New York 5

Page 6: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Internships (On-Campus & Industry)

Some recent internships:

• ABC Television

• Einstein School of Medicine

• FAA– La Guardia

• IBM Research

• NYC MTA

• National Medical Library

• New York Public Library

Katherine St. John City University of New York 6

Page 7: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Research Assistantships

A few examples:

Computational Biology: Wildebeest Cluster MorphometricsTree of Life Project (132 processors) with AMNH

Katherine St. John City University of New York 7

Page 8: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Introduction to Computers & Robots

• What is a computer?

• What is a program?

• Compiling Programs

Katherine St. John City University of New York 8

Page 9: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

What is a computer?

A basic computer has a

• central processing unit (CPU) or “brain”,

• registers to keep track of next instruction & where data is stored

• Two kinds of memory:

– Read Only Memory (ROM): Often contains directions that

programs the CPU and can’t be erased,

– Random Access Memory (RAM): Used to store firmware and

programs the computer runs.

Katherine St. John City University of New York 9

Page 10: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

What is a computer?

There’s also input devices:

• keyboard, mouse, scanner,...

and output devices:

• screen, printer, speaker,...

Katherine St. John City University of New York 10

Page 11: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Lego Mindstorm Robot

The lego robot has:

• 8-bit CPU (in bulkly lego block,

called the RCX)

• 16K Internal ROM & 32K static RAM

(6K for programs)

• Input Devices: 2 touch sensors,

1 light sensor, I/R port

• Output Devices: 2 motors, screen, speaker,

I/R port

Katherine St. John City University of New York 11

Page 12: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Lego Mindstorm Internals

(Pictures of RCX internals from: http://graphics.stanford.edu/ kekoa/rcx/)

Katherine St. John City University of New York 12

Page 13: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

CPU Directions

• Most CPUs understand directions written in machine

language– strings of 0’s and 1’s

• Each instruction corresponds to an “operation code” or

opcode that consists of commands like:

‘‘Increment value in register AX’’

• Very hard to write program in machine language.

• Most programs are written in a high level language,

like Java, Visual Basic, C or C++.

Katherine St. John City University of New York 13

Page 14: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Programming

• The general process is:You write a program ⇒ Gives a binary file ⇒ You “run” thethat looks like English “compiling” the computer can binary to execute(with lots of rules) understand the program

• A program is a set of instructions for the computer to

follow.

• Programs implement algorithms– step-by-step

directions for performing a task (ex: a recipe to make

cookies, directions to make the robot turn 360◦).

Katherine St. John City University of New York 14

Page 15: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Not Quite C

• For the robot, we’re going to write programs in a

variant of C, called Not Quite C (NQC).

• Legos come with a language called RCX– it’s very

simple, but doesn’t allow you to do a lot.

• By using NQC, you can do more sophisticated

programs and it will help you learn C/C++ and Java.

Katherine St. John City University of New York 15

Page 16: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

A Simple Program

// tankbot1.nqc - drive straight ahead

#define LEFT OUT_A#define RIGHT OUT_C

task main(){

On(LEFT+RIGHT);until(false);

}

Katherine St. John City University of New York 16

Page 17: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Some Useful NQC Commands

Command Definition Example

On(outputs) turn on outputs On(LEFT+RIGHT);Off(outputs) turn off outputs Off(LEFT+RIGHT);Fwd(outputs) sets to foward direction Fwd(LEFT);Rev(outputs) sets to reverse direction Rev(RIGHT);

Wait(time) wait for time time100 seconds Wait(100);

(Much more on this in the next two lectures.)

Katherine St. John City University of New York 17

Page 18: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Checking Out & Building Robots

• Robots are stored in Gillet 137.

• After a short break, need a few volunteers to help

transport them to our classroom.

Katherine St. John City University of New York 18

Page 19: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Checking Out & Building Robots

Each student will get:

• Large blue box of Lego pieces

• Small plastic shoebox to store assembled robot

• Labels to place on the robot RCX, the blue box, and the shoebox.

Katherine St. John City University of New York 19

Page 20: LSP 350: Computers & Society - Lehman Collegecomet.lehman.cuny.edu/stjohn/teaching/lsp350/lsp350_20050831.pdf · 8/31/2005  · (bumpbot) and light sensor mount (linebot). • We

Checking Out & Building Robots

• Everyone will put a robot together and test the 5 built-in

programs, described in the Lego instruction manual.

• The easiest robot (tankbot) to build is described in Chapter 5 of

Dave Baum’s book. Subsequent chapters describe an easy bumper

(bumpbot) and light sensor mount (linebot).

• We will begin cleaning up at 11:30am and must be completely out

of the room by 11:50am.

• If you do not finish today, you may come during my office hours

(W 11:30-12:30, Th 10-12) or when Gillet 137 suite is open (most

T,W,Th 2-5).

Katherine St. John City University of New York 20