M-DUINO Communication

M-DUINO Communication

M-Duino has different communications:

I2C:

I2C communication requires a pull-up resistor (IS.ACI2C-4.7K)

Check the switch configuration to enable I2C port.

TTL:

M-Duino has two TTL ports, RX0/TX0 and RX1/TX1, RX3/TX3.

TTL0 is accessed with the function Serial (pins 0 and 1 of the Arduino Mega).

TTL1 is accessed with the function Serial1 (pins 18 and 19 of the Arduino Mega).

TTL3 is accessed with the function Serial3 (pins 14 and 15 of the Arduino Mega).

Check the switch configuration to enable TTL ports.

SPI:

The M-Duino pins used for the SPI bus are summarized in the table below. For SPI bus MISO, MOSI and CLOCK pins are common to all the connected devices to the M-Duino, conversely, each of the connected devices will have a single and dedicated SS pin.

Function M-Duino connection Mega board pin
MISO 50 SO 50
MOSI 51 SI 51
CLOCK 52 SCK 52
RESET Reset RESET
SS SCL/SDA/RX0/TX0/RX1/TX1/RX3/TX3/Pin2/Pin3 21/20/1/0/19/18/15/14/2/3

 

Check the switch configuration to enable SS pins.

RS-232:

The Arduino Mega function code to access the RS-232 port in the M-Duino is Serial2 (pins 16 and 17 of the Arduino Mega). Check the switch switch configuration to enable RS -232 port.

For an example of RS-232 communication check out Industrial Shields blog.

RS-485:

For RS485 communication protocol the defined Arduino Mega pins are showed in the chart below.

RS-485 Pinout
FUNCTION Arduino Pin
DI 10
RO 11
RE 15
DE 14

 

In order to use RS-485 a serial port must be created on pins 14 and 15 using SoftwareSerial function. Following there is a simple Arduino demo sketch which reads a byte from RS-485 port and echoes it back to the RS-485 bus. 

#define SSerialRX 11 // RO //RS485 Receive pin
#define SSerialTX 10 // DI //RS485 Transmit pin
#define SSerialTxControl 14 // DE //RS485 Direction pin
#define GroundRE 15 // RE
#define RS485Transmit HIGH
#define RS485Receive LOW
SoftwareSerial RS485Serial(SSerialRX, SSerialTX);
void setup() {
digitalWrite(GroundRE,LOW);
RS485Serial.begin(4800);
}
void loop() {
digitalWrite(SSerialTxControl, RS485Receive);
if (RS485Serial.available()) { // Read from RS485!
 digitalWrite(PinLED, HIGH);
 byteRecv = RS485Serial.read();
digitalWrite(SSerialTxControl, RS485Transmit);
RS485Serial.write(byteRecv);
}
}

For another example check Indsutrial Shields blog.

Ethernet:

M-Duino Ethernet port controller is based on w5100 IC, which is the compatible IC compatible with Arduino Ethernet Shield libraries. All Ethernet shield Arduino libraries are compatible with the M-Duino.

In the M-Duino, W5100 IC communicates to the Mega board via SPI bus (SS Arduino Mega pin 53).

Before using the M-Duino Ethernet port, the Arduino IDE on the programming PC must be configured according to the following tutorial. The required .h files for the configuration may be download from this link.

All Arduino sketches intending to use Ethernet on the M-Duino must include the following code lines.

#define SPI_ETHERNET 53
void setup()
{
 pinMode(SPI_ETHERNET, OUTPUT);
 digitalWrite(SPI_ETHERNET,LOW);
}
void loop()

To use the communication in a simple way, you also can use the SimpleComm library of Industrial Shields. This library will help you to process the data. 

See Also: 

RS-485, RS485 AND RS232 IMPLEMENTATION, RS-485 COMMUNICATION EXAMPLE USING OUR LIBRARIESI2CSimpleComm libraryETHERNET ARDUINO PLCHOW TO CONNECT THE ETHERNET PORT USING W5100 LIBRARY

 

Comments are closed.