Browsed by
Autor: Technical Service

How to use a Max3232 with Arduino based PLC

How to use a Max3232 with Arduino based PLC

On this post it is showed how to connect a Max3232 to an M-Duino PLC family.                                      

Max3232 has a two lines of RS-232 communication and their respective two channels of TTL and also power supply pins (3-5,5V-GND). 

How to connect M-Duino PLC whit the Max3232?

M-Duino has two available serial TTL, RX1/TX1 (or Serial1) and RX3/TX3 (or serial3).  Connecting RX1/TX1 with T1IN/R1OUT and RX3/TX3 with T2IN/R2OUT the MAX3232 is ready to transmit and receive the data (don’t forget to connect the power supply). Next it is showed a electric connections diagram:

 

Once the connections are set it’s possible to proceed to upload a sketch to test if the MAX3232 are working as expected. On this sketch it’s just used one of them because the other it’s just a copy. Actually the MAX3232 is doing all the hard work, for the user just have to code as a normal TTL serial port using serial1 or serial3 as is showed bellow.

Next it is showed the test sketch:

#define TTL Serial1 // Serial1 or Serial3

/////////////////////////////////////////////////////////////////////////////
void setup() {
  Serial.begin(9600L);
  Serial.println("ttl started");

  TTL.begin(115200L);
}

/////////////////////////////////////////////////////////////////////////////
void loop() {
  if (Serial.available()) {
    byte in = Serial.read();
    TTL.write(in);
  }

  if (TTL.available()) {
    byte in = TTL.read();
    Serial.write(in);
  }
}

 

See also:

RS-232 TEST ON M-DUINO PLUS

RS485 AND RS232 IMPLEMENTATION

 

Pulses module library on Tools40 for Arduino based PLC’s

Pulses module library on Tools40 for Arduino based PLC’s

Pulses module library is a library inside of Tools40 make it for Industrial Shields developers to use pulses or square wave forms (SQW) on the PWM Pins of  Industrial Shields equipment’s. 

The startPulses(Pin, Frequency, Precision) function starts the train of pulses at the specified frequency and precision. The default frequency is 1kHz and the default precision is 3.

pinMode(3, OUTPUT);

startPulses(3, 2000, 3);

Read More Read More

RS-485 TEST ON Ardbox HD

RS-485 TEST ON Ardbox HD

In this post it is showed how to test the RS-485 on Ardbox HF version.

The first thing that you need to know is that the  RS-485 HF version have full and half duplex communication. Controlling the dip switch you must select if you want to work on full or half duplex. There is internally installed a half duplex MAX485 and MAX485 transmitter. If you are working on full duplex you will use the MAX485 half duplex to receive data and MAX485 transmitter to send the data.

If you are working half duplex or full duplex the mapping is:

Max485 Arduino Pins
RX (RO) RX Serial1 (0)
TX (DI) TX Serial1 (1)
RE (inverted logic) 11
DE 10

 

To do the full duplex test you must connect the A, B (receivers) to the Y, X(transmitters). For half duplex you must connect with another device with RS-485 and select if you want to transmit or receive data with comment or uncomment “#define” command.

Next it is showed the test code for half duplex:

#define TEST_RS485_TX
//#define TEST_RS485_RX
 
int _rs485DE = 10;
int _rs485RE = 11;

///////////////////////////////////////////////////////////////////////////////
void setup() {
  Serial.begin(9600L);
  Serial.println("M-Duino PLUS RS-485 test started");
  
  Serial1.begin(9600L);
  pinMode(_rs485RE, OUTPUT);
  digitalWrite(_rs485RE, LOW);
  pinMode(_rs485DE, OUTPUT);
  digitalWrite(_rs485DE, LOW);
}
//////////////////////////////////////////////////////////////////////////////
void loop() {

#if defined TEST_RS485_TX
  digitalWrite(_rs485RE, HIGH);
  digitalWrite(_rs485DE, HIGH);
  Serial1.write(0x12);
  Serial1.flush();
  digitalWrite(_rs485DE, LOW);
  digitalWrite(_rs485RE, LOW);
  delay(1000);
#endif // TEST_RS485_TX

#if defined TEST_RS485_RX
  if (Serial1.available()) {
    if (Serial1.read() == 0x12) {
      Serial.println("RX");
    }
   }
#endif // TEST_RS485_RX
}

 

Next it is showed the test code for half duplex:

int _rs485DE = 10;
int _rs485RE = 11;

