Você está na página 1de 71

USB

(UNIVERSAL SERIAL BUS)


MC Nicols Quiroz Hernndez

Conectores USB tipo A y B


Tipo A
Macho

Tipo B
Macho

Mini USB

Hembra

Hembra

Micro USB

Nicols Quiroz

Dependiendo del conector, el nmero de pines difiere entre ellos y tambin la disposicin de las seales

USB Velocidades
USB 1.0
La especificacin USB 1.0 (Denominada de Baja Velocidad) es la primera que se estableci en 1996, y debido a su baja velocidad (0.192MB/s) slo se utiliza para dispositivos de interfaz humana como ratones, teclados, trackballs, etc. Su tasa de transferencia es de hasta 1,5 Mbps (192 KB/s). USB 1.1 En 1998, se lanzara una nueva revisin USB 1.1 (Denominada de Velocidad Completa) que mejora la velocidad (hasta 1,5MB/s). Aunque es una mejora, se va volviendo cada vez ms insuficiente para transferir informacin de varios megas de peso a medida que pasa el tiempo. Su tasa de transferencia es de hasta 12 Mbps (1,5 MB/s).
Nicols Quiroz 4

USB Velocidades
USB 2.0
En el 2000 es cuando surge USB 2.0 (Denominada de Alta Velocidad), un interfaz de alta velocidad (60MB/s) que consigue satisfacer las necesidades de transferencia y comienza a ser comercializado para discos duros externos, pendrives, etc. Su tasa de transferencia de hasta 480 Mbps (60 MB/s) pero por lo general es de hasta 125Mbps (16MB/s)

Nicols Quiroz

USB Velocidades
USB 3.0
Tiene una tasa de transferencia de hasta 4.8 Gbps (600 MB/s). Esta especificacin es diez veces mas veloz que la anterior 2.0 y se lanz a mediados de 2009 por USB Implementers Forum. Aunque actualmente cualquier distribucin GNU/Linux, Windows Vista y Windows 7 son capaces de soportar el nuevo estndar, sin embargo, an no hay hardware disponible. La velocidad del bus es diez veces ms rpida que la del USB 2.0, debido a que han incluido 5 conectores extra, desechando el conector de fibra ptica propuesto inicialmente, y ser compatible con los estndares anteriores. Se espera que los productos fabricados con esta tecnologa lleguen al consumidor entre 2009 y 2015.

Nicols Quiroz

USB Velocidades
USB 1.0: baja velocidad (hasta 1.5Mbit/seg) usado en dispositivos de interfaz humana (HID) como ratones y teclados.
USB 2.0: Alta Velocidad (hasta 480Mbit/seg) unos 60Mg/seg. USB 3.0: Giga Velocidad, en fase experimental, (hasta 4.8Gbit/seg) unos 600 Mg/seg. Los buses son mucho ms rpido debido a la incorporacin de una fibra ptica al enlace de cobre.
Nicols Quiroz 7

Datos USB
La transmisin del USB se realiza mediante un cable de cobre de par trenzado con una impedancia de unos 90 ohms llamados D+ y D-. Estos pueden dar energa a dispositivos externos, con una tensin de 5V y un mximo de corriente de 500mA.
Existe actualmente en el mercado el dispositivo llamado USB OTG (On The Go), permitiendo actuar a un dispositivo como una PDA como servidor del enlace de datos, es por ello que podemos conectar a la PDA otros dispositivos USB como teclados o ratones.

Nicols Quiroz

Terminologa
Host: Dispositivo maestro que inicia la comunicacin (Generalmente la computadora).

Hub: Dispositivo que contiene uno o mas conectores o conexiones internas hacia otros dispositivos USB, el cual habilita la comunicacin entre el host y con diversos dispositivos. Cada conector representa un puerto USB.

Nicols Quiroz

Puntos terminales (Endpoints)


Es una localidad especifica dentro del dispositivo. El Endpoint es un buffer que almacena mltiples bytes dentro del microcontrolador. Todos lo dispositivos deben soportar el punto terminal 0. Este punto terminal es el que recibe todo el control y la peticiones de estado durante la enumeracin cuando el dispositivo esta sobre el bus.

Nicols Quiroz

