Visual C - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Visual C

Description:

... Bits: 0-2 not used, 3-Error, 4-Select, 5 ... Base address (data register) is at 0x378 ... No in-depth knowledge of USB hardware or software is required ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 14
Provided by: johnal1
Category:
Tags: base | knowledge | run | up | visual

less

Transcript and Presenter's Notes

Title: Visual C


1
Visual C Hardware interfacing - 1
Topics Serial port Parallel port API
DLLs USB USB Module
2
Visual C Hardware interfacing - 2
  • Visual Studio has a Serial Port control
  • On the Components toolbox tab
  • It is a non visual control.
  • Properties
  • BaudRate 9600,
  • DataBits 8,
  • Parity None,
  • PortName COM1,
  • StopBits One.
  • Event
  • Main event is DataReceived
  • Occurs when data is received from the port

3
Visual C Hardware interfacing - 3
In use Needs using System.IO.Ports Set
properties serialPort1.BaudRate
9600 serialPort1.DataBits
8 Parity and StopBits are enumerated types
serialPort1.Parity (Parity)Enum.Parse(ty
peof(Parity), "None") serialPort1.StopBits
(StopBits)Enum.Parse(typeof(StopBits),
"One") Open device
serialPort1.Open()
4
Visual C Hardware interfacing - 4
Send and receive data serialPort1.WriteLi
ne(textBox1.Text) listBox1.Items.Add(seri
alPort1.ReadLine()) Should really use threads -
one each for Read and Write. Or use DataReceived
event But this is a thread so to write to the
controls use CheckForIllegalCrossThreadCalls
false in the form load event.
5
Visual C Hardware interfacing - 5
e.g private void serialPort1_DataReceived (obje
ct sender, SerialDataReceivedEventArgs e)
listBox1.Items.Add(serialPort1.ReadLine())
6
Visual C Hardware interfacing - 6
Parallel printer port interface. One way of
getting digital I/O. Data register Bits 0-7
data Status Register Bits 0-2 not used,
3-Error, 4-Select, 5-paper out, 6-acknowledge, 7
busy. Control Register Bits 0 strobe,
1-Auto-feed, 2-initialise, 3-select, 4-IRQ
enable, 5-7 not used Base address (data
register) is at 0x378 Status and control at 0x379
and 0x37A. Eight outputs Only a few guaranteed
inputs those from the status register.
7
Visual C Hardware interfacing - 7
Accessing the parallel port Use inpout32.dll
From Lake View Research (www.lvr.com). Provides
direct read and write of the I/O
DllImport("inpout32.dll", EntryPoint
"Out32") public static extern void Output(int
adress, int value) DllImport("inpout32.dll",
EntryPoint "Inp32") public static
extern int Input(int address)
Use Output(port, data) // writes data to
port temp Input(port) // read port, puts data
in temp
8
Visual C Hardware interfacing - 8
USB interfacing The USB port is now the most
popular way of interfacing peripherals to the
PC. Complete design involves hardware / USB
interface PC drivers Understanding protocol and
hardware limitations Difficult
9
Visual C Hardware interfacing - 9
USB interfacing Many manufacturers make USB /
I/O modules One is DLP design use DLP-245PB-G
10
Visual C Hardware interfacing - 10
  • The module features
  • USB 1.0 and 2.0 compatible communication at up
    to 2Mbits/s
  • 18 digital I/O lines (6 as A/D inputs)
  • Programmable Microchip 16F877A PIC
  • Pre-programmed code to interface to USB providing
    access to the I/O, EEPROM and external digital
    temperature sensors
  • Access to the PIC data bus for further expansion.
  • No in-depth knowledge of USB hardware or software
    is required
  • 40-pin DIL pin-out, so further expansion is easy.

11
Visual C Hardware interfacing - 11
The USB interface USB version 2.0 specifies three
modes of operation High speed (480 Mbits/s),
Full speed (12 Mbits/s) and Low speed (1.5
Mbits/s). Device indicates its speed by pulling
D or D- data line high. Power can be taken from
USB bus but limitations The host controls the
bus and initiates controls all messages Up to
127 devices on the bus so a device may not run
full speed. USB Connectors The A-type is
exclusively for a host B-types are for connection
to slaves. A smaller B-type for small
peripherals such as digital cameras.
12
Visual C Hardware interfacing - 12
Module Install drivers and DLL can then use
from C Need to understand protocol like
the assignment!
13
Visual C Hardware interfacing - 13
Write a Comment
User Comments (0)
About PowerShow.com