0

I am trying to write following inner current control loop structure in MATLAB. Both these diagrams are inter related and using these diagrams I made a following code, my aim in this code is to minimize id*-id, i am doing this by using ITEA. plz help me in verifying this code. the diagram is in image link below. i have implemented that link in code below.

`

user12318
  • 33
  • 6

1 Answers1

0

The standard way to connect a block diagram is to use append/connect. Your system actually is system.

To connect the output, we need the additional block 7 (we can not connect the system output to the input of some block, only to the output): new system

So, the code can look like this:

sys1= tf(1,[Lt Rt]);
sys2= omega*Lt;
sys3= omega*Lt;
sys4= tf(1,[Lt Rt]);
sys5= (Kp + Ki/s);
sys6=(Kp + Ki/s);
sys7 = 1;
system= append(sys1,sys2,sys3,sys4,sys5,sys6,sys7);
connections= [ 1 2 -5;
    2 4 0;
    3 1 0;
    4 -3 -6;
    5 7 0;
    6 -4 0;
    7 -1 0];  
inputs=  [7 4 5 6];
outputs= 7; 
system= connect(system,connections,inputs,outputs); 

Note that you can't use name-based and index-based connections at one time.

AVK
  • 2,130
  • 3
  • 15
  • 25
  • after writing this code, should i make this block in simulink as well? or this code is enough to make a diagram in m file? – user12318 Jul 29 '17 at 08:56
  • what about inputs section?are these just random no, or assigned by connections command? – user12318 Jul 29 '17 at 09:32
  • No, you should not. This code uses the Control System Toolbox functions. It does not use Simulink in any way – AVK Jul 29 '17 at 09:59
  • `inputs` contains the indices of the blocks connected to the global system input – AVK Jul 29 '17 at 10:03
  • plus how i can add this block output to input of the other in the picture? – user12318 Jul 29 '17 at 10:13
  • You can use the same method, `append` and `connect` the constructed blocks – AVK Jul 29 '17 at 10:18
  • so if i want to add any input to this block, what is the code for it, for example ed=0.4, input=[0.4,'1'], does it goes like that? – user12318 Jul 29 '17 at 13:37
  • As far as I understand, you mean simulation. It is a different question and it requires a separate answer. Briefly, you can use `step` (if your input is a constant) or `lsim` functions – AVK Jul 29 '17 at 14:44
  • no sir, i am asking this question in terms of matlab coding not simulation. – user12318 Jul 29 '17 at 16:10
  • how i can the `vq` and `vq` inputs in this code, plus if if i want to give some values to inputs and output how i should do that? – user12318 Jul 29 '17 at 16:33
  • You mean the open-loop control (the input of the system is equal to some u(t), in particular, u(t)=const). The open loop control information is not stored in lti objects. You should provide it for modeling the output of your system (when using `step`, `lsim` or smth else) This modeling is called simulation, it has nothing to do with Simulink – AVK Jul 30 '17 at 06:24
  • `vq` and `vq` can be added using additional -1 gain blocks connected to the inputs. – AVK Jul 30 '17 at 06:28