outputting simulink variable to matlab

edited April 2009 in Science & Tech
i am tryingt o output a number for 1-255 from simulink into matlab and use it imediatly. using the to file and to workspace only updates the data when the stop button is pressed and i am trying to use it in real time, is there some setting that i can not find. i have read multiple how to' s about this but they are not any help.

Comments

  • shwaipshwaip bluffin' with my muffin Icrontian
    edited April 2009
    why do you want to do this?

    I don't have any experience with simulink, but it would seem that you could do whatever you wanted to inside of simulink...
  • edited April 2009
    shwaip wrote:
    why do you want to do this?

    I don't have any experience with simulink, but it would seem that you could do whatever you wanted to inside of simulink...


    i am using the variables in an output command. i have attempted to use the built in rs232 connections but it will not output the correct commands. becasue the system i am using requires letters and numbers, while simulink will only allow me to input numbers into the constants.
  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited April 2009
    Ordinarily what you would want to do is construct the commands you wanted to use as strings and then use fprintf to write the command to the serial port. Can you show us some of your code?

    -drasnor :fold:
  • edited April 2009
    ok so uploaded is my simulink code which has the outputs. they should be from 1-255 when using a 320*640 camera. the code i am trying to implement is
    %port is the variable given to the SV203 connection
    %servo is the servo number you would like to move
    %value is the value you would like the servo to move to

    function servoVal(port,servo,value)

    servo = num2str (servo);
    value = num2str (value);
    transmit = strcat('SV',servo,'M',value);
    fprintf(port, transmit);


    this is code i have received form someone else who is using the sv203 on a different platform.

    where port =
    sv = serial('com7', 'BaudRate', 9600, 'terminator', 'CR/LF');

    i am able to call this in matlab and it works fine but i am trying to call it using values in simulink. by sending to matlab or using the matlab fcn command which does not work for me, or s-functions.
  • edited April 2009
    the simplified code that i have worked out is SV3M85 where the 3 can be changed when the code is not running. but the 85 needs to be continuously sent. or sent every second.

    SV3M85
    is the command that is sent directly to the serial.
Sign In or Register to comment.