
USB to RS485 (PC to Pi) Data Transfer
In this chapter, we shall learn how we can transfer data from a PC to a Rasberry Pi device. These will be the initial steps for our Modbus communications which are coming later. We shall show how we can transfer data from a PC to a Raspberry Pi and vice versa. We can do the same to show how we can develop TwinCAT HMI to communicate with pi.

Figure 01: Experimental setup
SerialPort :
Initializes a new instance of the System.IO.Ports.SerialPort class using the specified port name, baud rate, parity bit, data bits, and stop bit.
SerialPort serialPortObject;
serialPortObject = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One);
SerialPort Identification in PC:
When we insert our serial device into a USB port then the Windows OS creates a COM port which can be visible in the device manager.
=> Type ‘Device Manager’ in the Search Box or find control panel | Devices and Printers | Device Manager
The following figure shows that my device has been configured as COM3, if I remove the device then COM3 will disappear.

Figure 02: Identification of COM port
Building a Test App in Windows:
=> Create a Windows Forms App (.Net Framework) application
Download:
Download the sample from the link given above.
References:
=>
=>