Chapter 9 SOFTWARE - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Chapter 9 SOFTWARE

Description:

Commonly have several USB ports in one PC. - Suitable for high storage data. ... How to program Parallel Port using C. The calculation: ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 16
Provided by: Owne8
Category:
Tags: software | chapter | dos

less

Transcript and Presenter's Notes

Title: Chapter 9 SOFTWARE


1
Chapter 9SOFTWARE HARDWARE INTERFACES
2
Outline
  • Introduction on software hardware interfaces
  • Software programming language types
  • Computer ports for communication
  • Interface using C language

3
Software Type
  • Machine Language development software
  • - Assembly, Pbasic, C
  • - For firmware programming purposes
  • High Level
  • - C/C, Cobol, Fortron
  • - HTML, XML, Php etc.
  • Application Level
  • - Visual Basic, LabVIEW, Multimedia
    Developer
  • - Virtual system, interactive, user friendly
  • - User interface

4
Hardware
  • Interface card system (I/O card)
  • Application machines
  • - ATM, Vending, petrol pump etc.
  • Computer communication media
  • - Coxial cable, Fibre optic, RF wave etc.
  • Computer ports and protocol
  • - Parallel port, serial port,
  • Universal Serial Bus (USB) etc.
  • Communication Protocol
  • - RS232, RS422, RS485, TCP/IP etc.

5
Basic Computer Communication ports
  • Serial port
  • - Using for RS232, RS422 and TCP/IP protocol
  • - Commonly DB9 and DB25 pins
  • Parallel port
  • - Using printing purposes
  • - Commonly DB25 pins
  • Universal Serial Bus (USB)
  • - Multi-purposes port
  • - Commonly have several USB ports in one PC.
  • - Suitable for high storage data. Eg
    MPEG,JPEG etc.

6
Serial Ports Pin Configuration
DB9 pin
DB25 pin
7
USB Ports Type
Type A Port
Type B Port
8
Parallel Port
Pin Configuration
9
Parallel Port DB25 Pin details
10
How to program Parallel Port using C
  • The calculation
  • The value that send via program is binary number
  • Data pins configuration and decimal value

11
How to program Parallel Port using C
  • Function in C
  • porttalk need to be installed to set the
    "pt_ioctl.c
  • library. Base address of data for LPT1 is 378
    (0x378)
  • Basic function - OpenPortTalk (),
    outportb(0xBase,0xn), ClosePortTalk ()
  • Formula
  • 0xn
  • which n b0b1b2.
  • Example
  • If Pin 2 and 3 want to be set as HIGH (Logic
    1). So, the n
  • value that need to be stated in the
  • LPT port function in C
  • n 12 3

12
Example program code in C
OpenPortTalk () outportb(base_addr,0x00) //Low
voltage (0-0.3VDC) to all Data ports
(D0-D7) ClosePortTalk () for(x0xlt10x) pr
intf("Output will be HIGH\n") OpenPortTalk
() outportb(base_addr,0x01)//High voltage
(5VDC) to port D0 only ClosePortTalk
() getch() return (0)
include ltstdio.hgt include ltwindows.hgt //call
os (windows)
include
"pt_ioctl.c // talking to device driver include
ltconio.hgt define base_addr 0x378 // initialize
parallel port address main() int k,
x for(k0klt10k) printf("Ouput will be
LOW\n")
13
void main(void) outportb(0x378,0xFF)
Example C program for the motor
void main(void) outportb(0x378,0x01) //pin 2
high outportb(0x378,0x00) //switch off pin
14
Example C program for the motor
includeltstdio.hgt includeltconio.hgt
includeltdos.hgt   main() outportb(0x378,0x00
) ---------STOP MOTOR sleep(2)
outportb(0x378,0x01)---------MOVE MOTOR(CCW)
sleep(2) outportb(0x378,0x02)---------MOVE
MOTOR(CW) sleep(2) outportb(0x378,0x03)-------
--MOVE MOTOR(Break!) sleep(2) return 0
eg sleep(2)-----delay or sleep for 2 seconds eg
delay(500) -------delay for 500
milliseconds
15
References
  • http//www.faqs.org/docs/Linux-HOWTO/Serial-Progr
    amming-HOWTO.html
  • http//www.beyondlogic.org/spp/parallel.htm
  • http//www.epanorama.net/circuits/parallel_output.
    html
  • http//www.experts-exchange.com
    /Programming/Programming_Languages/C
  • http//www.logix4u.net/parallelport1.htm
  • http//www.geocities.com/gear996/sub/parallel.html
Write a Comment
User Comments (0)
About PowerShow.com