General

Welcome!

This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

Serial communication M-Duino 38R+ with softwareSerial

Avatar
Sylvain Bernard


Hello, I am trying to reproduce the following code to communicate in serial.

https://www.industrialshields.com/es_ES/blog/blog-industrial-open-source-1/post/como-utilizar-la-libreria-de-software-serial-en-el-controlador-industrial-arduino-plc-99


On the M-Duino 38R + the RX (SO), TX (SI) pins are respectively 50, 51

So, I wired tx from the device to RX MDuino and rx from the device to tx from MDuino


For information, here is the device with which I tried to communicate with M-Duino : https://learn.sparkfun.com/tutorials/sparkfun-rfid-starter-kit-hookup-guide



// https://github.com/PaulStoffregen/SoftwareSerial
#include <SoftwareSerial.h>

// https://github.com/agmangas/SerialRFID #include <SerialRFID.h> const byte RX_PIN = 50;//PIN_SPI_MISO; const byte TX_PIN = 51;//PIN_SPI_MOSI; SoftwareSerial sSerial(RX_PIN, TX_PIN); // RX (SO), TX (SI) SerialRFID rfid(sSerial); char tag[SIZE_TAG_ID]; char matchTag[SIZE_TAG_ID] = "5C00CADB5A17"; //SoftwareSerial mySerial(50, 51); // RX (SO), TX (SI) void setup() { Serial.begin(9600); sSerial.begin(9600); Serial.println(); Serial.println(">> Starting SerialRFID example program"); } void loop() { if (rfid.readTag(tag, sizeof(tag))) { Serial.print("Tag: "); Serial.print(tag); Serial.println(); //if (SerialRFID::isEqualTag(tag, matchTag)) //{ // Serial.println(" / Match: OK"); //} //else //{ // Serial.println(" / Match: No"); //} } }

I tested the following code on the arduino mega (basic) and it works ...

Response arduino mega (basic)
>> Starting SerialRFID example program Tag: 4300926D45F9 Tag: 4300926D45F9


Is there something I don't understand?

Thank you in advance for your answer.



Avatar
Descartar
2 Respuestas
0
Avatar
Sylvain Bernard
Best Answer

hello, thank you for your quick response.

12VDC power supply check - OK

I therefore tried to connect the GND of the external 12VDC power supply to the GND of the 5VDC output of M-DUINO, that did not change anything.


I specify that the device is connected to the 5VDC power supply of M-Duino


If you have other subjection, I am interested.


Here is the link of the diagram (M-Duino on the left in the pdf and arduino on the right in the pdf).

Lien vers mon shéma (one drive) : https://1drv.ms/u/s!AtNw4GbNMHxrkdMdCm1vlc5nWhEyjw?e=7dtlCl



Avatar
Descartar
0
Avatar
Support Team
Best Answer

Hi Silvayn, 

let's check all the steps to achieve this simple communication: 


on your MDuino 38R+ the first thing you need for this testing purposes is to have the PLC connected to the external Power Supply Unit (12/24Vdc), it will not work only with the 5Vdc provided by the USB connection.


There are no switch available to able/disable the SPI connectivity, so that it's always operative. 


Regarding the connections, it's important to have also a common GND between both devices in order to have the same GND reference. 


I see no errors on the programming, the sketch is ok and also the RX pin used (50 - MISO) can be used for this purpose. 


Please let us know if your set up is as exposed and we keep in contact,

Avatar
Descartar