Hi Tobias,
As mentioned in the documentation of the “to instrument” block, code generation is not supported by this block. Hence, you can try out the following approach:
Use the “Serial Send” block from the Simulink library. As mentioned by you, there is an issue; how to get the SCPI command as the input to the Serial Send block?
As there is no way to have a constant block do the job of getting an SCPI command to the input of the Serial Send block, there is something I think can work, and you can try it.
You can add a MATLAB function block in Simulink and connect it to a MATLAB function. The function template will be something like this:
function mySCPICommand()
% Open the serial port
s = serial('COM1');
fopen(s);
% Send the SCPI command
fprintf(s, 'your_scpi_command\n');
% Close the serial port fclose(s);
end
The output of this function block can be then used as the input to the Serial Send block, with the appropriate configuration.
Also, yes, you might have to make some typecasting, and for that you can use functions like “num2str” for that purpose.
Hope this helps!
These links were really helpful to me:


