Settimino на Ардуино
- Войдите на сайт для отправки комментариев
Втр, 13/12/2016 - 10:35
Добрый день, форумчане. Перерыл весь интернет но толком не нашел информации. Может кто то сталкивался? Проблемма вот в чем. Есть библиотека Settimino (легко гуглится офф сайт). По ней происходит подключение к промышленому контроллеру Siemens. Должно происходить подключение. Несмотря на все примеры к данной библиотеке не получилось установить связь. Может кто то работал с этой библиотекой и знает выход из данной ситуации?
У меня ардуино уно. Модуль Ethernet MiniENC ENC28J60 (есть подозрения что этот модуль не подходит) из примеров работы с этим модулем, все хорошо, модуль цел. Связь по Ethernet с контроллером siemens 300.
#include "EtherCard.h"
#include "Settimino.h"
// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,1,250 };
byte Ethernet::buffer[500];
BufferFiller bfill;
unsigned long Elapsed; // To calc the execution time
//IPAddress Local(192,168,0,90); // Local Address
IPAddress PLC(192,168,1,50); // PLC Address
int DBNum = 110; // This DB must be present in your PLC
byte Buffer[64];
S7Client Client(_S7WIRED);
bool Connect()
{
int Result=Client.ConnectTo(PLC,
0, // Rack (see the doc.)
2); // Slot (see the doc.)
Serial.print("Connecting to ");Serial.println(PLC);
if (Result==0)
{
Serial.print("Connected ! PDU Length = ");Serial.println(Client.GetPDULength());
}
else
Serial.println("Connection error");
return Result==0;
}
void CheckError(int ErrNo)
{
Serial.print("Error No. 0x");
Serial.println(ErrNo, HEX);
// Checks if it's a Severe Error => we need to disconnect
if (ErrNo & 0x00FF)
{
Serial.println("SEVERE ERROR, disconnecting.");
Client.Disconnect();
}
}
void MarkTime()
{
Elapsed=millis();
}
void ShowTime()
{
// Calcs the time
Elapsed=millis()-Elapsed;
Serial.print("Job time (ms) : ");
Serial.println(Elapsed);
}
void Dump(void *Buffer, int Length)
{
int i, cnt=0;
pbyte buf;
if (Buffer!=NULL)
buf = pbyte(Buffer);
else
buf = pbyte(&PDU.DATA[0]);
Serial.print("[ Dumping ");Serial.print(Length);
Serial.println(" bytes ]===========================");
for (i=0; i<Length; i++)
{
cnt++;
if (buf[i]<0x10)
Serial.print("0");
Serial.print(buf[i], HEX);
Serial.print(" ");
if (cnt==16)
{
cnt=0;
Serial.println();
}
}
Serial.println("===============================================");
}
void setup() {
Serial.begin(9600);
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println(F("Failed to access Ethernet controller"));
ether.staticSetup(myip);
}
void loop() {
int Size, Result;
void *Target;
Size=64;
Target = NULL; // Uses the internal Buffer (PDU.DATA[])
while (!Client.Connected)
{
if (!Connect())
delay(500);
}
Serial.print("Reading ");Serial.print(Size);Serial.print(" bytes from DB");Serial.println(DBNum);
// Get the current tick
MarkTime();
Result=Client.ReadArea(S7AreaDB, // We are requesting DB access
DBNum, // DB Number
0, // Start from byte N.0
Size, // We need "Size" bytes
Target); // Put them into our target (Buffer or PDU)
if (Result==0)
{
ShowTime();
Dump(Target, Size);
}
else
CheckError(Result);
delay(2000);
}
xx1raven1xx, есть ли успех? С такой же проблемой сейчас столкнулся.
Нет, я ничего не добился от этих модулей. Давно уже забросил все это. Пишу потихоньку свою скаду для ПК на Autohotkey.