1

Problem

I have a Raspberry Pi A+ and I've heard that there's a serial on /dev/serial0, which is actually symlinked to /dev/ttyAMA0. What I would like to achieve is connect the beckhoff I/Os to the raspberry and read/write in/outputs using Python's MinimalModbus library. The HMI adapter's power led is green, but the activity led is not doing anything. Python just exits with an error: "No answer from device".

Things I posess

The Setup

schematic

simulate this circuit – Schematic created using CircuitLab

Sorry for the crappy schematic, I'm not an engineer. I know it's not proper to connect some of those wires together, but it's easier to explain it this way.

The code used is the example code on this page.

1

I am not totally sure your setup is right. The wiring seem odd to me, I have never used a Beckhoff BK3150 with 24V supply through the DB9 profibus connector. Is it to power up the HMI adapter?

If I don't get it wrong you want to read the status of the inputs/outputs of Beckhoff I/O system using a Raspberry Pi. Thus, the Raspberry PI must act as a master and the BK should act as slave. But, I am not sure the HMI-adapter can act as Profibus master and also not quite sure the adapter uses Modbus on it's RS232 interface.

Could you please confirm if the HMI adapter can be a Profibus master on the MPI/DP side and Modbus slave on the RS232 side? Also, Modbus and Profibus slaves must have an ID or address, which must be used to communicate with the devices. In case the HMI adapter uses an address, is it properly set?

Also, why do you use Profibus to do the data exchange? Beckhoff has more friendly ways to communicate with a Raspberry Pi. Using a Codesys for RaspberryPi runtime you can use the EtherCAT communication protocol (The license cost is about 40$). Also Modbus TCP is available and you don't need extra hardware or tricky configurations.

  • Thank you very much for your response! Sorry for not clarifying my question. Address is 1x1+10x1. And yes, the HMI adapter needs that loopback power. But... Wait a second... Modbus TCP? What should I do in order to connect the Pi and the beckhoff together like that? (I mean, I haven't seen an RJ45 on the beckhoff) Or is there another simple (and free) pythonic way to communicate with the beckhoff I/Os? The project is actually for a home control center with a bunch of relays being controlled by the Pi. If you have some links of tutorials, I would gladly read them :) – ForceMagic Jul 12 '17 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.