10

Enumeracin
Cuando se conecta un dispositivo USB a la PC se produce el proceso de Enumeracin, el cual consiste en que el host le pregunta al dispositivo que se presente y le diga cuales son sus parmetros, tales como:
Consumo de energa expresada en unidades de Carga Numero y tipos de Puntos terminales Clase del producto. Tipo de transferencia Razn de escrutinio, etc.

El proceso de enumeracin es inicializado por el host cuando detecta que un nuevo dispositivo que ha sido adjuntado al Bus. El host le asigna una direccin al dispositivo adjuntado al bus y habilita su configuracin permitiendo la transferencia de datos sobre el bus.
Nicols Quiroz 11

Modos de Transferencia
Tuberas (Pipes): Es un enlace virtual entre el host (la PC) y el dispositivo USB, este enlace configura los parmetros asociados con el ancho de banda, que tipo de transferencia se va a utilizar (Control, Bulk, Iscrona o Interrupt) direccin del flujo de datos y el mximo y/o mnimo tamao de los paquetes.
Cada enlace est caracterizado por su banda de paso (Token), su tipo de servicio, el nmero de punto terminal (End Point) y el tamao de los paquetes. Estos enlaces se definen y crean durante la inicializacin del USB. Siempre existe un enlace virtual 0 que permite tener acceso a la informacin de configuracin del perifrico USB (estado, control e informacin).
Nicols Quiroz 12

Modo de Transferencia Control


Modo utilizado para realizar configuraciones, existe siempre sobre el Punto terminal 0 (EndPoint 0). Todos los dispositivos USB deben soportar este tipo de transferencia. Los datos de control sirven para configurar el perifrico en el momento de conectarse al USB. Algunos drivers especficos pueden utilizar este enlace para transmitir su propia informacin de control. Este enlace no tiene prdida de datos, puesto que los dispositivos de deteccin y de recuperacin de errores estn activos a nivel USB.

Nicols Quiroz

13

Modo de Transferencia Bulk


Este modo se utiliza para la transmisin de importantes cantidades de informacin. Como el tipo control, de este enlace no tiene prdida de datos. Este tipo de transferencia es til cuando la razn de transferencia no es critica como por ejemplo , el envi de un archivo a imprimir o la recepcin de datos desde un escner. En estas aplicaciones, la transferencia es rpida, pero puede esperar si fuera necesario. Solo los dispositivos de media y alta velocidad utilizan este tipo de transferencia.

Nicols Quiroz

14

Modo de Transferencia Interrupt


Modo utilizado para transmisiones de pequeos paquetes, rpidos, orientados a percepciones humanas (ratn, punteros). Este tipo de transferencia son para dispositivos que deben recibir atencin peridicamente y lo utilizan los dispositivos de baja velocidad. Este tipo de transmisin garantiza la transferencia de pequeas cantidades de datos. El tiempo de respuesta no puede ser inferior al valor especificado por la interfaz. El ratn o cualquier otro dispositivo apuntador es una aplicacin tpica de este modo de transmisin.

Nicols Quiroz

15

Modo de Transferencia Iscrona


Tambin llamado Flujo en tiempo real, este modo es utilizado para la transmisin de audio o video comprimido. Este tipo de transmisin funciona en tiempo real. Este es el modo de mayor prioridad. La transmisin de la voz es un ejemplo de esta aplicacin. Si sta no se transmite correctamente, pueden llegar a orse parsitos (glich) y la aplicacin puede detectar ciertos errores de los llamados underruns.

Nicols Quiroz

16

PIC utilizado PIC18F4550


Vamos a usar un PIC 18F4550 que gestione mediante software la comunicacin USB2.0 con la computadora, tambin se puede usar un PIC18F2550,
Tambin hay que configurar dos parmetros esenciales en todo dispositivo que son el VID y PID. VID (Vendor ID): Es el identificador de la empresa. Cada empresa tiene un identificador, el cual puede vender diferentes productos a los que se les incluye el ID. PID (Product ID): Es el identificador del producto. Por tanto un dispositivo tendr un VID e ID fijos que les hace nicos con lo que no pueden sufrir incompatibilidad con otros dispositivos.
http://www.pcidatabase.com
Nicols Quiroz 17

