TransWikia.com

Matlab GUI interfacing with pic18f4550

Electrical Engineering Asked by assia_sia on January 4, 2022

My project consists on collecting usb data form the uC PIC 18F4550 to show them using GUI Interface well I am using for the simulation MikroC for PIC programmation as well as Proteus, I compiled my programme and it worked fine since I tried to send data from the USB HID terminal and the correct led connected to the microcontroller blinked, when I came to recive data in matlab ( I used a programme that I found on the internet) but I got this error

Here is the programme

%////////////////////////////////////////////////////////////////////////%
%/// CONEXION USB MATLAB MEDIANTE LA LIBRERIA MPUSBAPI,DLL            ///%
%/// SOFTWARE QUE NOS PERMITE RECIBIR DATOS DESDE EL ADC DEL PIC      ///%
%/// 18F4550 Y ANALIZAR LA ONDAS FOTOPLETISMOGRAFICAS                 ///%
%///                CUSCO-PERU-2009                                   ///%
%////////////////////////////////////////////////////////////////////////%
%NOMBRAMOS A NUESTRO PROYECTO Conex_USB_1
function Conex_USB_1
%INCIALIZAMOS Y ESCONDEMOS EL GUI CREADO
f = figure('Visible','off','Position',[310,50,450,285]);
 
%DEFINIMOS CONTROLES ABRIR-CERRAR PUERTO
        %ABRIMOS CONEXION
         hAbrirConex = uicontrol('Style','pushbutton',...
             'String','Abrir','Enable','off','Position',[15,220,70,25],...
             'Callback',{@AbrirConexButton_Callback});
        %CERRAMOS CONEXION
         hCerrarConex = uicontrol('Style','pushbutton',...
             'String','Cerrar','Enable','off','Position',[15,150,70,25],...
             'Callback',{@CerrarConexButton_Callback});
        %CERRAMOS LIBREIA PARA EVITAR ERRORES
         hCerrarLib = uicontrol('Style','pushbutton',...
             'String','Cerrar Lib','Enable','off','Position',[15,90,70,25],...
             'Callback',{@CerrarLibButton_Callback});
        %CERRAMOS LIBREIA PARA EVITAR ERRORES
         hRecibeADCRojoAC = uicontrol('Style','pushbutton',...
             'String','ADC ROJO AC','Enable','off','Position',[150,220,70,25],...
             'Callback',{@RecibeADCRojoACButton_Callback});
         %ALINEAMOS LOS BOTONES        
         align([hAbrirConex,hCerrarConex],'Center','None');
 
         %HACEMOS EL GUI VISIBLE
         set(f,'Visible','on')
 
         %CAMBIAMOS LA NORMALIZACXION DE LOS COMPONENTES
         set([f,hAbrirConex,hCerrarConex],'Units','normalized');
 
 %//////////////////////////////////////////////////////////////////////%
 %///    CARAGMOS LA LIBRERIA MPUSBAPI                               ///%
 %//////////////////////////////////////////////////////////////////////%
 
 %CARGAMOS LA LIBRERIA MPUSBAPI
 loadlibrary mpusbapi _mpusbapi.h alias libreria 
 libisloaded libreria
 
 %DECLARANDO VECTORES DE DATOS
 data_in = eye(1,64,'uint8');       % El que se recibe del PIC
 data_out = eye(1,3,'uint8');      % El que se envia al PIC
 
 %DECALARANDO VID-PID DEL PIC18F4550
 vid_pid_norm = libpointer('int8Ptr',[uint8('vid_04d8&pid_0052') 0]); 
 out_pipe = libpointer('int8Ptr',[uint8('MCHP_EP1') 0]); 
 in_pipe = libpointer('int8Ptr',[uint8('MCHP_EP1') 0]);
 
 %REALIZAMOS  CONTEO DE DISPOSITIVOS
 calllib('libreria','MPUSBGetDLLVersion');
 [conectado] = calllib('libreria','MPUSBGetDeviceCount',vid_pid_norm)
 
 %PREGUNTAMOS SI LA CONEX SE REALIZO
 %SI ES ASI HABILITAMOS EL BOTON ABRIR CONEX 
    if conectado == 1
        set(hAbrirConex,'Enable','on');
    end
    
%/////////////////////////////////////////////////////////////////////////%
%///                    FUNCIONES DE LOS BOTONES                       ///%
%/////////////////////////////////////////////////////////////////////////%
%CREAMOS FUNCIONES PARA CONTORLAR EL ENVIO Y RECEPCION DE DATOS
 function AbrirConexButton_Callback(source,eventdata)
     set(hCerrarConex,'Enable','on');
     set(hAbrirConex,'Enable','off');
     set(hRecibeADCRojoAC,'Enable','on');
     % ABRIMOS EL PIPE DE CONEXION
     [my_out_pipe] = calllib('libreria', 'MPUSBOpen',uint8 (0), vid_pid_norm, out_pipe, uint8(0), uint8 (0)); 
     % SE ENVIA DATO AL PIC
     calllib('libreria', 'MPUSBWrite',my_out_pipe, data_out, uint8(64), uint8(64), uint8(10)); 
 end
 
%FUNCION CERRAR LOS PIPES DDE COMUNICACION
 function CerrarConexButton_Callback(source,eventdata)
     set(hAbrirConex,'Enable','off');
     set(hCerrarConex,'Enable','off');
     set(hCerrarLib,'Enable','on');
     [my_out_pipe] = calllib('libreria', 'MPUSBOpen',uint8 (0), vid_pid_norm, out_pipe, uint8(0), uint8 (0)); % Se abre el tunel de envio
     calllib('libreria', 'MPUSBClose', my_out_pipe); % Se cierra el tunel de envio
    %calllib('libreria', 'MPUSBClose', my_in_pipe); % Se cierra el tunel de envio
     libisloaded libreria
 end
 
%CERRAMOS LAS LIBRERIAS _mpusbapi.h y mpusbapi.dll PARA EVITAR ERRORES
 function CerrarLibButton_Callback(source,eventdata)
     set(hAbrirConex,'Enable','off');
     set(hCerrarConex,'Enable','off');
     unloadlibrary libreria
     libisloaded libreria
 end
 
%CERRAMOS LAS LIBRERIAS _mpusbapi.h y mpusbapi.dll PARA EVITAR ERRORES
 function RecibeADCRojoACButton_Callback(source,eventdata)
     set(hAbrirConex,'Enable','off');
     set(hCerrarConex,'Enable','off');
      % ABRIMOS EL PIPE DE CONEXION
     [my_out_pipe] = calllib('libreria', 'MPUSBOpen',uint8 (1), vid_pid_norm, out_pipe, uint8(0), uint8 (0)); 
     % ENVIAMOS PETICON AL PIC
     calllib('libreria', 'MPUSBWrite',my_out_pipe, data_out, uint8(64), uint8(64), uint8(10)); 
%     for n=0:10
     % RECIBIMOS DATOS DEL PIC
     [my_in_pipe] = calllib('libreria', 'MPUSBOpen',uint8 (0), vid_pid_norm, in_pipe, uint8 (1), uint8 (0));
     [aa,bb,data_in,dd] = calllib('libreria', 'MPUSBRead',my_in_pipe, data_in, uint8(10), uint8(10), uint8(0));
     data_in(1)
     data_in(2)
     data_in(3)
     data_in(4)
     data_in(5)
     data_in(5)
     data_in(6)
     data_in(7)
 %    end
 end
end
Error in Conex_USB_1 (line 43)
loadlibrary mpusbapi _mpusbapi.h alias libreria

After a small reserch I found that there is a .Dll missing file but I don’t how to get it ?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP