540 likes | 558 Views
Explore computer applications in MAE, structured programming, C language, data types, and more. Learn to solve problems with computational solutions and prepare for mechatronics. Discover software commonly used by MAEs.
E N D
Lecture 1: Course IntroductionOverview of Computers and their Applications in MAE BJ Furman 01SEP2012
The Plan for Today • Welcome to ME 30 • Learning objectives • Roll call • Highlights from the syllabus (aka, ‘greensheet’) • Overview of computers and their applications in MAE • Introduce structured programming, algorithms, pseudocode, and flowcharts • Form of a C program • Data types and variables
Learning Objectives By the end of the lecture you should be able to: • Explain the focus of the course • Describe where and how computers are used by mechanical and aerospace engineers (MAEs) • List some of the software commonly used by MAEs • Describe what the major elements of a computer are and what they do conceptually • Explain what is meant by ‘structured programming’ • Describe the structure of a C program • List and describe the important data types • Declare a variable
Roll Call Back
Syllabus Highlights and Where to Find Things • Available at www.engr.sjsu.edu/bjfurman/courses/ME30/ and sjsu.desire2learn.com • My contact and office information • My background • Course information • Course goals and learning objectives • Textbook • Policies and protocol • Grading • Resources • Course schedule Back
Focus of ME 30 • Solving problems with computers • Learn the process for formulating a computational solution to a problem • Practice the process • Learn structured programming using the C language • Get prepared for learning about mechatronics • Gain familiarity with other software used by MAEs for technical computing • Matlab • Excel
sin(r)/r Where and How are Computers Used in MAE? 1 • Technical and Personal Communication • Email • Word processing • (reports, procedures, etc.) • Presentations • Conferencing • Computation and Analysis • Arithmetic • Equation solving • Data analysis and visualization • Multiphysics andnumerical modeling
Where and How are Computers Used in MAE? 2 • Design • Solid modeling (ME 165) • Finite Element Analysis (FEA) (ME 160) • Dynamic modeling and simulation (ME 147, ME 187, ME 190) • Design tradeoffs and analytical modeling of mechanical components and systems (ME 154, ME 157) • Gathering Information • Web searches • Patent searches • Databases • Vendor and other websites • Datasheets
http://las.perkinelmer.com/Content/Images/smallImages/janusLabAuto.jpghttp://las.perkinelmer.com/Content/Images/smallImages/janusLabAuto.jpg http://www.plm.automation.siemens.com/en_us/products/teamcenter/solutions_by_product/mechatronics_process_management.shtml Where and How are Computers Used in MAE? 3 • Testing and Experimental Work • Data acquisition from sensors (ME 120) • Laboratory and Factory Automationand Control • Dynamic systems (ME 187, ME 190) • Factory automation video • Instrumentation and Product Design • Embedded controllers (ME 106, ME 190) • MRP, Inventory, and Document Control • Drawings • Procedures • Bill of Materials (BOM) • Specifications • Engineering change orders (ECOs)
What Software is Most Often Used? 1 • Technical and Personal Communication • Email (MS Outlook, Mozilla Thunderbird) • Word processing (MS Word, Open Office) • Presentations (MS Power Point, Open Office) • Computation and Analysis • Spreadsheets (MS Excel, Open Office Calc) • Mathcad/Maple/Mathematica • Matlab/Octave/Scilab • TK Solver • Maxima
What Software is Most Often Used? 2 • Design • Solid modeling (Solidworks, ProE, Inventor, Unigraphics) • Finite Element Analysis (Cosmos, ProMechanica, Nastran) • Dynamic modeling and simulation (Matlab/Simulink, ) • Design tradeoffs and analytical modeling of mechanical components and systems (Excel, Mathcad, Matlab, TK Solver) • Gathering Information • Web searches (Google, other search engines) • Patent searches (Google Patent, USPTO website) • Databases (see the SJSU Articles & Databases website: http://www.sjlibrary.org/research/databases/index.htm?getType=3 • Vendor and other websites (Google, other search engines) • Datasheets (Google, vendor websites)
What Software is Most Often Used?3 • Testing and Experimental Work • Lab View, C, Matlab • Laboratory and Factory Automationand Control • Lab View, C, Visual Basic • Instrumentation and (Mechatronic) Product Design • C, Matlab, Lab View (see “Real Men Program in C”) • Product Data Management • Siemens PLM • Oracle Agile • Dassault Enovia
The Bottom Line • Mechanical and aerospace engineers use computers widely • You need to know how to use computers to help you be successful • ME 30 will help you especially in the area of computation and analysis • Focus will be on the C language • Exposure to Matlab and Excel • I hope it will also whet your appetite to learn about mechatronics Next -->
Networking • Introduce yourself to someone you DO NOT know • Find out one thing about them that they like to do in their spare time Two minutes! Back
What do computers actually do? • Perform arithmetic operations • Addition, subtraction, multiplication, division • Compare two values • And decide among alternative courses of action • If a > b, then do action c • Move data around internally (memory and peripherals) • Input data (keyboard, mouse, sensors, etc.) • Output data (display, I/O ports, etc.) And do all of this really fast ….
Robot Programming Problem Write a program to make a robot follow a square course
Personal Computer (PC) Anatomy • Case or housing • Embedded computers likely not to have • Power supply • Motherboard • CPU • Memory • Video and audio chipsets • Networking • I/O ports • Hard disk • Solid state sometimes now • Peripherals • CD or DVD drive
Hard drive,CD/DVD CPU Diskcontroller Videochipset Audiochipset Display Memory Ports USB, Serial, Keyboard, Mouse, etc. Speakers Networkingchipset Internet Bus Computer Block Diagram
Memory (8-bit) Address 0x10FE 0 0 1 1 1 0 1 0 0 0 1 1 0 1 0 0 0x10FF 0x1100 0 0 0 0 0 0 0 0 0xFFFF Bit 7 6 5 4 3 2 1 0 Memory • Stores program instructions and data • Each location hasan ‘address’ • Each location storesthe information as ‘bits’ • Binary ____its • Zero or one • 8 bits is one byte • Information is ‘coded’ • Memory is ‘written’ or ‘read’
CPU Registers Clock ALU CU Data Instructions Memory CPU • The ‘brain’ of your computer • Carries out the instructions of your program • Essential components: • Arithmetic Logic Unit (ALU) • Does arithmetic and logic functions • Add and subtract (sometimes multiply and divide) • Bit-wise logic: • AND, OR, NOT, XOR • Bit shift (left or right) • Control Unit (CU) • Controls the actions inside the CPU • Registers • Temporary locations to store data, instructions, and addresses • Clock • Synchronizes operations in the CPU Adapted from Fundamentals of Computer Organization and Architecture, M. Abd-El-Barr, H. El-Rewini, John Wiley and Sons, 2005
Ports • Connection to the external world • USB • Serial • Keyboard • Monitor • Pins on a microcontroller • Voltage level determines whether a 0 or a 1 • Ex. 5 V logic: • < 1.5 V = 0 • > 3.5 V = 1 http://media.digikey.com/photos/Atmel%20Photos/453-64-TQFP.jpg http://www.atmel.com/dyn/resources/prod_documents/doc2467.pdf
Software • The intermediary between you (the user) and the hardware • Operating system (OS) see the next page • Windows, OS X, Linux • Application programs • End-user applications • Word processor, solid modeler, etc. • Mathcad, Matlab, etc. • Application development software (programming languages) • C, Matlab (sort of), Lab View (sort of), Python, Java, FORTRAN, etc.
Operating System (OS) • A program that: • Acts as an intermediary between hardware and application software • Provides a consistent, stable way for applications to interact with hardware • APIs, so you don’t have to do it all yourself • Examples: • Windows XP/Vista • Linux • OS X http://en.wikipedia.org/wiki/File:Operating_system_placement.svg
Correct Not correct Program Development from Figure 1.11, p. 32 in HK note additions! Create/Edit source files (your program!) IDE Compile source files Link compiled files Load executable file Run your program! Test Repeat process
References • http://www.karbosguide.com/ • http://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Asus_a8n_VMCSM02.jpg/645px-Asus_a8n_VMCSM02.jpg Fir0002/Flagstaffotos. Retrieved 22MAY2009. • http://en.wikipedia.org/wiki/Operating_system. Wikipedia. Retrieved 23MAY2009. • http://www.embeddedsys.com/. Visited 23MAY2009.
Embedded Computers and Microcontrollers Microcontrollers ATtiny10 microcontroller, with 1K bytes of programmable Flash memory, and 32 bytes of internal SRAM http://media.digikey.com/photos/Atmel%20Photos/313-64-TQFP.jpg http://media.digikey.com/photos/Atmel%20Photos/453-64-TQFP.jpg http://www.electropages.com/articleImages/large/12813.jpg Single-board computer http://www.oxisso.com/Microcontrollers/Atmega128TinyBoard_Show.jpg Back http://www.embeddedsys.com/subpages/products/images/pdf/microsys_sbc1586_datasheet.pdf
Power Supply ATX power supply MFG: ECHO-STARP/N: ES-450-24STYLE: ATX-20/24Input: 110/220 VAC 50-60HzOutput #1: +3.3V @ 28A #2:+5V @ 34A#3: +5VDCSB @ 2A #4: +12V @ 14A#5: -12V @ .8A #6: -5V @ .5A(450W Max combined output) http://www.mpja.com/prodinfo.asp?number=16581+PS Back
Motherboard Asus a8n VMCSM02 - Supports AMD Socket 939 Athlon 64FX / Athlon 64 X2 / Athlon 64 - NVIDIA GeForce 6150 + nForce 430- Dual-channel DDR400- PCI Express architecture- Integrated GeForce6 GPU- Dual VGA Ouput:DVI-D & RGB- NVIDIA Gigabit LAN with NVIDIA ActiveArmor Firewall- 4 x SATA II (RAID 0, RAID 1, RAID 0+1, RAID 5)- 1394a Support- High Definition Audio http://en.wikipedia.org/wiki/File:Asus_a8n_VMCSM02.jpg Fir0002/Flagstaffotos Back
My Background • Almost native SJ • Willow Glen High School class of ’76 • Education – first round • UC Davis • BSME – 1980 • MEME – 1982 • Industry experience – first round • IBM GPD – 1982 - 1986 • 3390 actuator development • Education – second round • Stanford University 1986-1991 • Non-contact rotor balancing • Industry experience – second round • IBM SSD 1991 – 1993 • 3390 product engineering • Spindle motor development • Academia • SJSU MAE – 1994 to pres. • Personal • Married • 13-year old daughter • Hobbies: build things, fix things, garden, read, hike, amateur radio (ARES) • Most significant: relationship to God through Jesus Christ • www.leaderu.com Faculty Offices (under Academics) Back
Robot Programming Problem • How do you go about the programming task? Write a program to make a robot follow a square course
Method for Developing a Program Note: these steps are to be done BEFOREyou write any program code! 1. Define the problem: • State the problem you are trying to solve in clear and concise terms. 2. List the inputs and the outputs • Inputs: information needed to solve the problem • Outputs: what the algorithm will produce as a result 3. Describe the steps needed to convert or manipulate the inputs to produce the outputs (develop the algorithm) • Begin at a high-level first • Refine (subdivide the high-level) steps until they are effectively computable operations. 4. Test the algorithm: • choose data sets, and verify that your algorithm works!
Structured Programming • Sequence • Selection • IF • IF – ELSE • SWITCH • Repetition • WHILE • DO – WHILE • FOR Flowchart constructs
Algorithm • What is an algorithm? • A recipe • A procedure • Definition: • “well-ordered collection of unambiguous and effectively computable operations, that when executed, produces a result and halts in a finite amount of time.” definition from: An Invitation to Computer Science (Gersting/Schneider) via http://www.cs.xu.edu/csci170/08f/sect01/Overheads/WhatIsAnAlgorithm.html (visited 19JUN2009)
Characteristics of an Algorithm • Well-ordered: • the steps are in a clear order • Unambiguous: • the operations described are understood by a computing agent without further simplification • Effectively computable: • the computing agent can actually carry out the operation
Pseudocode • natural language-like statements that precisely describe the steps of an algorithm • Statements that describe actions • Focuses on the logic of the algorithm • Avoids language-specific elements • Written at a level so that code can be generated almost automatically from each statement • Steps are numbered • Subordinate numbers and/or indentation are used for dependent statements in selection and repetition structures
Pseudocode example Note: English-like statements that describe the actions of the algorithm, and indented to show the logical structure of the algorithm.
Flowcharts - 1 • Flowcharts • A graphical tool that diagrammatically depicts the steps and structure of an algorithm or program
Flowchart Constructs - Sequence and Selection Control Structures from Deitel & Deitel, 6th ed., p. 122
Flowchart Constructs - Repetition from Deitel & Deitel, 6th ed., p. 122 Control Structures
Example: D&D 3.15c - 1 • “Obtain a series of positive numbers from the keyboard, and determine and display their sum. Assume that the user types the sentinel value -1 to indicate "end of data entry" • Define the problem • Statement pretty well defines the problem • List inputs and outputs • inputs: number entered from keyboard • outputs: sum of number
Example: D&D 3.15c - 1 • “Obtain a series of positive numbers from the keyboard, and determine and display their sum. Assume that the user types the sentinel value -1 to indicate "end of data entry" • Develop the algorithm • High-level first, then refine: 1. Start 2. Declare variables: ________ 3. Repeat while number not equal to -1 3.1. get number 3.2. add to sum 4. Display sum Does this work?
Example: D&D 3.15c - 2 1. Start 2. Declare variables: ________ 3. Repeat while number not equal to -1 3.1. get number 3.2. add to sum 4. Display sum • Develop the algorithm, cont. • Refine 1. Start 2. Declare variables: num, sum 3. while numnot equal to -1, continue doing: 3.1. Display prompt “Enter positive number” 3.2. Read number from the keyboard 3.3. Display number entered 3.4. add to sum 4. Display sum Are we there yet?
Example: D&D 3.15c - 3 • Develop the algorithm, cont. • Add a test to exclude negative numbers 1. Start 2. Declare variables: num, sum 3. while numnot equal to -1, continue doing: 3.1. Display prompt “Enter positive number” 3.2. Read number from the keyboard 3.3. Display number entered 3.4. if num less than zero, then 3.4.1 continue 3.5. add to sum 4. Display sum Are we there now?
Flowchart 1. Start 2. Declare variables: num, sum 3. while numnot equal to -1, continue doing: 3.1. Display prompt “Enter positive number” 3.2. Read number from the keyboard 3.3. Display number entered 3.4. if num less than zero, then 3.4.1 continue 3.5. add to sum 4. Display sum Test the algorithm!
Burford Furman Professor Dept. of Mech. and Aero. Eng San José State University San Jose, CA 95192-0087 July 20, 2009 Dear Prof. Furman, I’m writing you to see if I can get into ME 30… … Sincerely, Jane Student Title block Date Salutation Body Closing Signature Structure of a C Program • A formal letter has a structure • So does a program in C
Programmer’s block Pre-processor directive Main function (statements go between { } ) Declare and initialize variables While loop(repetition structure) return statement C Code for D&D 3.15c
Programmer’s Block • Include important information (comments) to document the program: • Title • Date • Author • Description • Inputs/Outputs • Algorithm • Revision history Add comments using one of two methods: 1. /* put comment between */ (note: traditional C) 2. // comment (note: single line only) Full program