USB pipes and endpoints

It consists of a big pipe (12 Mbps) and up to 127 small pipes. Each of the small pipes connects to a USB device. There are 7 address bits in the USB token which can address up to 128 devices. However, address 000 0000B, called the USB default address, is used for all devices when they are first attached. Thus USB can support up to 127 devices. Each of the small pipes connected to a USB device can be further divided into smaller pipes. There can be up to 16 pairs of these tiny pipes from a single small pipe. This is because there are 4 "endpoint" bits in a USB token and the token can be identified as IN or OUT tokens.
Nicols Quiroz 18

USB Transfer Types


There are four USB transfer types:
1. 2. 3. 4. Control Isochronous Interrupt Bulk

Nicols Quiroz

19

Control Transfer
Control transfers are bi-directional and intended to support configuration, command or status communications between the host and functions.
A control transfer consists of 2 or 3 stages: a setup stage, data stage (may or may not exist) and status stage. In the setup stage, the host sends a request to the function. In the data stage, data transfer occurs in the direction as indicated in the setup stage, and in the status stage, the function returns a handshake to the host. Each USB device is required to implement the endpoint pair 0 as control transfer endpoints. It is used to exchange information when the device is first attached to the host.

Nicols Quiroz

20

Isochronous Transfer
Isochronous transfer can be uni-directional or bi-directional. It is intended to be used to transfer information that requires a constant rate and can tolerate errors. A good application example of this transfer type is 64 kbps Pulse Code Modulation (PCM) voice data. The voice data requires a constant rate and can tolerate errors (typically up to a bit error rate of 1x10-3).
Isochronous transfer has the following characteristics: guaranteed access to USB with bounded latency, and no retrying in case of a delivery failure due to error. The maximum packet size for isochronous transfer is 1023 bytes per USB frame of 1 ms. This implies that the maximum transfer achievable using isochronous transfer is 8,184 Mbps.
Nicols Quiroz 21

Interrupt transfer
Interrupt transfer is uni-directional and only inputs to the host. It is used to support data transfers that are small in size and happen infrequently. The interrupt transfer of USB is of a polling type; that is, the host asks if the interrupt endpoints have any data to send according to the frequency requested by the endpoints. For full speed devices, the endpoint can specify the polling period of 1 ms to 255 ms. For low speed devices, the polling period is from 10 ms to 255 ms. Thus, the fastest polling frequency is 1 kHz for full speed devices. In case of delivery failure due to errors, a retry of transfer will be carried out in the next polling period. A good example of a device using interrupt transfer is a keyboard, where it sends a small amount of data to the host when a key is pressed.
Nicols Quiroz 22

Bulk Transfer
The bulk transfer can be uni- or bi-directional. It is used to
support endpoints that need to communicate large amounts of data accurately but where the time of delivery is not critical. The bulk transfer is designed to claim unused bandwidth of the USB, and therefore the provision of USB access time to bulk transfers is on a bandwidth available basis. In case of delivery failure due to errors, the transfer

is retried. A typical usage is a scanner, where a large


amount of data needs to be delivered accurately, but not immediately.

Nicols Quiroz

23

Connection of external resistors in a full speed device

For low speed devices, the 1.5 k 5% resistor must be tied from the D- wire to a voltage source between 3.0 and 3.6 v.

Nicols Quiroz

24

Power Supply from USB Wires


The voltage supply is between 4.75v-5.25v.
A bus-powered device can draw a maximum of 500 mA. The definition of a bus-powered device is that the device draw current from the USB bus directly. Devices that have their own power supply are called self-powered devices. Before the requested amount of current is granted by the USB host, the device must draw no more than 100 mA from the USB when it first attaches to the bus. For devices that are attached to a bus-powered hub, the maximum amount of current supply permitted is 100 mA.

Nicols Quiroz

25

USB Packet Formats


USB packets fit into one of these types:
Token SOF Data Handshake Special packets.

Nicols Quiroz

26

Token Packets
USB transaction are always initiated by the host and are started with a token packet in the format shown in figure:
SYNC PID ADDR ENDP CRC

