Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Homepage
Introduction¶
Settimino library for MBED is an MBED porting of Arduino's Settimino library. Settimino was developed by Davide Nardella as a side project of his Snap7 communication suite
http://settimino.sourceforge.net/
Documentation¶
You can find the API documentation in the official Settimino (for ARDUINO) library page
http://settimino.sourceforge.net
Hardware¶
The library implements the protocol over TCP/IP, so the system needs to be connected via Ethernet to the PLC. You need to connect an RJ45 connector to the MBED board. The library was tested using MBED Application Board.
Dependencies¶
Settimino depends on EthernetInterface MBED library, that uses mbed-rtos library. You need to import these libraries in your projects to use Settimino library.
Examples¶
Import program
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 #include "Settimino.h" 00004 00005 // PLC INFO 00006 const char* PLC = "10.0.10.51"; 00007 const int RACK = 0; 00008 const int SLOT = 2; 00009 const int DB = 21; 00010 const int TOT_DATA = 10; 00011 const int OFFSET = 0; 00012 00013 int main() 00014 { 00015 EthernetInterface eth; // Ethernet interface for connection 00016 S7Client client; // Snap7 client 00017 Serial serial(USBTX, USBRX); // USB serial port 00018 00019 // Check EthernetInferface library handbook for details 00020 serial.printf("Connect to network...\r\n"); 00021 eth.init(); //Use DHCP 00022 eth.connect(); 00023 serial.printf("Connected: IP Address is %s\r\n", eth.getIPAddress()); 00024 wait(2); 00025 00026 serial.printf("Connecto to PLC at %s...\r\n", PLC); 00027 while(!client.Connected) 00028 { 00029 if(client.ConnectTo(PLC, RACK, SLOT)) 00030 wait_ms(500); 00031 } 00032 serial.printf("Connected: PDU Length = %d\r\n", client.GetPDULength()); 00033 wait(2); 00034 00035 char buffer[32]; 00036 int result; 00037 serial.printf("Read %d bytes from DB%d, starting at %d...\r\n", TOT_DATA, DB, OFFSET); 00038 result = client.ReadArea(S7AreaDB, // Area type 00039 DB, // DB address 00040 OFFSET, // Byte offset 00041 TOT_DATA, // Tot bytes to read 00042 buffer); // buffer that will store read data 00043 if(result != 0) 00044 { 00045 serial.printf("ERROR %d\r\n", result); 00046 } 00047 else 00048 { 00049 serial.printf("Read data:\r\n"); 00050 for(uint16_t i = 0; i < TOT_DATA; i++) 00051 serial.printf("%c", buffer[i]); 00052 serial.printf("\r\n"); 00053 } 00054 wait(2); 00055 00056 serial.printf("Disconnect from PLC...\r\n"); 00057 client.Disconnect(); 00058 00059 serial.printf("Disconnect from network...\r\n"); 00060 eth.disconnect(); 00061 00062 serial.printf("\r\n-- Test terminated --\r\n\r\n"); 00063 00064 while(1) {} 00065 }
The test program requires that the MBED can see the PLC whithin the network, and that the PLC expose the requested DB. It is possible to simulate a PLC running Snap7 server example program, contained in the Snap7 library package (http://snap7.sourceforge.net), from a PC.
Running this example the mbed will output something similar from the serial port:
Connect to network... Connected: IP Address is 10.0.10.213 Connecto to PLC at 10.0.10.51... Connected: PDU Length = 240 Read 10 bytes from DB21, starting at 0... Read data: DB content Disconnect from PLC... Disconnect from network... -- Test terminated --