logging in or signing up PB 6th IntroductoryInterfac ingAndElectronics Nivedi Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINTLite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 381 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: November 07, 2007 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Introductory Interfacing & Electronics: Introductory Interfacing & Electronics Peter Beens peter@beens.org Presented at Durham College November, 2004Overview: Overview This presentation covers a basic introduction to interfacing with the parallel port and just enough electronics to keep you from damaging your computer.Interfacing Introduction: Interfacing IntroductionInterfacing Overview: Interfacing Overview Computer Interface Peripheral Wires ICs Resistors Capacitors Transistors Connectors LEDs Motors Lights Robots Joystick Music BoxWhat Ports Can We Interface?: What Ports Can We Interface? Parallel Port (AKA Printer Port) Serial Port (AKA RS232) Keyboard Port USB??? (Hopefully soon…) We will concentrate on the Parallel PortIdentifying the Parallel Port: Identifying the Parallel Port It’s the female connector with 25 pins “DB25” Can be on a cardElectronics Introduction: Electronics IntroductionThree Main Invisible Electrical Properties: Three Main Invisible Electrical Properties Voltage, V, Volts Provides the “push” Current, I, Amperes (Amps) Flow of Electrons Amount of Current is dependent on Voltage and Resistance Resistance, R, Ohms (S) Limits the amount of currentSafe Current & Voltage Levels: Safe Current & Voltage Levels Voltage: 30 V Voltages inside a computer do not exceed 12 V, except at the power supply and power switch on older computers, which are at 120 V. Be careful in these areas! Current: 5 mA (0.005 Amperes)Voltage Sources: Voltage SourcesCurrent: Current Is the flow of electrons Direction depends on conventionOhm’s Law: Ohm’s Law “Current (I) is proportional to Voltage (V) and inversely proportional to Resistance (R)”Ohm’s Law & Power Wheel: Ohm’s Law & Power Wheel Reproduced by permission of Tony van Roon, 2002 http://www.uoguelph.ca/~antoonKirchhoff’s Laws: Kirchhoff’s Laws Kirchhoff’s Voltage Law “The sum of the voltage drops equals the applied voltage”, or… “The sum of the voltage drops around a closed loop equals zero” Used in series circuits Kirchhoff’s Current Law “The current entering a junction must equal the current leaving the junction” Use in parallel circuits. Light Emitting Diodes (LEDs): Light Emitting Diodes (LEDs) A type of diode designed to emit light Can be visible or IR 2 V voltage drop Typically draws 20 mA (0.020 A) Schematic Symbol…Resistors: Resistors Can be rated by… Resistance (Ohms, S) Tolerance (% of nominal value) Power Rating (Watts) Schematic Symbol…Resistor Types: Resistor TypesResistor Colour Code: Resistor Colour Code Reproduced by permission of Tony van Roon, 2002 http://www.uoguelph.ca/~antoon Resistor Colour Code Example: Resistor Colour Code Example 1st band: orange = 3 2nd band: orange = 3 3rd band: red = 2 (i.e. 102) 4th band: gold = 5% 33 x 102 = 3300 S = 3.3 kSResistor Power Ratings: Resistor Power RatingsSeries Circuits: Series Circuits One current path, therefore the current is the same everywhere Total resistance is the sum of the individual resistancesParallel Circuits: Parallel Circuits More than one current path Total current is the sum of the individual currentsThe Parallel Port – The Hardware: The Parallel Port – The HardwareParallel Port Specifications: Parallel Port Specifications Output Voltage 0V for “low” 5V for “high” TTL (Transistor-Transistor Logic) Output Current Limitation 10-15 mA (careful!)Parallel Port Pinout: Parallel Port Pinout Graphic from http://www.doc.ic.ac.uk/~ih/doc/par/Output Table: Output TableInput Table: Input TableInterfacing an LED Circuit: Interfacing an LED CircuitUnderstanding the LED Circuit: Understanding the LED Circuit The parallel port output is 5V A standard red LED needs ~20 mA and drops about 2 V A resistor is needed to “drop” the excess voltageDoing the Math: Doing the Math From Ohm’s Law From Kirchhoff’s Voltage Law Currents equal in a series cctMotor Control: Motor Control (A stepper motor would require more outputs)High Current Control: High Current Control Use a relayParallel Port Connector Tip: Parallel Port Connector TipThe Programming: The ProgrammingTuring: Preparing for Interfacing: Turing: Preparing for Interfacing Turing is already prepared for interfacing with the parallel port No preparation necessary!Turing: Turning On the LED: Turing: Turning On the LED Parallelput(value) Parallelput(1) turns on the 1 bit (D0) Parallelput(255) turns on all bits (D0-D7)Turing: Turning Off the LED: Turing: Turning Off the LED Parallelput(0)Turing: Flashing the LED: Turing: Flashing the LED loop parallelput (1) delay (250) parallelput (0) delay (250) end loopTuring: LED Walking: Turing: LED Walking loop % loops up for i : 0 .. 7 parallelput (2 ** i) delay (500) end for % loops down for decreasing i : 6 .. 1 parallelput (2 ** i) delay (500) end for end loopJava: Preparing for Interfacing: Java: Preparing for Interfacing Download http://www.geocities.com/Juanga69/parport/parport-win32.zip Extract the parport folder to your classes folder Copy parport.dll to you bin folder import parport.ParallelPort; ParallelPort lpt1 = new ParallelPort (0x378);Java: Output: Java: Output ParallelPort lpt1 = new ParallelPort(0x378); int byteVal = 255; lpt1.write(byteVal); System.out.println("Output to port: " + byteVal);Java: Input: Java: Input ParallelPort portIn = new ParallelPort (0x378); int in; in = portIn.read (); System.out.println (in + " is currently being input.");Java Delay Method: Java Delay Method private static void delay (int mS) { try { Thread.sleep (mS); } catch (Exception e) { ; } }Delphi: Preparing for Interfacing: Delphi: Preparing for Interfacing Download io.dll from http://geekhideout.com/downloads/io.dll Copy into project folderDelphi: Output: Delphi: Output procedure PortOut(Port : Word; Data : Byte); stdcall; external 'io.dll'; procedure TForm1.Button1Click(Sender: TObject); begin PortOut(888,1); end;Delphi: Input: Delphi: Input function PortIn(Port:Word):Byte; stdcall; external 'io.dll'; procedure TForm1.Button3Click(Sender: TObject); var InValue : Byte; begin InValue := PortIn(889); label1.Caption := IntToStr(InValue); end; Delphi Delay Procedure: Delphi Delay Procedure procedure xSleep(milliseconds: LongInt); var iTemp : Longint; Begin iTemp:= GetTickCount + milliseconds; while GetTickCount < iTemp do Application.ProcessMessages End;Assembler: Output: Assembler: Output MOV DX,0378H MOV AL,n OUT DX,AL Where n is the value you want to output.Resources: ResourcesWeb Resources: Web Resources http://www.epanorama.net/circuits/parallel_output.html http://www.lvr.com/jansfaq.htm http://www.doc.ic.ac.uk/~ih/doc/par/ http://www.southwest.com.au/~jfuller/delphi/delphi1.htmTextbook References: Textbook References Computer Engineering: An Activity-Based Approach (Holt) Networks, Interfaces and Integrated Circuits (Holt)Q: Why can't programmers tell the difference between Christmas and Halloween?: Q: Why can't programmers tell the difference between Christmas and Halloween? A: Because DEC25 = OCT31 Contact Information: Contact Information Pete Beens Westlane Secondary School Niagara Falls, ON L2H1T5 905.356.2401 Web: http://www.beens.org Email: peter@beens.org You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
PB 6th IntroductoryInterfac ingAndElectronics Nivedi Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINTLite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 381 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: November 07, 2007 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Introductory Interfacing & Electronics: Introductory Interfacing & Electronics Peter Beens peter@beens.org Presented at Durham College November, 2004Overview: Overview This presentation covers a basic introduction to interfacing with the parallel port and just enough electronics to keep you from damaging your computer.Interfacing Introduction: Interfacing IntroductionInterfacing Overview: Interfacing Overview Computer Interface Peripheral Wires ICs Resistors Capacitors Transistors Connectors LEDs Motors Lights Robots Joystick Music BoxWhat Ports Can We Interface?: What Ports Can We Interface? Parallel Port (AKA Printer Port) Serial Port (AKA RS232) Keyboard Port USB??? (Hopefully soon…) We will concentrate on the Parallel PortIdentifying the Parallel Port: Identifying the Parallel Port It’s the female connector with 25 pins “DB25” Can be on a cardElectronics Introduction: Electronics IntroductionThree Main Invisible Electrical Properties: Three Main Invisible Electrical Properties Voltage, V, Volts Provides the “push” Current, I, Amperes (Amps) Flow of Electrons Amount of Current is dependent on Voltage and Resistance Resistance, R, Ohms (S) Limits the amount of currentSafe Current & Voltage Levels: Safe Current & Voltage Levels Voltage: 30 V Voltages inside a computer do not exceed 12 V, except at the power supply and power switch on older computers, which are at 120 V. Be careful in these areas! Current: 5 mA (0.005 Amperes)Voltage Sources: Voltage SourcesCurrent: Current Is the flow of electrons Direction depends on conventionOhm’s Law: Ohm’s Law “Current (I) is proportional to Voltage (V) and inversely proportional to Resistance (R)”Ohm’s Law & Power Wheel: Ohm’s Law & Power Wheel Reproduced by permission of Tony van Roon, 2002 http://www.uoguelph.ca/~antoonKirchhoff’s Laws: Kirchhoff’s Laws Kirchhoff’s Voltage Law “The sum of the voltage drops equals the applied voltage”, or… “The sum of the voltage drops around a closed loop equals zero” Used in series circuits Kirchhoff’s Current Law “The current entering a junction must equal the current leaving the junction” Use in parallel circuits. Light Emitting Diodes (LEDs): Light Emitting Diodes (LEDs) A type of diode designed to emit light Can be visible or IR 2 V voltage drop Typically draws 20 mA (0.020 A) Schematic Symbol…Resistors: Resistors Can be rated by… Resistance (Ohms, S) Tolerance (% of nominal value) Power Rating (Watts) Schematic Symbol…Resistor Types: Resistor TypesResistor Colour Code: Resistor Colour Code Reproduced by permission of Tony van Roon, 2002 http://www.uoguelph.ca/~antoon Resistor Colour Code Example: Resistor Colour Code Example 1st band: orange = 3 2nd band: orange = 3 3rd band: red = 2 (i.e. 102) 4th band: gold = 5% 33 x 102 = 3300 S = 3.3 kSResistor Power Ratings: Resistor Power RatingsSeries Circuits: Series Circuits One current path, therefore the current is the same everywhere Total resistance is the sum of the individual resistancesParallel Circuits: Parallel Circuits More than one current path Total current is the sum of the individual currentsThe Parallel Port – The Hardware: The Parallel Port – The HardwareParallel Port Specifications: Parallel Port Specifications Output Voltage 0V for “low” 5V for “high” TTL (Transistor-Transistor Logic) Output Current Limitation 10-15 mA (careful!)Parallel Port Pinout: Parallel Port Pinout Graphic from http://www.doc.ic.ac.uk/~ih/doc/par/Output Table: Output TableInput Table: Input TableInterfacing an LED Circuit: Interfacing an LED CircuitUnderstanding the LED Circuit: Understanding the LED Circuit The parallel port output is 5V A standard red LED needs ~20 mA and drops about 2 V A resistor is needed to “drop” the excess voltageDoing the Math: Doing the Math From Ohm’s Law From Kirchhoff’s Voltage Law Currents equal in a series cctMotor Control: Motor Control (A stepper motor would require more outputs)High Current Control: High Current Control Use a relayParallel Port Connector Tip: Parallel Port Connector TipThe Programming: The ProgrammingTuring: Preparing for Interfacing: Turing: Preparing for Interfacing Turing is already prepared for interfacing with the parallel port No preparation necessary!Turing: Turning On the LED: Turing: Turning On the LED Parallelput(value) Parallelput(1) turns on the 1 bit (D0) Parallelput(255) turns on all bits (D0-D7)Turing: Turning Off the LED: Turing: Turning Off the LED Parallelput(0)Turing: Flashing the LED: Turing: Flashing the LED loop parallelput (1) delay (250) parallelput (0) delay (250) end loopTuring: LED Walking: Turing: LED Walking loop % loops up for i : 0 .. 7 parallelput (2 ** i) delay (500) end for % loops down for decreasing i : 6 .. 1 parallelput (2 ** i) delay (500) end for end loopJava: Preparing for Interfacing: Java: Preparing for Interfacing Download http://www.geocities.com/Juanga69/parport/parport-win32.zip Extract the parport folder to your classes folder Copy parport.dll to you bin folder import parport.ParallelPort; ParallelPort lpt1 = new ParallelPort (0x378);Java: Output: Java: Output ParallelPort lpt1 = new ParallelPort(0x378); int byteVal = 255; lpt1.write(byteVal); System.out.println("Output to port: " + byteVal);Java: Input: Java: Input ParallelPort portIn = new ParallelPort (0x378); int in; in = portIn.read (); System.out.println (in + " is currently being input.");Java Delay Method: Java Delay Method private static void delay (int mS) { try { Thread.sleep (mS); } catch (Exception e) { ; } }Delphi: Preparing for Interfacing: Delphi: Preparing for Interfacing Download io.dll from http://geekhideout.com/downloads/io.dll Copy into project folderDelphi: Output: Delphi: Output procedure PortOut(Port : Word; Data : Byte); stdcall; external 'io.dll'; procedure TForm1.Button1Click(Sender: TObject); begin PortOut(888,1); end;Delphi: Input: Delphi: Input function PortIn(Port:Word):Byte; stdcall; external 'io.dll'; procedure TForm1.Button3Click(Sender: TObject); var InValue : Byte; begin InValue := PortIn(889); label1.Caption := IntToStr(InValue); end; Delphi Delay Procedure: Delphi Delay Procedure procedure xSleep(milliseconds: LongInt); var iTemp : Longint; Begin iTemp:= GetTickCount + milliseconds; while GetTickCount < iTemp do Application.ProcessMessages End;Assembler: Output: Assembler: Output MOV DX,0378H MOV AL,n OUT DX,AL Where n is the value you want to output.Resources: ResourcesWeb Resources: Web Resources http://www.epanorama.net/circuits/parallel_output.html http://www.lvr.com/jansfaq.htm http://www.doc.ic.ac.uk/~ih/doc/par/ http://www.southwest.com.au/~jfuller/delphi/delphi1.htmTextbook References: Textbook References Computer Engineering: An Activity-Based Approach (Holt) Networks, Interfaces and Integrated Circuits (Holt)Q: Why can't programmers tell the difference between Christmas and Halloween?: Q: Why can't programmers tell the difference between Christmas and Halloween? A: Because DEC25 = OCT31 Contact Information: Contact Information Pete Beens Westlane Secondary School Niagara Falls, ON L2H1T5 905.356.2401 Web: http://www.beens.org Email: peter@beens.org