SYNC
All packets begin with a synchronization (SYNC) field. It is used by the input circuitry to align incoming data with the local clock and it is 8 bits in length.

PID
A packet identifier (PID) immediately follows the SYNC field. A PID consists of four bits followed by a four-bit check field, as shown in figure:
PID0 PID1 PID2 PID3 PID0 PID1 PID2 PID3

Nicols Quiroz

27

Token Packets
The PID indicates the type of packet that is transmitted (differentiated by PID0 and PID1); either token, data, handshake or special packet.

These four types of


packets are subdivided into various identifiers (differentiated by PID2 and PID3):

Packet type PID Name PID3:PID2 PID1:PID0 Token Token SOF Token Data Data OUT IN SOF SETUP DATA0 DATA1 00 10 01 11 00 10 01 01 01 01 11 11

Handshake
Handshake Handshake Special
Nicols Quiroz

ACK
NAK STALL PRE

00
10 11 11

10
10 10 00
28

Token Packets
ADDR
The 7-bit function address (ADDR) field specifies which device the packet is intended for. The host assigns a unique address to each device during USB enumeration process when it is first attached to the bus.

ENDP
The 4-bit endpoint (ENDP) further specifies which tiny pipe of the device the packet is intended for. For example, a device has endpoint 0 and endpoint 1 configured, the host can choose to communicate to endpoint 0 of this device at this instant, ignoring endpoint 1.

CRC
Cyclic Redundancy Checks (CRCs) provide error checking for the non-PID fields of the USB packet. The PID is not protected by this CRC as it has self error checking.
Nicols Quiroz 29

Start of Frame Packets


Start of Frame (SOF) packets, as shown in figure, are broadcast by the host once every 1.00 ms 0.05.
SYNC PID Frame Number CRC

Nicols Quiroz

30

Data Packets
The host performs the management of the bus, and devices respond to requests from the host. If the host requests information from a device it will send an IN token addressed to that device endpoint and the device will response with a USB data packet. The format of the data packet is as shown in figure, with the PID indicating DATA0 or DATA1.
SYNC PID DATA CRC

If the transfer type of this particular endpoint is bulk, control or interrupt, the host will response with an acknowledgment when it receives the data without error. If the transfer type is isochronous, no handshake packet will be sent. The host will send an OUT token followed by a data packet if it wishes to transfer data to the device.
Nicols Quiroz

31

Handshake Packets
The handshake packets consist of only a PID, as shown in figure. They are used to report ACK, NACK or STALL (as indicated by the PID) for transactions that require handshakes.

SYNC

PID

Nicols Quiroz

32

Special Packets
The special preamble (PRE) packet is sent by the host when it wishes to communicate to low speed devices. The host will send this PRE packet first, before sending low speed 1.5 Mbps packets to communicate with low speed devices.

Nicols Quiroz

33

USB Protocol by Transfer Types

Control Transfers
Control transfers have two or three stages:
Setup Data (may or may not be required) Status stage

The best way to understand how a control transfer works is to look at an example, as shown in figure. It shows a complete control transfer between a function and a host, as captured by a CATC USB bus analyzer.

Nicols Quiroz

35

178

Sync (0000001) SOF(0x A5) Frame#(0x 12C)CRC5(0x1F)

Nicols Quiroz

36

MC Nicols Quiroz

COMUNICACIN USB 2.0 PC <------> PIC


Nicols Quiroz 37

Ejemplo Comunicacin USB


Realizar una interfaz con la PC a travs del puerto USB y un PIC18F4550.
1. Para controlar un led 2. Para controlar dos leds (verde y rojo) 3. Motor Realizar un programa en VC++ 6
Una interfaz de usuario para controlar led

Un programa en PICC para el microcontrolador Realizar un circuito para la comunicacin USB Instalar el driver

Nicols Quiroz

38

Pasos para realizar el programa en C++


Crear un nuevo proyecto
Basado en un cuadro de dialogo Copiar los archivos siguientes en el directorio raz del proyecto: usb2550.dll, usb2550.lib, usb2550.h, USB.cpp y USB.h Agregar los archivos siguientes al proyecto: USB.cpp, usb2550.h, y USB.h Se enlaza la librera usb2550.lib.
Barra de herramientas: Project -> Setting o se pulsa Alt+F7, donde saldr el cuadro de dilogo: Project Settings. Ir pestaa Link -> En Object/library modules escribir usb2550.lib y oprimir OK.

