Serial USB-RS45 Failing to Read on Raspberry Pi But Not on Ubuntu Laptop

P

Thread Starter

Peter Turner

I am trying to read values from a Battery Management System. There are two banks of batteries, and I am using two RS485-USB (ftdi) boards in order to do this.

I am using python and the minimal modbus library, (example code below)<pre>
# Bank A
instrument_A = minimalmodbus.Instrument('/dev/ttyUSB0', 1)
# Bank B
instrument_B = minimalmodbus.Instrument('/dev/ttyUSB1', 1)
// Read something from BMS
socA = instrument_A.read_register(40008)</pre>
This code works fine on my Ubuntu laptop, but fails after only a few reads on the raspberry pi.

I am using a lot of serial ports at once on the pi, could it be that the pi just isn't up to it?

Power issue?

Would appreciate some enlightenment if anyone sees this and feels they may know whats happening here.

Thanks
 
The Raspberry Pi is absolutely "man-enough" for this task. In the past I used Sun SPARC workstations to host my SCADA system and ported all that code to the Raspberry Pi; a fully running SCADA application with multiple links running multiple calculation lists, historical logging, alarm and events etc take less than 10% CPU load on a RPI 3. The data acquisition links themselves were a bottleneck until I cranked them up to 115,200 b/s. I then did a comparison to show why the Pi has no trouble running an industrial SCADA application; I even have it running on the Pi Zero and the original Model B. Have a look at www.linklaser.com to see the comparison. There there are also links to Youtube showing how to get Modbus working - here is a direct link to one of those video's
.

As I point out in the video you have to get everything correct to get things working,so assuming you have rechecked everything, speed parity, terminating resistors etc etc the most likely problem is software (timing etc) and python is not good for that. The FTDI chip is also a good choice so it won't be that. Have you tried opening a console and running
<b>dmesg | grep tty</b>

after the link fails to make sure the FTDI is still recognized properly, and there are no possible conflicts?

It could be a power supply problem. I have found that with four USB ports used on a Raspberry Pi 3 you really need a good supply of at least 2.5 A.
 
Top