sending and receiving frames over RS485 with Raspberry Pi

4.6k views Asked by At

My task at work is to use a Raspberry Pi 3 to controll a turntable. The turntable has an internal RS485 serial port which can be accessed through a build in FTDI USB converter (USB-RS485-WE-1800-BT). I am using Raspbian Jessie Lite on the Pi and have not jet decided, what programming language to use.

First of all it seems to me, the FTDI converter is properly installed. Please correct me if I am wrong:

pi@turntable_ctl1:~ $ dmesg | grep FTDI
[    2.236219] usb 1-1.3: Manufacturer: FTDI
[    5.085380] usbserial: USB Serial support registered for FTDI USB Serial Device
[    5.086330] ftdi_sio 1-1.3:1.0: FTDI USB Serial Device converter detected
[    5.087760] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB0

Also if I run minicom -D /dev/ttyUSB0 (there turn hardware flow control off and software flow controll on and set the baudrate to 19200 8N1) the red LED inside the USB plug of the converter is blinking with every of my keystrokes.

Unfortunately there is no complete documentaion for the turntable, because it is custom made for us by a company in france. The guys there have provided me with this graphic (half in english/half in french) along with the following information:

"When you send us a PC frame the board respond with a MT frame."

As far as I understand this, to get the table turning I now have to open an RS485 connection on the /dev/ttyUSB0 and then do something like:

sendChar(P)
sendChar(C)
sendChar(1)
sendChar(100)  // for example
sendChar(1)    // for example

But I have no idea how to do that in any programming language. And even worse, I was not able to find any sample of code that does this, allthough I expected this to be a rather standard task.

So if anyone could point me in the right direction or tell me where my train of thought went off the rail, I would be very grateful!

Thanks for your time! Mark

1

There are 1 answers

0
Mark On BEST ANSWER

If this may concern anyone other than me, here is my solution: After some more searching and a lot of hints from friends I found this library that offers (among other helpfull tools for Raspberry Pi) a great simple toolset for serial communication on the Raspberry Pi.

WiringPi - Serial Library

Gordon has all the documentation and Tutorials on his website you will need.

Thanks to Gordon! Mark