Shop OBEX P1 Docs P2 Docs Learn Events
MATLAB serial communication with Prop — Parallax Forums

MATLAB serial communication with Prop

CHAD.GCHAD.G Posts: 11
edited 2011-03-14 07:36 in Propeller 1
Anyone here achieved serial communication between their Prop and MATLAB? I'm attempting to use FullDuplexSerialPlus along with the MATLAB commands specified in the help docs. I'm struggling to get the devices to even connect on the COM port.

Thanks for any help.

Comments

  • LeonLeon Posts: 7,620
    edited 2011-03-14 07:03
    Get it working with an ordinary terminal program, initially.
  • CHAD.GCHAD.G Posts: 11
    edited 2011-03-14 07:09
    Leon wrote: »
    Get it working with an ordinary terminal program, initially.

    As in the Parallax Serial Terminal window? Done. It's not what I'm trying to send that I'm stuck on, it's simply connecting the Prop and MATLAB to the COM port that I'm stuck.

    (Note: Sending me links to the MATLAB help files will not assist me further at the moment, I'm already looking through those).
  • Mike GMike G Posts: 2,702
    edited 2011-03-14 07:24
    Propeller Pins 30 and 31 on COM 5
    CON
        _clkmode = xtal1 + pll16x
        _xinfreq = 5_000_000
    
        
    DAT
      message     byte      "Hello World",0
    
    OBJ
      serial : "FullDuplexSerial"
    
    
    PUB main
    
      serial.Start(31, 30, 0, 115200)
      
      repeat 
        serial.str(@message)
        serial.tx(13)
        waitcnt(cnt + clkfreq/2) 
    

    Matlab
    function SerialTest()
    
        % Set the port paramenter
        s=serial('COM5', 'BaudRate', 115200, 'Parity', 'none', 'DataBits', 8, 'StopBits', 1);
        s.terminator = 'CR';
        % open the port
        fopen(s);
        
        % display the com port resources
        com = instrfind;
        disp(com);
      
        % Expecting x bytes
        out=fread(s,11);
        
        % Display the byte
        disp(out);
        
        % Clean up
        fclose(s);
        delete(s);
        clear s;
    end
    
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-03-14 07:36
    There is a post at this link http://forums.parallax.com/showthread.php?106241-Connect-the-Boe-Bot-to-MATLAB&p=748346 where a BS2 was used to send a message to Matlab , the OP refers to a web page with instructions.

    I don't have Matlab so I don't know how useful this information would be for you.

    Jeff T.
Sign In or Register to comment.