How can I send variable value with To Instrument Simulink block?

72 views Asked by At

I am using an external PSU (RIGOL DP832) and I would like to set the voltage and current using simulink but I am not able to do it with simulink.

I am using the Instrument Toolbox and the Support Package for Keysight IO Libraries and VISA Interface. For matlab it is straight forward, this is the code

PSU = visadevlist();
vi = visa('agilent',PSU{1,1});

fopen(vi);
fprintf(vi, ':INST CH2'); 
fprintf(vi, ':VOLT 27.3');
fclose(vi);

but with simulink I am not able to send the value of a variable to the PSU. I am using the To Instrument block, and this is my simple simulink diagram,

enter image description here

and these are my properties

enter image description here

Any idea how to do this? I am also open to other alternatives, but I need parametric input for simulink

1

There are 1 answers

0
scotty3785 On

I'm not familiar with the block but having read the documentation I'd suggest the following

Change your command to

':VOLT '

The block will then add the value from the inport of the block to the end of the above command.

In your example you've added the voltage as a fixed value in the command string.