Con esto ya se tiene enlazado el proyecto con las MFC y la librera de USB de microchip.
Nicols Quiroz 39

Lo primero es crear un objeto que contenga las propiedades de las libreras USB. Abrir el archivo PicUSBDlg.h y aadir las siguientes directivas e instanciacin del objeto USB:
#include "usb.h" #include "usb2550.h"

Y agregar un miembro pblico a la clase public: USB MiUSB;


Nicols Quiroz 40

Se muestra el archivo PicUSBDlg.h


Donde se agregaron las directivas, y la declaracin del objeto MiUSB de la clase USB.
// PicUSBDlg.h: archivo de encabezado // #pragma once #include "afxwin.h" #include "usb.h" #include "usb2550.h" // Cuadro de dilogo de CPicCalculadoraUSBDlg class CPicUSBDlg : public CDialog { ..... ..... ..... DECLARE_MESSAGE_MAP() public: USB MiUSB; //Esto es mi objeto USB }

Nicols Quiroz

41

Cdigo para botones


Agregar un 2 botones con caption: Led O&N y Led O&FF
Agregar dos mtodos para el evento clic. Para botn Led ON: OnBtnLedOn() con el siguiente cdigo:
Utilizar el mtodo miUSB.SendPacket(Arreglo, Tam_bytes) Esta funcin enviar un arreglo Arreglo de bytes de longitud Tam_bytes, por el puerto USB.
void CPicUSBDlg::OnBtnLedOn() { // TODO: Agregue aqu su cdigo BYTE Datos[1]; Datos[0]=1; MiUSB.SendPacket(Datos,1); }

Para el botn Led_OFF slo


cambia el dato enviado Datos[0]=0;

Nicols Quiroz

42

Funciones para enviar y recibir datos


Recibir datos desde el PIC
void ReceivePacket(BYTE *ReceiveData, DWORD *ReceiveLength); ReceiveData Bfer donde se almacenan los datos recibidos ReceiveLength- Cuantos datos se reciben Enviar datos al PIC void SendPacket(BYTE *SendData, DWORD SendLength);

SendData- Direccin de los datos a enviar


SendLength- cantidad de datos a enviar.

Nicols Quiroz

43

Archivo USB.cpp
Verificar que al inicio del archivo USB.cpp
Que los Ids son "vid_04d8&pid_0011"; Estos valores deben coincidir con el programa desarrollado para el PIC.
// Global Vars PCHAR vid_pid = "vid_04d8&pid_0011"; //VID y PID PCHAR out_pipe= "\\MCHP_EP1"; PCHAR in_pipe= "\\MCHP_EP1"; HANDLE myOutPipe; HANDLE myInPipe;

Nicols Quiroz

44

Las libreras suministradas


Pic_usb.h: driver de capa hardware de la familia PICl6C765. Pic_l8usb.h: driver de capa hardware de la familia PIC18F4550. usbn960x.h: driver de capa hardware para el dispositivo externo USBN9603/USBN9604. De esta forma, se puede utilizar el bus USB en cualquier PIC. Usb.h: definiciones y prototipos utilizados en el driver USB. usb.c: El USB stack, que maneja las interrupciones; USB y el USB Setup Requests en Endpoint 0. usb-cdc.h: driver que permite utilizar una clase de dispositivo CDC USB, emulando un dispositivo RS232 y lo muestra como un puerto COM en Windows.

Las funciones ms importantes


usb_init(): inicializa el hardware USB. Espera en un bucle infinito hasta que el perifrico USB es conectado al bus (aunque eso no significa que ha sido enumerado por el PC). Habilita y utiliza la interrupcin USB.
usb_task(): Si se utiliza una deteccin de conexin para la inicializacin, entonces se debe llamar peridicamente a esta funcin para controlar el pin de deteccin de conexin. Cuando el PIC es conectado o desconectado del bus, esta funcin inicializa el perifrico USB o resetea el USB stack y el perifrico.

Funciones USB
usb_enumerated: Devuelve un TRUE si el dispositivo ha sido enumerado por el PC y, en este caso, el dispositivo entra en modo de operacin normal y puede enviar y recibir paquetes de datos.
Existen funciones especficas para CDC, entre ellas: usb_cdc_putc(c): Es idntica a put(c) y enva un carcter. Coloca un carcter en el bfer de transmisin; en el caso de que est lleno esperara hasta que pueda enviarlo. usb_cdc_getc(c): Es idntica a get(c) y lee un carcter. Recibe un carcter del bfer de transmisin; y el caso de estar vaco esperar hasta que se reciba.

Programacin PIC
USB 2.0 Microchip

Microchip permite mediante la programacin de sus PIC realizar una comunicacin PIC<---->PC de forma sencilla y eficaz. Utilizando la librera MPUSBAPI, para escribir y leer en el PIC. La velocidad es de hasta 12Mbit/seg.

Nicols Quiroz

49

Material
1 PIC18F4550
1 cristal de 12 MHz 1 capacitor electroltico de 47uF/16V 2 capacitores de 15 pF 1 conector USB tipo A macho 1 cable con 4 hilos (1 m) 1 tira de pines (solo 4 pines)

2 resistencias de 330 Ohms


2 Leds (verde y rojo)

Nicols Quiroz

50

Diagrama elctrico del PIC18F4550


Checar las conexiones para el pic de 40 pines.
Conectar los leds a los pines Rojo -> pin 40 (RB7) Verde -> pin 39 (RB6)

Nicols Quiroz

51

PIC
Programacin del PIC se utiliza el compilador PIC C de la empresa CCS.
El cdigo principal para crear nuestro USB 2.0 es el siguiente:

Nicols Quiroz

52

Relevant Functions
usb_init()
Initializes the USB hardware. Will then wait in an infinite loop for the USB peripheral to be connected to bus (but that doesn't mean it has been enumerated by the PC). Will enable and use the USB interrupt. usb_task() If you use connection sense, and the usb_init_cs() for initialization, then you must periodically call this function to keep an eye on the connection sense pin. When the PIC is connected to the BUS, this function will then perpare the USB peripheral. When the PIC is disconnected from the BUS, it will reset the USB stack and peripheral. Will enable and use the USB interrupt. usb_enumerated() Returns TRUE if the device has been enumerated by the PC. If the device has been enumerated by the PC, that means it is in normal operation mode and you can send/receive packets.

Nicols Quiroz

53

Relevant Functions
usb_put_packet(endpoint, data, len, tgl)
Places the packet of data into the specified endpoint buffer. Returns TRUE if success, FALSE if the buffer is still full with the last packet.

usb_get_packet(endpoint, ptr, max)


Reads up to max bytes from the specified endpoint buffer and saves it to the pointer ptr. Returns the number of bytes saved to ptr.

usb_kbhit(endpoint)
Returns TRUE if the specified endpoint has data in it's receive buffer

Nicols Quiroz

54

usb_put_packet(endpoint, data, len, tgl)


usb_put_packet(1, data, 1, USB_DTS_TOGGLE); endpoint-> 1, EP1 a la pC data-> direccin del bfer de datos len -> cuandos se envian en bytes tgl -> USB_DTS_TOGGLE

Nicols Quiroz

55

Checar los IDs


vendor id = 0x04D8 y product id = 0x0011 en el archivo PicUsb.h
//////////////////////////////////////////////////////////////////
/// start device descriptors ////////////////////////////////////////////////////////////////// //device descriptor char const USB_DEVICE_DESC[] ={

USB_DESC_DEVICE_LEN,
0x01, 0x10,0x01, 0x00, 0x00, 0x00,

//the length of this report

//constant DEVICE (0x01) //usb version in bcd //class code (if 0, interface defines class. FF is vendor defined) //subclass code //protocol code

USB_MAX_EP0_PACKET_LENGTH, //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8)

0xD8,0x04, 0x11,0x00,
0x01,0x00, 0x01, 0x02, 0x00, };

//vendor id (0x04D8 is Microchip) //product id, puede ser el 0x0011


//device release number

//index of string description of manufacturer. therefore we point to string_1 array (see below) //index of string descriptor of the product //index of string descriptor of serial number

USB_NUM_CONFIGURATIONS //number of possible configurations

Nicols Quiroz

56

void main(void) { int8 datos[3]; //declaramos variables

Cdigo en el PIC
//inicializamos el USB
//habilita periferico usb e interrupciones //esperamos hasta que el PicUSB sea configurado por el host //si el PicUSB est configurado //si el endpoint contiene datos del host

usb_init();
usb_task(); while (TRUE) {

usb_wait_for_enumeration(); if(usb_enumerated())

{
if (usb_kbhit(1)) { usb_get_packet(1, datos, 1); //obtiene el paquete de tamao 1 bytes del EP1 //y almacenamos en datos

if (datos[0] == 0)
{ } if (datos[0] == 1) // Modo_Led { output_high(PIN_B7); //// Enciende led output_low(PIN_B7); // Apaga led

}
} } } }
Nicols Quiroz 57

