Today is...
Sunday, June 24, 2018
Welcome to Control.com, the global online
community of automation professionals.
Featured Video...
Featured Video
A demonstration of EtherCAT control of linear motors using the CTC EtherCAT master.
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
Serial USB-RS45 Failing to Read on Raspberry Pi But Not on Ubuntu Laptop
Able to read values from batteries using RS485-USB from my linux laptop, but the same code is failing after a few reads on a raspberry pi.
By Peter Turner on 9 December, 2017 - 1:44 am

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)


# 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)

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

What model of the raspberry pi are you using?

1 out of 1 members thought this post was helpful...

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 https://www.youtube.com/watch?v=JZEXuZbwVbo.

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
dmesg | grep tty

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.