Hello everyone,
I have just started my career in automation field. My doubt is very simple but it is complex to me.
I am connecting RS232 to arduino nano and those values to logo plc. In first place before sending the values from RS232. I need to send at least test messages to check whether it will work or not.
I have a sample program of arduino and logo plc. I will attach them with this.
Kindly correct me if I'm wrong and made mistakes somewhere.
Thank You in Advance.
The arduino code is:
#include <ArduinoModbus.h>
#include <SPI.h>
#include <Ethernet.h>
#include <EtherCard.h>
#include <Modbus.h>
#include <ModbusIP.h>
#include <ModbusIP_ENC28J60.h>
//#include <MgsModbus.h>
ModbusIP Mb;
//int analogPin = A0; // nepoužito étend analogového vstupu
int receivel, receive2;
byte mac[]= {0x90, 0xA2, 0xDA, 0x0E, 0x94, 0xB5};
IPAddress ip(192, 168, 0, 9);
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, ip); // start ethernet interface.
Serial.print("The subnet mask is: ");
Serial.println(Ethernet.subnetMask());
Serial.print("The gateway IP address is: ");
Serial.println(Ethernet.gatewayIP());
}
void loop() {
Mb.MbsRun();
Mb.MbData[0]=666; // V LOGO! je to HRI
// Mb.bata[1] analogRead(analogPin); // nepoužito čtení analogového vstupu
Mb.MbData[2] 2020; // V LOGO! je to HR3
receivel = Mb.MbData[3]; // v LOGO! je to HR4
receive2 = Mb.MbData[4]; // v LOGO! je to HRS
Serial.print("send1= ");
Serial.println(Mb.MbData[0]);
//Serial.printlnprobata[1]); // nepoulito ¿tent analogového vstupu
Serial.print("send2= ");
Serial.println(Mb.MbData[2]);
Serial.print("receive1= ");
Serial.println(receivel);
Serial.print("receive2= ");
Serial.println(receive2);
delay(200);
}
The Logo Program is:
