2014 ii c08t-sbc pic para ecg

of 84 /84
Page 1 Universidad de Huánuco Facultad de Ingeniería de Sistemas e Informática

Embed Size (px)



Transcript of 2014 ii c08t-sbc pic para ecg

  • 1. Page 1Universidad de HunucoFacultad de Ingeniera de Sistemas e Informtica

2. Page 2AgendaBase del ConocimientoDiagramas de BodeDiseo de Filtros AnalgicosDiseo de un ElectrocardiogramaMicrocontrolador PIC con LabviewMotor de InferenciaTcnicas de Diagnstico de un ECGMedios de ComunicacinPrototipo de un ECG 3. Page 3Acerca del ECG-UDH 4. Page 4Modelando un PICPICProcesadorMemoriaTemporizadorADCUSBGLCDOscilador 5. Page 5Modelando un PICInput Variables Output (User Interface) Variables (Link to other Systems) Embedded Computer Software Hardware Signal Conditioning Data Conversion Output Drive (display, keypad etc.) 6. Page 6Microcontrolador PICComo sabemos los micro controladores de 8 bits de Microchip se dividen en 3 gamas:PIC10 y PIC12: Gama bajaPIC16: Gama mediaPIC18: Gama alta 7. Page 7Estructura Interna de un PIC 8. Page 8Estructura Externa de un PIC 9. Page 9Organizacin de las Memorias de un PICa) Enfoque de Von Neumann b) Enfoque de HarvardDataMemoryProgramMemoryAddressDataCentralProcessingUnit (CPU)Input/OutputCentralProcessingUnit (CPU)DataMemoryInput/OutputProgramMemoryAddressDataAddressDataAddressData 10. Page 10Arquitectura RISC-PICA CISC machine is generallyrecognised by: Many instructions (say over onehundred), some with considerablesophistication; Instruction words are of differentlength; Instructions take differentlengths of time to execute.A RISC machine is generallyrecognised by: Few instructions (say well belowone hundred), Each performs a very simpleaction; All instructions are single word; All, or almost all instructionstake the same length of time toexecute.DigitalProgramI/0MicroprocessorDataMemoryMemoryCoreAnalogI/0& TimersCountersResetPowerClockAddress BusesInternal Data &FurtherPeripheralFurtherPeripheralInterrupt(s)A microcontroller = microprocessor core + memory + peripherals 11. Page 11Diagrama de Bloques del PICThe CPUAddress for Program MemoryData from Program Memory, carrying instruction wordAddress for Data MemoryData bus for Data Memory and peripheralsProgram MemoryData MemoryExtra non- volatile Data MemoryCounter/Timer PeripheralDigital Input/ Output PortsIt is easy to see the Program memory, which uses Flash memory technology. Alongside this comes the Stack, which we meet later. Microchip call the main data memory File Registers. There is another section of data memory which uses EEPROM technology. 12. Page 12Registro de Estado de un PICCondition Code Flags 13. Page 13Memoria de Programa y StackProgram Counter16 Series instructions which invoke the StackUnimplemented memory space, still addressable by the 13-bit 16F84A program address bus.Program Counter points to locations in program memoryThe program must start hereThe Interrupt Service Routine must start here 14. Page 14Mapa de Memoria de Datos y (SFR) Registro de Funciones Especialesmsb is bank select bit(Status register).These are the Special Function Registers, which allow the CPU to interact with the peripheralsGeneral purpose memory 15. Page 15Interface con Perifricos va elRegistro de Funciones EspecialesControl SFR(s)PeripheralData Transfer SFR(s)MicrocontrollerCore"OutsideWorld"Interrupt(s)Microcontroller Interaction with its Peripherals, via Special Function Register (SFR) and Interrupt microcontroller peripherals can be configured in software to operate in a number of different modes,to do this certain control data must be sent to them to set them up in the desired way once in use, there will be data flow between core and peripheral, there may still be need for further control data, these needs are commonly met by means of dedicated, memory - mapped registers, sometimescalled Special Function Registers, this approach gives the microcontroller manufacturer great flexibility to extend a microcontrollerfamily SFRs for new peripherals can easily be located in gaps in the memory map. 16. Page 16Configuraciones Globales del PICThe configuration word determines certain operating features of the microcontroller. It is in program memory, but cannot be accessed in normal operation. It is written to during the programming process. You set its value either by response to a dialogue box in MPLAB, or by use of Assembler Directives, at the head of your programme.The 16F84A Configuration Word 17. Page 17Tipos de Memorias de un PIC 18. Page 18Caractersticas de los OsciladoresOscilador PrimarioOscilador SecundarioOscilador InternoFrecuencias de Oscilacin Altas (XT, HS)Frecuencias de Oscilacin Medias (LP)Frecuencias de Oscilacin Bajas (RC)Con PLLSin PLLCon Pre EscalaSin Pre EscalaCon Pre EscalaSin Pre EscalaMultiplica Frecuencia de OscilacinDivide Frecuencia de OscilacinDivide Frecuencia de Oscilacin 19. Page 19Modos del OsciladorThe 16F84A can be configured to operate in four different oscillator modes, using R-C, crystal or ceramic oscillators. It can also accept an external clock source. The user selects which mode is to be used by setting bits in the Configuration Word.XT CrystalThe standard crystal configuration, intended for crystals or ceramics in the range 1MHz to 4MHz.HS High SpeedA higher drive version of the XT configuration, for higher frequency crystals and ceramic resonators. Intended for frequencies in the region of 4MHz or greater. It leads to the highest current consumption of all the oscillator modes.LP Low PowerIntended for low frequency crystal applications, and gives the lowest power consumption possible. Will however operate at any frequency below around 200kHz.RC - Resistor-CapacitorRequires connection of an external resistor and capacitor. The lowest cost way of getting an oscillator, but should not be used when any timing accuracy is required. 20. Page 20Modos del Osciladorb) Resistor-Capacitorc) Externally Supplied Clocka) Crystal or Ceramic, HS, XT, or LPRA2RA3RA4/T0CKIMCLRVRB0/INTRB1RB2RB3 RB4RB5RB6RB7RA1RA0OSC1/CLKINOSC2/CLKOUTSS VDD Supply voltageOscillator connectionsPort A, Bit 0Port A, Bit 2 Port A, Bit 1Port A, Bit 3*Port A, Bit 4Ground**Port B, Bit 0Port B, Bit 1Port B, Bit 2Port B, Bit 3Port B, Bit 7Port B, Bit 6Port B, Bit 5Port B, Bit 4*also Counter/Timer clock input**also external Interrupt inputReset19 1018The Oscillator Pins 21. Page 21Diagramas de un Oscilador Primario 22. Page 22Acerca del Conversor Analgico a Digital ADC del PIC 23. Page 23Acerca del ADC del PIC 24. Page 24AgendaBase del ConocimientoDiagramas de BodeDiseo de Filtros AnalgicosDiseo de un ElectrocardiogramaMicrocontrolador PIC con LabviewMotor de InferenciaTcnicas de Diagnstico de un ECGMedios de ComunicacinPrototipo de un ECGADC 25. Page 25Acerca del ECG-UDH 26. Page 26Caractersticas ADC del DSPICConversin va aproximacin sucesiva SAR.Velocidad de conversin de hasta 500 ksps.Hasta 16 pines de entrada analgica.Pines de referencia de Voltaje Externo.Modo Automtico de Escaneo de Canal .Fuente seleccionable de activacin de conversin.Buffer de resultado de conversin de 16 wordModos seleccionables de llenado de Buffers.Cuatro opciones de alineamiento de resultado.Modos de operacin durante el estado Sleep e Idle. 27. Page 27Acerca del ADC del PIC 28. Page 28Flujo grama de operacin del ADC 29. Page 29Estructura Mdulo A/D del PIC24FVREF+VREF-A/D converterConversion ControlBus InterfaceDataFormatSample Sequence ControlAN0AN1S/HAN15CH08/16 LevelResultsBufferVR+VR-VR SelectAVDDAVSS 30. Page 30Eje y: Tiempo de Conversin A/D = Tiempo de Adquisicin ms ConversinTiempo deAdquisicinTiempo de ConversinInicio del Tiempo de AdquisicinFin deConversinEntradaAnalgicaTiempo de Conversin A/DClock A/DTAD 31. Page 31Registro de Control ADC 32. Page 32Eje x: Tiempo de MuestreoAD1CON3TCY to 256*TCYRCADFCY = FOSC/2TADAD1CON310AD Clock Postscaler by 1 to 256 33. Page 33Proceso de Operacin del ADC 34. Page 34Configuracin del Clock del ADC 35. Page 35Aspectos de Precisin Digital 36. Page 36Diagrama de Bloques del ADC 10bitsAVDDAVSSVREF+VREF-VR+VR-VR SelectAD1CON2AVSSAVDD1xxVREF-VREF+011VREF-AVDD010AVSSVREF+001AVSSAVDD000VR-VR+VCFG2:VCFG0AD1CON2 Registerbit15CSSL13=0CSSL14=0CSSL15=0BUFMbit0ALTSCSNAVCFG2VCFG1VCFG0bit8SMPI1SMPI 0SMPI3SMPI2BUFSbit7--------------- 37. Page 37Diagrama de Bloques del ADC 10bitsAN0AN1AN15Mux AVR-AN1AD1CHSAD1CHSVINHVINL(0)(1)AD1PCFG Registerbit15CSSL10=0CSSL13=0CSSL14=0CSSL8=0PCFG1bit0PCFG0PCFG2PCFG15PCFG14PCFG13bit8AD1CON2 Registerbit15CSSL13=0CSSL14=0BUFMbit0ALTSCSNAVCFG2VCFG1VCFG0SMPI1SMPI 0SMPI3SMPI2BUFSbit7---------------bit8AD1CHS Registerbit15CH0SA1bit0CH0SA0CH0SA2CH0NAbit7CH0SA3CH0SB1CH0SB0CH0SB2CH0NBCH0SB3------------------AD1CSSL Registerbit15CSSL13=0CSSL14=0CSSL1bit0CSSL0CSSL2CSSL15CSSL14CSSL13 38. Page 38Escaneo de Canales del ADCADCBUF Buffer+-CH 0AN15AN14.AN5AN4AN3AN2AN1AN0+B- B+A- AVREF-AN1AN0AN2AN13AN14INTADCBUF0AD1CSSL Registerbit15CSSL13=0CSSL14=0CSSL1bit0CSSL0CSSL2CSSL15CSSL14CSSL13AN13bit8AD1CON2 Registerbit15CSSL13=0CSSL14=0BUFMbit0ALTSCSNAVCFG2VCFG1VCFG0SMPI1SMPI 0SMPI3SMPI2BUFSbit7--------------- 39. Page 39Diagrama de Bloques del ADC 10 bitsVINHVINLS/HMux AMux BAD1CON1AD1CON1Seal de Conversion completa01bit8AD1CON2 Registerbit15CSSL13=0BUFMbit0ALTSCSNAVCFG2VCFG1VCFG0SMPI1SMPI 0SMPI3SMPI2BUFSbit7--------------- 40. Page 40Diagrama de Bloques del ADC 10 bitsVINHVINLS/ HAD1CON1AD1CON1Conversion complete SignalADC1BUF0 : ADC1BUF15RESULTVR+VR-AD1CON1AD1CON3 (7)0 TAD to 31 TADAD1CON1 Clearing AD1CON1 (0)Active Transition on INT0 pin (1)Timer4 Compare ends (2)Evitar 0 TADA/DconverterVR-VR+ 41. Page 41Diagrama de Bloques del ADC 10 bits0000 00dd dddd dddd ssss sssd dddd dddd dddd dddd dd00 0000 sddd dddd dd00 0000RESULTFORMATAD1CON1AD1CON2 = 0AD1CON2AD1CON2ADC1BUF0: :::::ADC1BUF15AD1CON2 = 1ADC1BUF0 : : ADC1BUF7ADC1BUF8::ADC1BUF1501 42. Page 42Ejercicio N1: Digitalizar la Seal Analgica ECGTareas a realizar:Programar el PIC con MPLAB en C18.Realizar la conversin digital de una seal analgica en Proteus con PIC usando Potencimetro.Resultado esperado:Digitalizacin de una seal analgica y su visualizacin usando LCD. 43. Page 43Objetivos del LaboratorioConfigurar el ADCConfigurar los puertos de E/SLeer el ADC y mostrarlos en LEDsVDDVss PIC24AN5POT R6RA7-RA0LEDs D10-D3 44. Page 44Pasos a RealizarOpen the projectC:RTC203_PRCLab5Lab5.mcpOpen the fileC:RTC203_PRCLab5Lab5.cLook for ADCInit() function and configure ADC by initializing the registers AD1CON1, AD1CON2, and AD1CON3 looking into the Register details on the next few pages.STEP 1: AD1CON1Select Integer Format ResultAuto Conversion StartSample after conversionSTEP 2: AD1CON2Select AVDD and AVSS as referencesDisable Scan modeInterrupt at 16th sample/Convert sequence16*1 level bufferAlways use Mux ASTEP 3: AD1CON3Select Sample Time = 13TADConversion Time is always 12TADSelect AD Clock Source such that you get 16 samples in around 1 mSec (16 ksps)Assume 1TCY =.25 uS (FCY = 4 MHz) 45. Page 45Pasos a RealizarContinue to configure ADC by initializing the registers AD1CHS, AD1PCFG, and AD1CSSL looking into the Register details on the next few pages. STEP 4: AD1CHS Set the positive sample input channel for MUX A to use AN5 Set the negative input channel for MUX A to use VR- STEP 5: AD1PCFG Set AD1PCFG so that the only pin using analog functionality is AN5 STEP 6: AD1CSSL Channel scanning is not enabled, so no input channels should be selected for scanningBuild the project and program the deviceProcedure to TestVary the POT and observe LEDs 46. Page 46Configurando el Registro ADCAD1CON1: A/D CONTROL REGISTER 1ADON--ADSIL------FORM1FORM0Bit:8Bit:15ADC Module enable bitADC Module enable/disable in IDLE modeResult Format 00: Intiger (0000 00dd dddd dddd) 01: Signed Intiger (ssss sssd dddd dddd) 10: Fractional (dddd dddd dd00 0000) 11: Signed Fractional (sddd dddd dd00 0000)SSRC2SSRC1SSRC0----ASAMSAMPDONEStart Sampling, If ASAM is 0Conversion Status bitBit:0Bit:7Conversion Trigger Source Selection Bits000: Manual Conversion Trigger001: Active transition on INT0 pin triggers conversion010: Timer3 compare triggers conversion111: Auto conversionAuto Sample Selection bit 1: Sample immediately after completion of last conversion. 0: Sample on setting of SAMP 47. Page 47Configurando el Registro AD1CON2VCFG2:VCFG0VR+VR-000AVDDAVSS001VREF+AVSS010AVDDVREF-011VREF+VREF-1xxAVDDAVSSVCFG2VCFG2VCFG0----CSCNA----BUFS--SMPI3SMPI2SMPI1SMPI0BUFMALTSVR SelectAVDDAVSSVREF+VREF-VR+VR-VCFG2:VCFG0Bit:8Bit:15Scan CH0 Mux A InputBit:0Bit:7SMPI3:SMPI0Interrupt Event(Sample/convert sequence)0000each0001alternate.....1110Every 15th1111Every 16thBuffer Status bit, is valid only when BUFM = 1 1: Buffer 8-F is being filled, can access Buffer 0-7 0: Buffer 0-7 is being filled, can access Buffer 8-FBuffer Mode Select bit 1: Buffer configured as two 8-words buffers 0: Buffer configured as one 16-words buffersSample alternatively MUX-A & MUX-B 48. Page 48Configurando el Registro AD1CON3SAMC4:SAMC0Sampling Time000000 TAD000011 TAD.....1111030 TAD1111131 TADADRC----SAMC4SAMC3SAMC2SAMC1SAMC0ADCS7ADCS6ADCS5ADCS4ADCS3ADCS2ADCS1ADCS0ADCS7:ADCS0Conversion Clock00000000TCY ( FCY )000000012*TCY ( FCY / 2 ).....11111110255*TCY ( FCY / 255 )11111111256*TCY ( FCY / 256 )Bit:8Bit:15A/D conversion Clock Source1: ADRC is used0: System clock is usedBit:0Bit:7A/D Sample Time Selection bitsA/D Conversion Clock Selection bitsADCS = (TAD/TCY) - 1 49. Page 49Configurando el Registro AD1CHSCH0SB3:CH0SB0CH0 Positive Input for MUX B0000AN00001AN1.....1110AN141111AN15CH0NB------CH0SB3CH0SB2CH0SB1CH0SB0Bit:8Bit:15CH0 Negative input for MUX A 1: AN1 0: VR-CH0NA------CH0SA3CH0SA2CH0SA1CH0SA0Bit:0Bit:7CH0SA3:CH0SA0CH0 Positive Input for MUX A0000AN00001AN1.....1110AN141111AN15CH0 Negative input for MUX B 1: AN1 0: VR-VREF-AN15AN0ANxx+B- B+ A- AAN15AN0ANxxVREF-AN1+-CH 0AN1CH0SB3:CH0SB0CH0SA3:CH0SA0CH0NBCH0NA 50. Page 50Configurando el AD1PCFG: Registro de Configuracin de PuertosPCFG15PCFG14PCFG13PCFG12PCFG11PCFG10PCFG9PCFG8Bit:8Bit:15Bit:0Bit:7PCFG7PCFG6PCFG5PCFG4PCFG3PCFG2PCFG1PCFG0Analog Input Pin Configuration Control bits 0 to 15 1: Pin for corresponding analog channel (ANxx) is in digital mode 0: Pin for corresponding analog channel (ANxx) is in analog modeAD1CSSL : A/D Input Scan Select RegsiterCSSL15CSSL14CSSL13CSSL12CSSL11CSSL10CSSL9CSSL8Bit:8Bit:15Bit:0Bit:7CSSL7CSSL6CSSL5CSSL4CSSL3CSSL2CSSL1CSSL0A/D Input Channel Scan Selection bits 0 to 151: Corresponding analog channel (ANxx) is selected for sequential scanning0: Corresponding analog channel (ANxx) is ignored for sequential scanning 51. Page 51Resultado EsperadoEl valor del POT es promediado cada 16 muestras en 1 ms.El valor del POT es mostrado en los LEDs como un valor binario desde 0 hasta 255El Pin RB2 cambia de valor cada 16 muestras (con una frecuencia de 500 Hz) 52. Page 52AgendaBase del ConocimientoDiagramas de BodeDiseo de Filtros AnalgicosDiseo de un ElectrocardiogramaMicrocontrolador PIC con LabviewMotor de InferenciaTcnicas de Diagnstico de un ECGMedios de ComunicacinPrototipo de un ECGUSB 53. Page 53Acerca del ECG-UDH 54. Page 54Interfaces USBUSB Creado por Intel en el ao 1994, versin 1.0. En el ao 1998 se lanza la versin 1.1 con una velocidad detransferencia baja de 1.5 Mbps y a full capacidad de 12 Mbps. En el ao 2000, se lanza la versin 2.0 de alta capacidad con 480 Mbps. 55. Page 55USB: Bus Serial Universal Auto dteccin & configuraion (Plug&Play) Energa en el Bus 3 velocidades: Low- 1.5 Mbps, Full- 12 Mbps,High- 480 Megabits/secondRS232ParaleloPS/2Tipos deAplicacinExtend the functionality ofyour computer!Data Analysis,Data Logging,Firmware Updates,Diagnostics,Embedded Applications! 56. Page 56Caractersticas del USBNRZI Data EncodingHalf duplex data transmission can go in only one direction at a timeBus Power to each device:4.40 - 5.25 VGuaranteed 100 mA500 mA maximum through negotiation~ 5.0 V ~ 3.3 VVBUS D+ D- GNDVBUS D+ D- GND4-wire connectionDifferential Signaling 57. Page 57Caractersticas del USBmini-B Plug FS, HS PeripheralB Plug FS, HS PeripheralA Plug USB Host 58. Page 58Caractersticas del USBGuaranteed Latency Guaranteed DataIntegrityInterruptBulkIsochronousPIC18F4550 family supports all these transfer types. 59. Page 59USB PipesHOST PCBig USB Pipe12Mb/sSmall Pipe to each USBdevice (up to 127)Tiny Pipes (endpoints) 60. Page 60Client Software FunctionClientSoftwareInterfaceUSB DeviceHostEndpointsData FlowsBuffersPipes 61. Page 61El Dispositivo LgicoDevice(Manufacturer: Microchip Technology)(Product: Mouse in a Circle Demo)ConfigurationInterfaceIN (Endpoint 0)USB System Software(default control pipes)USB Device-Specific Pipe(s)(Human Interface Device)HID TX/RX Functions(MCHPFSUSB FW)Analog/Digital I/OOUT (Endpoint 0)IN (Endpoint x)OUT (Endpoint x)These settings arerepresented by aDevice DescriptorTable, stored infirmware. 62. Page 62Trama USBBULKBULKBULKBULKBULKBULKBULKBULKTx VoiceTx LineInterrupt,Control,Low SpeedTrame = 1msStereo AudioStereo AudioStereo AudioStereo AudioStereo AudioStereo AudioStereo AudioStereo AudioStereo AudioStereo AudioRx VoiceRx LineSlotSOFLow SpeedLow SpeedBULKBULKScanner 63. Page 63Perifricos USB63JoystickMouseSD CardReaderMCHPRS-232DataUPS LoggerKeyboardGenericHuman Interface DeviceClass (HID)Mass StorageDevice Class (MSD)CommunicationDevice Class (CDC)DigitizerLibUSB WinUSBCustom Class(Vendor Class)AudioClassMIDISpeaker 64. Page 64El Proceso de EnumeracinDETACHEDPOWEREDPower (self/bus)DEFAULTBus resetADDRESSGet Device DescriptorCONFIGUREDGet DescriptorsATTACHEDCable ConnectedSUSPENDED 65. Page 65Auto Deteccin: Full Velocidad+5VD+D-GNDTransceiverUSBConnectorPeripheral DeviceVUSB 3.3 VFull Speed IdentificationD+ line pull-up1.5 k5%USB PIC MCU 66. Page 66Auto Deteccin: Baja Velocidad+5VD+D-GNDTransceiverUSBConnectorPeripheral DeviceVUSB 3.3 VLow Speed IdentificationD- line pull-up1.5 k5%USB PIC MCU 67. Page 67On-chip Pull-up Resistors+5VD+D-GNDTransceiverUSBConnectorPeripheral DeviceVUSB 3.3 VOn-chip pull-up resistorsavailable!USB PIC MCU 68. Page 68Address and Configuration: EP0 See Chapter 9 in USB 2.0 Spec for more info.Other EndpointsEndpoint 0 IN(Control Data)Endpoint 0 OUT(Control Data)Dual Port/Access RAMDescriptorsControl TransfersUSB PIC MCU 69. Page 69DescriptoresDeviceConfiguration 1Interface 0EndpointInterface 1EndpointEndpointEndpointTo other Configurations if anyTo other Interfaces if anyString 0String 1String NDescriptors are typically stored in non-volatile/Flash memory 70. Page 70Ejemplo de DescriptoresPICDEM USBMicrochipDeviceConfiguration 1Interface 0EndpointManu. StringProd. StringUSB 2.0, VID = 0x04D8,PID = 0x0007, Num. Configurations, Strings?Configuration #1: Bus-Powered,Remote Wakeup, 500mA, Num. InterfacesInterface #0: HID Class, Num. EndpointsEndpoint 1 IN, Interrupt Transfer Type, 64-byte buffer, Poll every 3 msUnicode CharactersGo USB!Other String 71. Page 71MCHPFSUSB Software Framework - Device Descriptor Table -usb_descriptors.cDescriptorsVID & PIDClass Specific/* Device Descriptor */ROM USB_DEVICE_DESCRIPTOR device_dsc={ 0x12, // Size of this descriptor in bytesUSB_DESCRIPTOR_DEVICE, // DEVICE descriptor type0x0200, // USB Spec Release NumberCDC_DEVICE, // Class Code0x00, // Subclass code0x00, // Protocol codeEP0_BUFF_SIZE, // Max packet size for EP0,0x04D8, // Microchip Vendor ID0x000C, // Product ID ID 72. Page 72CDC RS-232 EmulationPC ComputerPIC MicrocontrollerUSB CableHyper TerminalCDCINF File Required(Supplied in MCHPSUSB)Standard Windows DriversDesign Considerations:~80 KB/s maxBulk TransfersPC applications can access the device as though it is connected to a serial COM port 73. Page 73MCHPFSUSB Framework - Polled Program Flow -Resetmain()InitializeSystem()while(1)Your application codeUSBDeviceTasks()ProcessIO()USB StackCooperative Multitasking!!No blocking functions.Use state machine.You edit UserInit()Function ServicesCDCTxService() MSDTasks() Re-arm OUT Endpoint (HID & Generic) 74. Page 74MCHPFSUSB Framework - Interrupt Program Flow -Resetmain()InitializeSystem()while(1)Your application codeProcessIO()You edit UserInit()USB Interrupt ContextUSBDeviceTasks()USBDeviceAttach()Function ServicesNotifies the stack when the device is attachedCDCTxService() MSDTasks() Re-arm OUT Endpoint (HID & Generic) 75. Page 75Cdigo de Ejemplo#include Compiler.h #include USBusb.h #include USBusb_function_cdc.h #include HardwareProfile.h void UserInit(void){ } void ProcessIO(void){ if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return; CDCTxService(); } static void InitializeSystem(void){ #if define #endif UserInit(); USBDeviceInit(); } int main(void){ InitializeSystem(); USBDeviceAttach(); while(1){ ProcessIO(); } }Main.cNeeded (usb_config.h is called by usb.h)Put your initialization code herePut your application code (state machine) hereNo need to changeConditional compiling (no need to change)USBDeviceTasks() is executed in an ISR (High Priority PIC18, _USB1Interrupt() PIC24 & PIC32) 76. Page 76AgendaBase del ConocimientoDiagramas de BodeDiseo de Filtros AnalgicosDiseo de un ElectrocardiogramaMicrocontrolador PIC con LabviewMotor de InferenciaTcnicas de Diagnstico de un ECGMedios de ComunicacinPrototipo de un ECGGLCD 77. Page 77Acerca del ECG-UDH 78. Page 78Pantallas Grficas LCD (GLCD)RA0/AN02RA1/AN13RA2/AN2/VREF-/CVREF4RA3/AN3/VREF+ 5RA4/T0CKI/C1OUT/RCV6RA5/AN4/SS/LVDIN/C2OUT7RA6/OSC2/CLKO14OSC1/CLKI13RB0/AN12/INT0/FLT0/SDI/SDA33RB1/AN10/INT1/SCK/SCL34RB2/AN8/INT2/VMO35RB3/AN9/CCP2/VPO36RB4/AN11/KBI0/CSSPP37RB5/KBI1/PGM38RB6/KBI2/PGC39RB7/KBI3/PGD40RC0/T1OSO/T1CKI15RC1/T1OSI/CCP2/UOE16RC2/CCP1/P1A17VUSB18RC4/D-/VM23RC5/D+/VP24RC6/TX/CK25RC7/RX/DT/SDO26RD0/SPP019RD1/SPP120RD2/SPP221RD3/SPP322RD4/SPP427RD5/SPP5/P1B28RD6/SPP6/P1C29RD7/SPP7/P1D30RE0/AN5/CK1SPP8RE1/AN6/CK2SPP9RE2/AN7/OESPP10RE3/MCLR/VPP1U2PIC18F4550X1CRYSTALC122pFC222pF12345ICSP 1-5CONN-SIL5MCLRPGDPGCMCLRPGCPGD1234AN 4-3-ECGCONN-H4 CS11CS22GND3VCC4V05RS6R/W7E8DB09DB110DB211DB312DB413DB514DB615DB716RST17-Vout18 LCD2AMPIRE128X64CS1CS2 CS1CS2 DI DI RWERST RWERST 12 3 RV410k 12345 J2CONN-SIL5U2(RC0/T1OSO/T1CKI) R410k1265Pasa U57809C12100nFC13100nFC14100uF16VC15100uF16VC16100nFC17100nFVI1VO3 U77805 VDD V+ V- V+ VCC1D+ 3D- 2GND4J3USBCONN321 DE ALIMENTACION +/- 9V y 5V326 7481 U1OP07V+ 326 7481 U8OP07V- R310kR1410kSUMADOR 79. Page 79Caractersticas de los GLCD 80. Page 80Controladores GLCD para Escribir Byte 0xAB 81. Page 81Instrucciones del Controlador GLCD 82. Page 82Diagrama de Bloque del Controlador GLCD 83. Page 83Cdigo del Proyecto ECG 84. Page 84Agenda:UDH Rumbo a la Acreditacin Internacional