Elementos de potencia
MC Nicols Quiroz

Circuito para disparar un Rel

Nicols Quiroz

59

SEVEN DARLINGTON ARRAYS ULN2001A-ULN2002A ULN2003A-ULN2004A

SEVEN DARLINGTONS PER PACKAGE OUTPUT CURRENT 500mA PER DRIVER (600mA PEAK) . OUTPUT VOLTAGE 50V

INTEGRATED SUPPRESSION DIODES FOR INDUCTIVE


LOADS OUTPUTS CAN BE PARALLELED FOR HIGHER CURRENT

TTL/CMOS/PMOS/DTL COMPATIBLE INPUTS


INPUTS PINNED OPPOSITE OUTPUTS TO SIMPLIFY LAYOUT

Nicols Quiroz

60

SEVEN DARLINGTON ARRAYS ULN2001A-ULN2002A ULN2003A-ULN2004A

Nicols Quiroz

61

Typical application Lamp

Typical application Motor

Nicols Quiroz

62

EIGHT DARLINGTON ARRAYS ULN2801A, ULN2804A - ULN2805A ULN2802A - ULN2803A


EIGHTDARLINGTONS WITH COMMON EMITTERS OUTPUT CURRENT TO 500 mA OUTPUT VOLTAGE TO 50 V INTEGRAL SUPPRESSIONDIODES VERSIONS FOR ALL POPULARLOGIC FAMILIES OUTPUT CAN BE PARALLELED INPUTS PINNED OPPOSITE OUTPUTS TO SIMPLIFY BOARD LAYOUT

