Petri Net to PLC Program converter:

Inputs Mapping

December 2016, José Gaspar

 

Abstract

In this page is published a specification for encoding PLC hardware inputs to Petri net transitions.

 

Specification

An example of inputs mapping is the following:

function inp_map= define_input_mapping

inp_map= { ...

    0,        4 ; ... % input0 fires transition4

    -(0+100), 5 ; ... % negated input0 fires t5

    };

In this example one has the input bit number 0 firing transitions numbers 4 and 5. In the first case the input bit is used directly, while in the second case its negated logic value is used instead. Notice that negating the input is represented by adding 100 to the number of the bit, and prefixing the result with a minus sign.

The inputs specification is used by the main compiling function plc_make_program.m

function plc_make_program(ofname, PN, input_map, output_map, show_places)

%

% Write to file a PLC program (structured text) given a Petri net (PN),

% and given the input/output physical mappings. May also add a list of

% places (only one active at each moment), to be shown as PLC outputs.

which calls multiple times the auxiliary function plc_map_inputs.m :

function prg_tfire = plc_map_inputs( inp_bits_lst, trans_lst, options )

%

% inp_bits_lst : 1xN : PLC input module list of bits

% trans_lst : 1xN : Petri net transitions list (indexes, not strings)

%

% prg_tfire : list of strings : lines of structured text

 

This function is called once per line of the Nx2 list inp_map previously introduced. The general description of the inp_map is that the first column contains physical inputs specification while the second column contains an identification of the Petri net transition. In the following are various examples of specifications of input mappings.

First example, one input to one transition:

inp_map= { 15, 25 }; % map input 15 (e.g. %i0.3.15) to transition t25

 

Second example, AND of two inputs to one transition:

inp_map= { [0 4]', 4 }; % input 0 AND input 4 -> transition 4

 

Third example, ANDs of pairs of inputs to transitions:

inp_map= { [1 2 3; 4 4 4], [5 6 3] };
% i1 & i4 -> trans5

% i2 & i4 -> trans6

% i3 & i4 -> trans3

 

Fourth example, negating entries of some inputs:

inp_map= { [-100 -101 -102 -103; 4 4 4 4], [9 10 7 8] };

% NOT(i0)&i4 -> trans9

% NOT(i1)&i4 -> trans10

% NOT(i2)&i4 -> trans7

% NOT(i3)&i4 -> trans8

 

 

Fifth example, OR of ANDs and NOR of ANDs:

mylst= {{[0 1], [0 2], [0 3], [1 2], [1 3], [2 3]}};

inp_map= { struct('op', 'OR_of_ANDs', 'transId',28, 'lst',mylst), []};

inp_map= { struct('op', 'NOR_of_ANDs', 'transId',28, 'lst',mylst), []};

 

In this last case transition 28 is the negation of a multi-entry OR. Each entry of the OR is a AND. More in detail: NOT( i0&i1 OR i0&i2 OR i0&i3 OR i1&i2 OR i1&i3 OR i2&i3 ) -> trans28.

 

Download and Usage

Download the zip file pn_to_plc_v2.zip and decompress it to a folder of your choice.

To run the main demo:

>> cd tst1_blink_turn_on_off
>> tst1_blink_on_off

 

Acknowledgments

In case you find this material useful and do any publication in the sequel please refer to the course Industrial Automation at Técnico, University of Lisbon.

 

Contact

Prof. José Gaspar
Instituto de Sistemas e Robótica,
Instituto Superior Técnico, Torre Norte
Av. Rovisco Pais, 1
1049-001 Lisboa, PORTUGAL

Office: Torre Norte do IST, 7.19
phone : +351 21 8418 293
fax : +351 21 8418 291
www : http://www.isr.ist.utl.pt/~jag
e-mail: