CrazyEngineers
  • Hi,
    I want to interface MATLAB with PIC, to do SCADA. MATLAB communicate with USB port, then I have USB-to-UART converter to connect to PIC.
    Does anybody have source to do this? It's is doing in GUI or m file?
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Ashraf HZ

    MemberDec 4, 2010

    Hey shahrul,

    I'm assuming the USB-UART converter is a serial port emulator. In Matlab, you just need to create a serial port object, open it, then read the data. At the most simple, the code will be:

    s = serial('COM1'); % Create serial port object s
    set(s,'BaudRate',9600)
    fopen(s); %open port
    x = fscanf(s); % read data into variable x
    fclose(s) % close port
    delete(s)
    clear s
    The above code assumes you are using COM1 port for the USB serial emulator. You should change accordingly. Also, 8N1 parameter is used as default. Of course, you may need to code more according to your project, refer to the Matlab reference below:

    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • shahrul

    MemberDec 5, 2010

    Thanks, I will try.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register