Nicols Quiroz

63

Puente H Direccin de motor de DC

Nicols Quiroz

64

Quadruple Half H 4 drivers L293, L293D, L298(2 amp)


Wide Supply-Voltage Range: 4.5 V to 36 V Separate Input-Logic Supply Internal ESD Protection Thermal Shutdown Output Current 1 A Per Channel (600 mA for L293D)

Peak Output Current 2 A Per Channel (1.2 A for L293D)


Output Clamp Diodes for Inductive Transient Suppression (L293D)

Nicols Quiroz

65

Manejo de motores L293

VCC1 Seal TTL (5V) o voltaje de control. VCC2 Voltaje de alimentacin del motor (5V, 12V, etc.)
Nicols Quiroz

Terminales 1 y 9 habilitacin de los drivers. Terminales 2,7,15, y 10 seales de control.


66

Bidirectional DC Motor Control

Nicols Quiroz

67

Motores a pasos
Motores de reluctancia variable Motores de imn permanente - unipolares - bipolares

Motores multifases

Diagrama de las bobinas de un motor a pasos

Nicols Quiroz

69

Unipolar pasos (wave drive)


Paso A B C D

Paso simple:
Esta secuencia de pasos es la mas simple de todas y consiste en activar cada bobina una a una y por separado, con esta secuencia de encendido de bobinas no se obtiene mucha fuerza ya que solo es una bobina cada vez la que arrastra y sujeta el rotor del eje del motor.

1 0 0 0

0 1 0 0

0 0 1 0

0 0 0 1

Nicols Quiroz

70

Bipolar Stepping-Motor Control

Nicols Quiroz

71

Você também pode gostar