///////////////////////////////////////////////////////////////////////////////
void setup() {
  Serial.begin(9600L);
  Serial.println("M-Duino PLUS RS-485 test started");
  
  Serial1.begin(9600L);
  pinMode(_rs485RE, OUTPUT);
  digitalWrite(_rs485RE, LOW);
  pinMode(_rs485DE, OUTPUT);
  digitalWrite(_rs485DE, LOW);
}
//////////////////////////////////////////////////////////////////////////////
void loop() {
  digitalWrite(_rs485RE, HIGH);
  digitalWrite(_rs485DE, HIGH);
  Serial1.write(0x12);
  Serial1.flush();
  digitalWrite(_rs485DE, LOW);
  digitalWrite(_rs485RE, LOW);
  delay(1000);

  if (Serial1.available()) {
    if (Serial1.read() == 0x12) {
      Serial.println("RX");
    }
   }
}

See also:

RS-485 TEST ON M-DUINO PLUS

How to connect Arduino based PLC with a OPC SCADA compilan

How to connect Arduino based PLC with a OPC SCADA compilan

On this post it is showed how to connect an Arduino based PLC with any OPC SCADA compilan. To do this you can use M-Duino familyand Ardbox family .

This example require:

  • Arduino based PLC
  • OPC Server for Arduino
  • OPC libraries for Arduino IDE

 

How to intall OPC Server?

OPC Server allows you to connect your Arduino with any OPC Scada Compilant. Just use the OPC.h library in your Arduino sketches, publish your items and provide data for each item you published in real time. You could retrieve/send information from/to your SCADA HMI software for building industrial applications.

Follow the next instructions to install the OPC Server on this link of Software Tools for Makers.

Once OPC Server is installed we can proceed to install OPC libraries for Arduino IDE.

 

How to install OPC libraries on Arduino IDE?

To install OPC libraries follow the next lines:

  • Open Arduino IDE
  • Go to Sketch –> Include library –> Manage libraries
  • On library Manager search “OPC”
  • Click on install  

 

How to use?

Software Tools for Makers has developed this software. On their web side there is few examples of how to use with dOPC Explorer, Matricon OPC Explorer and WinCC. Just take on mine that Industrial Shields PLC’s use an official Arduino Leonardo within Ardbox family and Arduino Mega within M-Duino family.

For example on our internal test we have used a WinCC SCADA system and M-Duino following the Software Tools for Makers example.

Software Tools for Makers example use an Arduino Uno. To make it work this example with Industrial Shields PLC’s we just need to change the Arduino Uno pins for the Mega or Leonardo pins or if you are using our boards use directly the M-Duino or Ardbox pins. Once these changes are done we can proceed to test it.

 

See also:

How connect Arduino based PLC with Siemens PLC equipped with Ethernet port

How to Install and use Rapid SCADA on Touchberry Pi and BananaTouch

How to Install and use Rapid SCADA on Touchberry Pi and BananaTouch

On this post is showed how to install Rapid SCADA on a Touchberry B3 PI 10.1″, BananaTouch Octacore M3 10.1″, BananaTouch M64 10.1″ and TouchBerry Pi B3 7″ IN/OUT.

These products use an official Raspberry Pi 3 or an official Banana Pi products. These products have installed a Linux Debian Jessie. So,on this post we will see how to install Rapid SCADA on this OS. Rapid SCADA is free, open source, full featured SCADA software. 

This post is divided for three section: how to install Rapid SCADA,  how to configure Rapid SCADA and how to displayed on the Touch.

Read More Read More

RS-485 TEST ON M-DUINO PLUS

RS-485 TEST ON M-DUINO PLUS

In this post it is showed how to test the RS-485 on M-Duino PLUS version.

The first thing that you need to know is that the  RS-485 PLUS version have full and half duplex communication. Controlling the dip switch you must select if you want to work on full or half duplex. There is internally installed a half duplex MAX485 and MAX485 transmitter. If you are working on full duplex you will use the MAX485 half duplex to receive data and MAX485 transmitter to send the data.

If you are working half duplex or full duplex the mapping is:

Read More Read More

Ethernet test on M-Duinos PLUS version

Ethernet test on M-Duinos PLUS version

In this post it is showed how to test Ethernet communication on M-Duino PLUS version

It’s necessary to install Arduino Ethernet2 library. See more infromation about Ethernet library functions on Arduino Reference.

Connecting an M-Duino to a router through Ethernet and uploading the test sketch, the M-Duino is able to complete the test.  

Next is showed the code:

Read More Read More