
I want to create a NE555P chip only, via command line. Not in stable or astable mode. Just the chip, so I can connect whatever I want later.
2 views (last 30 days)
Show older comments
I also want the chip pin layout to be as in the data sheets.
As a newbie think it´s enough to learn electronics, connect cables, testing, learning Matlab at once :)
1 8
2 7
3 6
4 5
%This is the code i run via Command window:
new_system('NE555P_Model');
open_system('NE555P_Model');
add_block('built-in/Subsystem', 'NE555P_Model/NE555P');
open_system('NE555P_Model/NE555P');
%That creates NE555P Model and opens the new window.
%Then command:
add_block('built-in/Inport', 'NE555P_Model/NE555P/GND');
set_param('NE555P_Model/NE555P/GND', 'Port', '1');
add_block('built-in/Inport', 'NE555P_Model/NE555P/TRIG');
set_param('NE555P_Model/NE555P/TRIG', 'Port', '2');
%Which creates images of:
%Pin 1 GND
%Pin 2 TRIG (both ok)
%Next command:
add_block('built-in/Outport', 'NE555P_Model/NE555P/OUT');
set_param('NE555P_Model/NE555P/OUT', 'Port', '3');
add_block('built-in/Inport', 'NE555P_Model/NE555P/RESET');
set_param('NE555P_Model/NE555P/RESET', 'Port', '4');
% To this point works nice, with correct labels:
%Left side:
%pin 1 GND
%Pn 2 TRIG
%Pin 3 OUT
%Pin 4. RESET
%Now comes the interesting part:
%When I add port 5 with this code:
add_block('built-in/Inport', 'NE555P_Model/NE555P/CTRL');
set_param('NE555P_Model/NE555P/CTRL', 'Port', '5');
%Pin 1, 2, 3 AND pin 5 is correct. BUT
%Pin 4 changed number to 3 still with correct text.
%Continue to ad pin 6
add_block('built-in/Outport', 'NE555P_Model/NE555P/THRES');
set_param('NE555P_Model/NE555P/THRES', 'Port', '6');
%Pin 6 Is correct with text: Thres
% GND pin 1: ok
% TRIG pin 2: ok
% OUT pin 3 changed number => 2
% Reset pin 4 changed number => 3
% pin 5 and 6 OK
% Adding pin 7:
add_block('built-in/Outport', 'NE555P_Model/NE555P/DISCH');
set_param('NE555P_Model/NE555P/DISCH', 'Port', '7');
%Pin 7 DISH (Correct)
%Adding pin 8:
add_block('built-in/Outport', 'NE555P_Model/NE555P/VCC');
set_param('NE555P_Model/NE555P/VCC', 'Port', '8');
%The more pins I add, the more they switch numbers, quite frustrating.
%This is the final result. any one who knows what I´m missing.
I can add up to pin 4 and everything is labeled right:

Pin 6 added, (3) OUT and (4) RESET twisted.

Pin 7 Added:

Pin 8 added.

0 Comments
Accepted Answer
Amish
on 12 May 2025
This is a common confusion when programmatically adding ports to a Simulink subsystem. The issue arises from how Simulink orders the ports on the subsystem block, which is not necessarily the order in which you add them, nor the 'Port' parameter you set.
Simulink orders ports by type (Inport/Outport) and their Port number, but also by their position on the canvas. When you add ports programmatically, their vertical position (the y-coordinate of the block) determines how they are displayed on the subsystem icon. The label shown on the subsystem block (e.g., "1", "2", "3", ...) corresponds to the order in which the ports appear on the left (Inports) or right (Outports) of the subsystem, not necessarily the Port property you set.
This is why the numbering appears to change as you add more ports.
You need to explicitly set the position of each port block inside the subsystem to control their order on the icon. This way, the numbering matches your intended pinout.
You can try the following code snippet:
% Create model and subsystem
new_system('NE555P_Model');
open_system('NE555P_Model');
add_block('built-in/Subsystem', 'NE555P_Model/NE555P');
open_system('NE555P_Model/NE555P');
% Define port names and their vertical positions (y-coordinates)
inport_names = {'GND', 'TRIG', 'RESET', 'CTRL'};
inport_ports = [1, 2, 4, 5]; % User-defined logical pin numbers
inport_ys = [30, 80, 130, 180]; % y-coordinates for vertical order
outport_names = {'OUT', 'THRES', 'DISCH', 'VCC'};
outport_ports = [3, 6, 7, 8];
outport_ys = [30, 80, 130, 180];
for k = 1:numel(inport_names)
blk = add_block('built-in/Inport', ...
['NE555P_Model/NE555P/', inport_names{k}], ...
'Position', [30 inport_ys(k) 60 inport_ys(k)+14]);
set_param(blk, 'Port', num2str(inport_ports(k)));
end
for k = 1:numel(outport_names)
blk = add_block('built-in/Outport', ...
['NE555P_Model/NE555P/', outport_names{k}], ...
'Position', [300 outport_ys(k) 330 outport_ys(k)+14]);
set_param(blk, 'Port', num2str(outport_ports(k)));
end
This will look something like this:

You can also refer to the following documentation:
Hope this answers your query!
More Answers (0)
See Also
Categories
Find more on Discriminant Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!