Interfacing MSP432 and Raspberry Pi over MODBUS

Hi,
I'm a new to Modbus.
I'm trying to do a communication between MSP432 and Raspberry Pi over MODBUS- (ASCII RS232) protocol. I have a PCB board which uses
MSP432 and has a USB port. This port should be connected to RPi on MODBUS and establish communication
please help me with some pointers or any example programs?

thanks,
 
There are a lot of confusing statements in your post. Please clarify the following so that we are able to understand and help you.

  1. Is the MSP432 you're referring to the MSP432 microcontroller from Texas Instruments?
  2. Which device(s) are you programming, the Pi, MSP432, or both?
  3. There are two different versions of Modbus for serial lines - RTU and ASCII. Please confirm which version you need (if you have a choice, I recommend RTU as it's more efficient)
  4. Please clarify the connection method between the two devices. You first state you want to communicate Modbus ASCII via RS-232 between the MSP432 and Pi, but then state you want to connect the USB port to the Pi. Which is it? RS-232 is typically connected using a serial cable with DB-9 connectors. And while it could be possible to communicate Modbus via USB (using the USB Communication Device Class, i.e. virtual COM port), this is not very common and the code running on the MSP432 would need to implement this USB class. Typically, to communicate Modbus between two CPU's, you would connect a UART's TX and RX signals from each CPU together (TX to RX and RX to TX), and of course, also have a common ground connection.
 
Hi jschulze,

Sorry for not being clear.
  • Yes, MSP432E411 is the microcontroller from TI
  • I'm programming on Pi
  • I need the Modbus ASCII version
  • the connection method between the RPi and MSP432 is USB, so want to communicate Modbus via USB.
 
Thank you for the details. Since you're only programming the Pi, presumably someone else has already programed the MSP432E411 to support communicating Modbus ASCII via USB (where the USB driver on the MSP432E411 enumerates as a Virtual COM Port USB device). Is this correct?

We need to know what software is running on the MSP432E411 and what capabilities it has in order to help you communicate to it from the Pi.

Is the PCB that includes the MSP432E411 and USB port a commercially available device or did you or someone else create this PCB?
 
Yes, you are correct someone else has already programed the MSP432E411 to support communicating Modbus via USB and on MSP432E411 gets enumerated as a Virtual COM.

Can you elaborate on " We need to know what software is running on the MSP432E411 ". I am not sure about the software being used. However they are using windows API to communicate like windows.h and api.h(and Functions like CreateFile,WriteFile,ReadFile) were used.

I am trying it replicate this same thing on RPi(Debian) - using the functions like open(),read(),write(). The port gets enumerated as /dev/tty/ACM0. However I am not able to read anything or write anything. There is an onboard LED on MSP432E411 board trying play with it with no success.

About the Modbus the protocol being implemented on Software running on MSPxxxx is using Modbus TCP.

My sample code is as follows:

char *sComPort = "/dev/ttyACM0";

int iOut, file_des; // file descriptor
// set settings for serial port
// system("stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parity -icanon hupcl -crtscts min 1 time 1");

//Open the port
file_des = open(sComPort, O_RDWR);// | O_NOCTTY | O_NONBLOCK);
if (file_des <0)
{
perror("/dev/ttyACM0");
printf("Could not open the dev/ttyACM0 port\n");
exit(-1);
}
if(file_des>0)
{
printf("Port is opened successfully\n");
}


//outBuf[] used to define the outgoing Modbus command (TCP frame format)

int wr = write(file_des, outBuf, 12);
printf("Port was able to WRITE %d # of bytes\n",wr);
if(wr < 0){
printf("%d %s \n", errno, strerror(errno));
}

int rd = read(file_des, inBuf, 1);
printf("Port was able to READ %d # of bytes\n",rd);
if(rd < 0){
printf("%d %s \n", errno, strerror(errno));
}




Thanks in advance.
 
Can you elaborate on " We need to know what software is running on the MSP432E411 ". I am not sure about the software being used.
I was trying to determine what software on the MSP432E411 is performing the Modbus communication and whether it is custom software created from scratch or commercially available software. Is there any documentation available?

You will need to know what registers (i.e. data) are available to be accessed on the MSP432E411 via Modbus communications.

However they are using windows API to communicate like windows.h and api.h(and Functions like CreateFile,WriteFile,ReadFile) were used.
Who is "they" and where/how are "they" "using windows API"? Are you saying there is software, or code written, for a Window's PC to communicate to the MSP432E411 via Modbus over USB? If so, can you share this software/code?

About the Modbus the protocol being implemented on Software running on MSPxxxx is using Modbus TCP.
This is very confusing. Are you absolutely sure it's Modbus/TCP and not one of the serial-line versions Modbus ASCII or Modbus RTU? It's not possible to communicate Modbus/TCP over a USB Virtual COM port (Modbus/TCP is only used on Ethernet ports, since it runs on top of TCP/IP). Although unlikely, the MSP432E411 may be implementing a proprietary version of Modbus where it's using just the Modbus PDU (protocol data unit) or ADU (application data unit, which would include the MBAP header) from Modbus/TCP without using the Ethernet, IP, or TCP headers.

You need to figure out EXACTLY what version of Modbus is used by the MSP432E411.

After that (assuming the protocol is standard Modbus ASCII or Modbus RTU), I strongly recommend using proven, third-party Modbus Master software on your Raspberry Pi to confirm communications via the ttyACM0 port before attempting to write your own software. One example is modpoll, which is available here:
https://www.modbusdriver.com/modpoll.html
 
Top