Академический Документы
Профессиональный Документы
Культура Документы
Capacitores de 22 microfaradios
Capacitores de 22 picofaradios
Max232
Conector DB9
PIC18F4550
Leds
Resistencias de 330 ohms
8
8
3
Push button
Cristal 8Mhz
Diagrama:
Cdigo de programacin:
char uart_rd;
void main () {
UART1_Init(9600);
Delay_ms(100);
TRISB = 0;
PORTB = 0;
while (1) {
PORTB = uart_rd;
UART1_Write(uart_rd);
}
}
}
Programacion en Labview:
Conclusion:
En esta prctica comenzamos a usar un nuevo PIC programando en un
lenguaje avanzado como el C, usando como interfaz Labview logrando la
comunicacin serial entre el pic y la computadora. Viendo el resultado en el
control de encendido en el puertoB.
Cdigo en C
char uart_rd1, uart_rd2;
unsigned int temp_res;
unsigned int uart_wr1, uart_wr2;
7
void main() {
TRISA = 0XFF;
TRISB = 0;
TRISD = 0;
UART1_Init(9600);
Delay_ms(100);
while (1) {
if (UART1_Data_Ready()) {
temp_res = ADC_read(2);
uart_rd1 = UART1_Read();
uart_wr1 = temp_res;
UART1_Write(uart_wr1);
PORTB = uart_wr1;
Delay_ms(7);
uart_rd2 = UART1_Read();
uart_wr2 = temp_res >> 8;
UART1_Write(uart_wr2);
PORTD = uart_wr2;
Delay_ms(7);
}
}
}
Programacion en Labview:
Conclusion:
Entre ms nos metemos al entorno de programacin, nos damos cuenta lo
poderosa que es esta herramienta, tambin nos ayuda a conocer ms el
lenguaje de programacin en C como ser capaces de disear una tarjeta
adquiridora de datos para Labview.
10
Cdigo en C.
char uart_rd, uart_rd1, uart_rd2;
unsigned int temp_res, temp_res1, temp_res2;
unsigned int uart_wr, uart_wr1, uart_wr2;
void main() {
TRISA = 0XFF;
TRISB = 0;
UART1_Init(9600);
Delay_ms(100);
while (1) {
if (UART1_Data_Ready()) {
temp_res = ADC_read(1);
uart_rd = UART1_Read();
if (uart_rd==64){
uart_wr = temp_res>> 2;
UART1_Write(uart_wr);
}
Delay_ms(7);
temp_res1 = ADC_read(2);
uart_rd1 = UART1_Read();
if (uart_rd1==65){
uart_wr1 = temp_res1>> 2;
UART1_Write(uart_wr1);
}
Delay_ms(7);
temp_res2 = ADC_read(3);
11
uart_rd2 = UART1_Read();
if (uart_rd2==69){
uart_wr2 = temp_res2>> 2;
PORTB=uart_wr2;
UART1_Write(uart_wr2);
}
Delay_ms(7);
}
}
}
Programacion en Labview:
12
Conclusin:
Como podemos ver cada convertidor tiene su propia respuesta, y esto lo
logramos con la programacin en C, esto se puede ver en las llaves en cada
lectura. Labview nos ayuda mucho en la construccin de estas prcticas.
13
Capacitores de 22 pF
Capacitores de 10nF
Cristal oscilador 8MHz
Conector USB (tipo A o tipo B)
Diagrama:
Colocar indicadores (Led) al puerto D
14
Cdigo en C
Programa Principal.
/*
* Project name:
HIDtest2 (USB HID Read & Write Test)
* Copyright:
(c) MikroElektronika, 2005-2008
* Revision History:
20050502:
- initial release;
* Description:
This example establishes connection with the HID terminal that is active
on the PC. Upon connection establishment, the HID Device Name will
appear
in the respective window. The character that user sends to PIC from the HID
terminal will be re-sent back to user.
* Test configuration:
MCU:
PIC18F4550
15
http://ww1.microchip.com/downloads/en/DeviceDoc/39632D.pdf
Dev.Board:
EasyPIC6
http://www.mikroe.com/en/tools/easypic6/
Oscillator:
Ext. Modules:
on-board USB-HID
http://www.mikroe.com/pdf/easypic6/easypic6_manual_v100.pdf#page14
SW:
* NOTES:
(*) Be VERY careful about the configuration flags for the 18F4550 - there's
so much place for mistake!
- Place jumpers J12 in the right position
*/
unsigned char k;
unsigned char userWR_buffer[64], userRD_buffer[64];
const char *text = "MIKROElektronika Compilers ER \r\n";
//*****************************************************************************************
*********
// Main Interrupt Routine
//*****************************************************************************************
*********
void interrupt()
{
HID_InterruptProc();
}
//*****************************************************************************************
*********
16
//*****************************************************************************************
*********
// Initialization Routine
//*****************************************************************************************
*********
void Init_Main()
{
//-------------------------------------// Disable all interrupts
//-------------------------------------INTCON = 0;
INTCON2 = 0xF5;
INTCON3 = 0xC0;
RCON.IPEN = 0;
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;
ADCON1 |= 0x0F;
as digital
CMCON |= 7;
// Disable comparators
TRISE = 0x07;
LATA = 0;
LATB = 0;
LATC = 0;
LATD = 0;
LATE = 0;
//-------------------------------------// Clear user RAM
// Banks [00 .. 07] ( 8 x 256 = 2048 Bytes )
//-------------------------------------}
//*****************************************************************************************
//*****************************************************************************************
// Main Program Routine
//*****************************************************************************************
void main() {
unsigned char i, ch;
Init_Main();
HID_Enable(&userRD_buffer, &userWR_buffer);
Delay_ms(1000); Delay_ms(1000);
while (1) {
k = HID_Read();
i = 0;
while (i < k) {
ch = userRD_buffer[i];
PORTD = ch;
userWR_buffer[0] = ch;
18
= 1;
= 1;
= 2;
// Byte constants
unsigned char const NUM_ENDPOINTS
= 2;
= 47;
= HID_ReportDesc_len;
19
= HID_ReportDesc_len >>
= HID_PACKET_SIZE;
= HID_PACKET_SIZE >>
// Descriptor Tables
unsigned char const DescTables[USB_DEVICE_DESCRIPTOR_ALL_LEN*2] =
{
// Device Descriptor
USB_DEVICE_DESCRIPTOR_LEN, 0,
Device descriptor (always 0x12)
// bLength
USB_DEVICE_DESCRIPTOR_TYPE, 0,
DEVICE descriptor
0x00, 0,
byte)
0x02, 0,
- Length of
// bDescriptorType
// bcdUSB
-1=
//
(high byte)
0x00, 0,
// bDeviceClass
- Zero means each
interface operates independently (class code in the interface descriptor)
0x00, 0,
// bDeviceSubClass
0x00, 0,
// bDeviceProtocol
EP0_PACKET_SIZE, 0,
// bMaxPacketSize0
of a data packet for a control transfer over EP0
0x78, 0,
// idVendor
0x56, 0,
//
0x01, 0,
// idProduct
0x00, 0,
//
0x01, 0,
// bcdDevice
0x00, 0,
//
0x01, 0,
// iManufacturer
0x02, 0,
// iProduct
- maximum size
0x00, 0,
// iSerialNumber
- ( None )
0x01, 0,
// bNumConfigurations
-1
// Configuration Descriptor
USB_CONFIG_DESCRIPTOR_LEN, 0,
Configuration descriptor (always 0x09)
// bLength
USB_CONFIG_DESCRIPTOR_TYPE, 0,
CONFIGURATION descriptor
- Length of
// bDescriptorType
-2=
ConfigDescr_wTotalLength, 0,
// wTotalLength
- Total length of
this config. descriptor plus the interface and endpoint descriptors that are part of
the configuration.
0x00, 0,
//
( high byte)
0x01, 0,
// bNumInterfaces
0x01, 0,
- Number of interfaces
0x00, 0,
configuration ( None )
// iConfiguration
0xA0, 0,
and "Remote wakeup"
// bmAttributes
50, 0,
mA from the bus.
// MaxPower
// Interface Descriptor
USB_INTERF_DESCRIPTOR_LEN, 0,
Interface descriptor (always 0x09)
// bLength
USB_INTERFACE_DESCRIPTOR_TYPE, 0,
INTERFACE descriptor
0x00, 0,
based array
// bInterfaceNumber
0x00, 0,
// bAlternateSetting
NUM_ENDPOINTS, 0,
endpoints used in this interface
- Length of
// bDescriptorType
- Number of interface, 0
- Alternate setting
// bNumEndPoints
0x03, 0,
// bInterfaceClass
0x00, 0,
// bInterfaceSubClass
-4=
- Number of
21
0x00, 0,
// bInterfaceProtocol
0x00, 0,
// iInterface
describes this interface ( None )
- none
// HID Descriptor
USB_HID_DESCRIPTOR_LEN, 0,
HID descriptor (always 0x09)
// bLength
USB_HID_DESCRIPTOR_TYPE, 0,
HID descriptor
0x01, 0,
- Length of
// bDescriptorType
- 0x21 =
0x01, 0,
0x00, 0,
0x01, 0,
0x22, 0,
Low_HID_ReportDesc_len, 0,
High_HID_ReportDesc_len, 0,
// EP1_RX Descriptor
USB_ENDP_DESCRIPTOR_LEN, 0,
descriptor (always 0x07)
// bLength
USB_ENDPOINT_DESCRIPTOR_TYPE, 0,
ENDPOINT descriptor
0x81, 0,
// bDescriptorType
// bEndpointAddress
USB_ENDPOINT_TYPE_INTERRUPT, 0,
Endpoint Type - Interrupt
- length of
- In, EP1
// bmAttributes
Low_HID_PACKET_SIZE, 0,
size - low order byte
// wMaxPacketSize
High_HID_PACKET_SIZE, 0,
high order byte
//
1, 0,
// bInterval
-5=
- max packet
// EP1_TX Descriptor
USB_ENDP_DESCRIPTOR_LEN, 0,
descriptor (always 0x07)
// bLength
- length of
22
USB_ENDPOINT_DESCRIPTOR_TYPE, 0,
ENDPOINT descriptor
0x01, 0,
// bDescriptorType
// bEndpointAddress
USB_ENDPOINT_TYPE_INTERRUPT, 0,
Endpoint Type - Interrupt
- Out, EP1
// bmAttributes
Low_HID_PACKET_SIZE, 0,
size - low order byte
// wMaxPacketSize
High_HID_PACKET_SIZE, 0,
high order byte
//
1, 0,
// bInterval
-5=
- max packet
// HID_Report Descriptor
0x06, 0,
0xA0, 0,
0xFF, 0,
0x09, 0,
0x01, 0,
0xA1, 0,
// COLLECTION (Application)
0x01, 0,
// The Input report
0x09, 0,
0x03, 0,
0x15, 0,
// LOGICAL_MINIMUM (0)
0x00, 0,
0x26, 0,
// LOGICAL_MAXIMUM (255)
0x00, 0,
0xFF, 0,
0x75, 0,
// REPORT_SIZE (8)
0x08, 0,
0x95, 0,
// REPORT_COUNT (2)
23
HID_INPUT_REPORT_BYTES, 0,
0x81, 0,
// INPUT (Data,Var,Abs)
0x02, 0,
// The Output report
0x09, 0,
0x04, 0,
0x15, 0,
// LOGICAL_MINIMUM (0)
0x00, 0,
0x26, 0,
// LOGICAL_MAXIMUM (255)
0x00, 0,
0xFF, 0,
0x75, 0,
// REPORT_SIZE (8)
0x08, 0,
0x95, 0,
// REPORT_COUNT (2)
HID_OUTPUT_REPORT_BYTES, 0,
0x91, 0,
// OUTPUT (Data,Var,Abs)
0x02, 0,
// The Feature report
0x09, 0,
0x05, 0,
0x15, 0,
// LOGICAL_MINIMUM (0)
0x00, 0,
0x26, 0,
// LOGICAL_MAXIMUM (255)
0x00, 0,
0xFF, 0,
0x75, 0,
// REPORT_SIZE (8)
0x08, 0,
24
0x95, 0,
// REPORT_COUNT (2)
HID_FEATURE_REPORT_BYTES, 0,
0xB1, 0,
// FEATURE (Data,Var,Abs)
0x02, 0,
// End Collection
0xC0, 0
// END_COLLECTION
};
//******************************************************************************
unsigned char const LangIDDescr[8] = {
0x04, 0,
USB_STRING_DESCRIPTOR_TYPE, 0,
0x09, 0,
0x04, 0
//
- High
};
//******************************************************************************
unsigned char const ManufacturerDescr[68] = {
34, 0,
USB_STRING_DESCRIPTOR_TYPE, 0,
't', 0, 0, 0,
'e', 0, 0, 0,
'm', 0, 0, 0,
'a', 0, 0, 0,
's', 0, 0, 0,
' ', 0, 0, 0,
'a', 0, 0, 0,
'v', 0, 0, 0,
'a', 0, 0, 0,
25
'n', 0, 0, 0,
'z', 0, 0, 0,
'a', 0, 0, 0,
'd', 0, 0, 0,
'o', 0, 0, 0,
's', 0, 0, 0,
' ', 0, 0, 0
};
//******************************************************************************
unsigned char const ProductDescr[96] = {
48, 0,
USB_STRING_DESCRIPTOR_TYPE, 0,
'm', 0, 0, 0,
'i', 0, 0, 0,
'k', 0, 0, 0,
'r', 0, 0, 0,
'o', 0, 0, 0,
'C', 0, 0, 0,
' ', 0, 0, 0,
'P', 0, 0, 0,
'I', 0, 0, 0,
'C', 0, 0, 0,
' ', 0, 0, 0,
'1', 0, 0, 0,
'8', 0, 0, 0,
'F', 0, 0, 0,
'4', 0, 0, 0,
26
'5', 0, 0, 0,
'5', 0, 0, 0,
'0', 0, 0, 0,
' ', 0, 0, 0,
't', 0, 0, 0,
'e', 0, 0, 0,
's', 0, 0, 0,
't', 0, 0, 0
};
//******************************************************************************
unsigned char const StrUnknownDescr[4] = {
2, 0,
USB_STRING_DESCRIPTOR_TYPE, 0
};
// Initialization Function
void InitUSBdsc()
{
Byte_tmp_0[0] = NUM_ENDPOINTS;
Byte_tmp_0[0] = ConfigDescr_wTotalLength;
Byte_tmp_0[0] = HID_ReportDesc_len;
Byte_tmp_0[0] = Low_HID_ReportDesc_len;
Byte_tmp_0[0] = High_HID_ReportDesc_len;
Byte_tmp_0[0] = Low_HID_PACKET_SIZE;
Byte_tmp_0[0] = High_HID_PACKET_SIZE;
DescTables;
LangIDDescr;
ManufacturerDescr;
27
ProductDescr;
StrUnknownDescr;
}
Procedimiento:
Conectar el dispositivo a la computadora.
En MIKROC acceder a la ventana de pruebas HID.
HID es Human Interface Device.
Desde MikroC verificar si el dispositivo tiene comunicacin con la computadora.
Conclusin:
Al desarrollar la prctica nos damos cuenta la aplicacin que se le puede dar a
esta comunicacin, como tambin nos muestra la necesidad de crear driver
para probar nuestro primer diseo lo cual veremos en la siguiente practica.
28
29
30
31
32
Conclusion:
Ahora hemos creado el driver que nos ayudara a la elaboracin de las
siguientes practicas, con esto y el programa de ECO hemos dado un paso a la
programacin con USB.
33
Cdigo C
Programa principal.
/*
* Project name:
HIDtest2 (USB HID Read & Write Test)
* Copyright:
(c) MikroElektronika, 2005-2008
* Revision History:
20050502:
34
- initial release;
* Description:
This example establishes connection with the HID terminal that is active
on the PC. Upon connection establishment, the HID Device Name will
appear
in the respective window. The character that user sends to PIC from the HID
terminal will be re-sent back to user.
* Test configuration:
MCU:
PIC18F4550
http://ww1.microchip.com/downloads/en/DeviceDoc/39632D.pdf
Dev.Board:
EasyPIC6
http://www.mikroe.com/en/tools/easypic6/
Oscillator:
Ext. Modules:
on-board USB-HID
http://www.mikroe.com/pdf/easypic6/easypic6_manual_v100.pdf#page14
SW:
* NOTES:
(*) Be VERY careful about the configuration flags for the 18F4550 - there's
so much place for mistake!
- Place jumpers J12 in the right position
*/
unsigned char k;
unsigned char userWR_buffer[64], userRD_buffer[64];
unsigned int temp_res;
const char *text = "MIKROElektronika Compilers ER \r\n";
//*****************************************************************************************
35
INTCON2 = 0xF5;
INTCON3 = 0xC0;
RCON.IPEN = 0;
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;
ADCON1 |= 0x00;
as digital (0X0F - Valor previo)
CMCON |= 7;
// Disable comparators
//--------------------------------------
36
// Ports Configuration
//-------------------------------------TRISA = 0xFF;
TRISB = 0xFF;
TRISC = 0xFF;
TRISD = 0;
TRISE = 0x07;
LATA = 0;
LATB = 0;
LATC = 0;
LATD = 0;
LATE = 0;
//-------------------------------------// Clear user RAM
// Banks [00 .. 07] ( 8 x 256 = 2048 Bytes )
//-------------------------------------}
//****************************************************************************
// Main Program Routine
//****************************************************************************
void main() {
unsigned char i, ch;
Init_Main();
HID_Enable(&userRD_buffer, &userWR_buffer);
Delay_ms(1000); Delay_ms(1000);
while (1) {
k = HID_Read();
37
i = 0;
while (i < k) {
ch = userRD_buffer[i];
temp_res = ADC_read(2);
PORTD = temp_res>> 2;
userWR_buffer[0] = temp_res>> 2;
while (!HID_Write(&userWR_buffer, 1)) ;
i++;
}
}
HID_Disable();
}
//****************************************************************************
Programacion en Labview:
38
Conclusin:
Ahora vemos un mejor resultado con el muestreo de nuestros datos adquiridos
del potencimetro, eso se debe al protocolo de comunicacin, con esto
podemos ver la practicidad del USB.
39
PIC18F4550
http://ww1.microchip.com/downloads/en/DeviceDoc/39632D.pdf
Dev.Board:
EasyPIC6
http://www.mikroe.com/en/tools/easypic6/
Oscillator:
Ext. Modules:
on-board USB-HID
http://www.mikroe.com/pdf/easypic6/easypic6_manual_v100.pdf#page14
SW:
* NOTES:
(*) Be VERY careful about the configuration flags for the 18F4550 - there's
so much place for mistake!
- Place jumpers J12 in the right position
*/
unsigned char k;
unsigned char userWR_buffer[64], userRD_buffer[64];
unsigned int temp_res;
const char *text = "MIKROElektronika Compilers ER \r\n";
//*****************************************************************************************
// Main Interrupt Routine
//*****************************************************************************************
void interrupt()
{
HID_InterruptProc();
41
}
//*****************************************************************************************
//*****************************************************************************************
// Initialization Routine
//*****************************************************************************************
void Init_Main()
{
//-------------------------------------// Disable all interrupts
//-------------------------------------INTCON = 0;
INTCON2 = 0xF5;
INTCON3 = 0xC0;
RCON.IPEN = 0;
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;
ADCON1 |= 0x00;
as digital (0X0F - Valor previo)
CMCON |= 7;
// Disable comparators
42
TRISD = 0;
TRISE = 0x07;
LATA = 0;
LATB = 0;
LATC = 0;
LATD = 0;
LATE = 0;
//-------------------------------------// Clear user RAM
// Banks [00 .. 07] ( 8 x 256 = 2048 Bytes )
//-------------------------------------}
//*****************************************************************************************
//*****************************************************************************************
// Main Program Routine
//*****************************************************************************************
void main() {
unsigned char i, ch, ch2;
Init_Main();
HID_Enable(&userRD_buffer, &userWR_buffer);
Delay_ms(1000); Delay_ms(1000)
while (1) {
k = HID_Read();
i = 0;
while (i < k) {
ch = userRD_buffer[i];
if (ch == 0X01) {
43
temp_res = ADC_read(2);
PORTD = temp_res;
userWR_buffer[0] = temp_res;
}
Delay_ms(7);
ch2 = userRD_buffer[i];
if (ch2 == 0x08) {
PORTB = temp_res >> 8;
userWR_buffer[0] = temp_res >> 8;
}
while (!HID_Write(&userWR_buffer, 1)) ;
i++;
}
}
HID_Disable();
}
//*****************************************************************************************
Programacin en Labview:
44
Conclusin:
La conversin a 10 bits nos da mejor respuesta debido a la resolucin. Lo que
se observo en la practica fueron perturbaciones debido al ruido entregado del
mismo potencimetro.
45
MCU:
PIC18F4550
http://ww1.microchip.com/downloads/en/DeviceDoc/39632D.pdf
Dev.Board:
EasyPIC6
http://www.mikroe.com/en/tools/easypic6/
Oscillator:
Ext. Modules:
on-board USB-HID
http://www.mikroe.com/pdf/easypic6/easypic6_manual_v100.pdf#page14
SW:
* NOTES:
(*) Be VERY careful about the configuration flags for the 18F4550 - there's
so much place for mistake!
- Place jumpers J12 in the right position
*/
unsigned char k;
unsigned char userWR_buffer[64], userRD_buffer[64];
unsigned int temp_res, temp_res1, temp_res2;
const char *text = "MIKROElektronika Compilers ER \r\n";
//*****************************************************************************************
// Main Interrupt Routine
//*****************************************************************************************
void interrupt()
{
HID_InterruptProc();
}
//*****************************************************************************************
47
//*****************************************************************************************
// Initialization Routine
//*****************************************************************************************
void Init_Main()
{
//-------------------------------------// Disable all interrupts
//-------------------------------------INTCON = 0;
INTCON2 = 0xF5;
INTCON3 = 0xC0;
RCON.IPEN = 0;
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;
ADCON1 |= 0x00;
as digital (0X0F - Valor previo)
CMCON |= 7;
// Disable comparators
48
LATA = 0;
LATB = 0;
LATC = 0;
LATD = 0;
LATE = 0;
//-------------------------------------// Clear user RAM
// Banks [00 .. 07] ( 8 x 256 = 2048 Bytes )
//-------------------------------------}
//*****************************************************************************************
// Main Program Routine
//*****************************************************************************************
void main() {
unsigned char i, ch, ch2, ch3 ;
Init_Main();
HID_Enable(&userRD_buffer, &userWR_buffer);
Delay_ms(1000); Delay_ms(1000);
while (1) {
k = HID_Read();
i = 0;
while (i < k) {
ch = userRD_buffer[i];
if (ch == 0X01) {
temp_res = ADC_read(0);
userWR_buffer[0] = temp_res>> 2;
}
49
Delay_ms(7);
ch2 = userRD_buffer[i];
if (ch2 == 0x08) {
temp_res1 = ADC_read(1);
userWR_buffer[0] = temp_res1>> 2;
}
Delay_ms(7);
ch3 = userRD_buffer[i];
if (ch3 == 0x0F) {
temp_res2 = ADC_read(2);
userWR_buffer[0] = temp_res2>> 2;
}
while (!HID_Write(&userWR_buffer, 1)) ;
i++;
}
}
HID_Disable();
}
Programacin con labview:
50
51
Conclusin:
Podemos ver la cantidad de datos y la velocidad con la cual se puede trabajar
con el protocolo USB.
52
53
54
Conclusin:
Al llevar a cabo esta prctica podemos ver el cambio entre la seal de entrada
en la prctica anterior a la actual esto gracias al filtro. Nos damos cuenta que
un filtro no en necesariamente colocar un capacitor y una resistencia o usando
opam, sino que tambin lo podemos realizar mediante software.
55
Programacin en Labview:
56
57
Conclusin:
Usamos una herramienta de Labview para guardar los datos obtenidos de la
medicin, as vamos conociendo mas nuestra interfaz.
58
1 Fusible.
Cdigo en C.
/*
* Project name:
HIDtest2 (USB HID Read & Write Test)
* Copyright:
(c) MikroElektronika, 2005-2008
* Revision History:
20050502:
- initial release;
* Description:
This example establishes connection with the HID terminal that is active
on the PC. Upon connection establishment, the HID Device Name will
appear
in the respective window. The character that user sends to PIC from the HID
terminal will be re-sent back to user.
59
* Test configuration:
MCU:
PIC18F4550
http://ww1.microchip.com/downloads/en/DeviceDoc/39632D.pdf
Dev.Board:
EasyPIC6
http://www.mikroe.com/en/tools/easypic6/
Oscillator:
Ext. Modules:
on-board USB-HID
http://www.mikroe.com/pdf/easypic6/easypic6_manual_v100.pdf#page14
SW:
* NOTES:
(*) Be VERY careful about the configuration flags for the 18F4550 - there's
so much place for mistake!
- Place jumpers J12 in the right position
*/
unsigned char k;
unsigned char userWR_buffer[64], userRD_buffer[64];
const char *text = "MIKROElektronika Compilers ER \r\n";
//*****************************************************************************************
// Main Interrupt Routine
//*****************************************************************************************
void interrupt()
{
HID_InterruptProc();
}
//*****************************************************************************************
60
//*****************************************************************************************
// Initialization Routine
//*****************************************************************************************
void Init_Main()
{
//-------------------------------------// Disable all interrupts
//-------------------------------------INTCON = 0;
INTCON2 = 0xF5;
INTCON3 = 0xC0;
RCON.IPEN = 0;
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;
ADCON1 |= 0x0F;
as digital
CMCON |= 7;
// Disable comparators
61
LATA = 0;
LATB = 0;
LATC = 0;
LATD = 0;
LATE = 0;
//-------------------------------------// Clear user RAM
// Banks [00 .. 07] ( 8 x 256 = 2048 Bytes )
//-------------------------------------}
//*****************************************************************************************
//*****************************************************************************************
// Main Program Routine
//*****************************************************************************************
void main() {
unsigned char i, ch, ch1;
Init_Main();
HID_Enable(&userRD_buffer, &userWR_buffer);
Delay_ms(1000); Delay_ms(1000);
while (1) {
k = HID_Read();
i = 0;
while (i < k) {
ch = userRD_buffer[i];
PORTD = ch;
ch1 = PORTB;
userWR_buffer[0] = ch1;
62
63
Resultados.
Podemos ver lo poderoso que es saber usar una herramienta como el Labview
para poder controlar un motor usando la lgica de escalera, claro este gracias a
acoplar al pic con un programa en lenguaje c usando mikroc.
64
Programacion en Labview:
65
Conclusion:
Conocer las interfaces realizadas por national instruments y ver la diferencia de
practicidad entre la daq profesional o una hecha por nosotros.
66
67
Conclusin:
Vemos la facilidad de procesar una seal con la ayuda de la tarjeta USB 6008
realizando un frecuencmetro acercndonos al comportamiento de un
osciloscopio.
68
69
Conclusin:
Vemos la facilidad de hacer un sistema telemtrico usando la interfaz USB
6008 y la herramienta de Labview para censar la temperatura y mandar un
correo con los datos obtenidos en la medicin.
70