Intergrate the snap7 PLC library into MATLAB via system objects.
- Linux OS
- MATLAB (18a or later) w/ Coder & RTW addons
- PLC (pingable)
Install the snap7 library as outlined in snap7's documentation. Note install not just build, else you will need to modify the sim7.m
source to point to the correct items.
The snap7.h
header file requires some changes to work with MATLAB:
- remove/change the bool typedef
- guard the true/false defines
- add static keyword to all const variable declarations
A MATLAB example is given below:
conn = sim7();
conn.loadSnap7();
u1 = uint8(1);
u2 = uint8(2);
conn.setup(u1,u2);
[y1, y2] = conn.step(u1,u2);
conn.release();
A simulink model is included in the tests folder to demonstrate operation within Simulink. The models compiles via RTW for a standalone executable.
More features are available via S-Functions but system objects are (relatively) quick and easy. Plus they work in MATLAB and don't need TLC for codegen.