Build Model / Code Generation Fail
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have created a logic with simulink and stateflow and have generated code which i loaded into dspace Controldesk. The logic works fine (i can set variables in Controldesk and it changes States like set in the stateflow charts).
But i also created an output signal from simulink to a power supply by using the "to instrument" block and writing a SCPI command in it. The control of the power supply works fine if i'm just running the simulink model. If i try to generate code again from the model to implemnt the code in controldesk, i get the following error after simulink created all the c-files:
OPUS MAKE: Don't know how to make 'SendInstrument.o03'. Stop
If I comment the block out, it works again. But i need to control the power supply with the code implmented in control desk. Isnt it possible to create code for serial communication with a "to instrument" block?
The code generation works if i'm using a serial send block, but where do i define my scpi command and do i need a data type conversion between the constant block (double) and the serial send? Its also only possible to usel one serial send block.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1431753/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1431758/image.png)
0 Kommentare
Antworten (1)
Akshat
am 25 Aug. 2023
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:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Deployment, Integration, and Supported Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!