mbuesch / pyprofibus

PROFIBUS-DP stack
https://bues.ch/a/profibus
GNU General Public License v2.0
134 stars 52 forks source link

connecting Pyprofibus with DP/PA coupler to communcate with PA devices (Invalid telegram format) #25

Closed Kaz040 closed 2 years ago

Kaz040 commented 2 years ago

Hello.

to start with, I am a novice in Profibus. I am working on a project to connected pyprofibus to DP/PA coupler so that i can communicate with some PA devices through it. I have been faced with some problem which I would really appreciate if i can get some help to start.

The main error i am getting now is PHY-serial: TX 10 10 01 49 5A 16 PHY-serial: RX (fragment) E7 A7 DA DPM1: RX error: PHY-serial: Failed to get received telegram size: Invalid telegram format.

I am using a raspberry pi as master and rs485 to rs232 transceiver and i configured my baudrate to be 45450 baud. That is the baud that DP/PA coupler support. I feel maybe my problem might be from the physical transceiver but then I saw that pyprofibus automatically reduce some devices baudrate down to 9600,19200.

anyhelp to debug this error would be appreciated.

Regards.

mbuesch commented 2 years ago

Hi. Thanks for your question.

The RX error probably points to a physical problem with the bus, or a baud rate mismatch.

If I remember correctly, then the Raspberry Pi serial can't physically do 45450 Baud. I would suggest to check the physical baud rate emitted by your Raspberry with an oscilloscope.

Can you reduce the coupler's baud rate to 19200?

Kaz040 commented 2 years ago

Hello,

Thank you for your swift reply. I really appreciate it. The pi suuports baudrate higher 45450, I have triend it with pyserial project before and it wokred fine. I think the problem might be from my transceiver. I read somewhere that raspberry pi serial supports only 3.3v but my transceiver is a TTL5v, maybe the pi is reading the data wrongly..... I am checking online on the right tranceiver to buy (for pi and for windows PC). Perhaps if you know of any or have usd any before, please i would be glad if you can suggest them to me.

The coupler only work 45450 baud as a coupler option. to add. I am interested in the acyclic task, that would be after I get my coulpler working and read the PA device cyclically.

Regards.

mbuesch commented 2 years ago

Yes, the Raspberry Pi supports baud rates higher than 45450. But it doesn't support 45450 exactly. That was at least the case last time I tested it a couple of years ago with a Pi 2. Things might have changed since, though.

Kaz040 commented 2 years ago

Thank you for this eye opener, I think you might be right on what you mentioned. I have tried to see if can get an oscilloscope to measure this signal baud but i cannot get any for now. seems my job for now is to be looking to find a way to work this with another device and also find an oscilloscope to read the rpi baud.

I will keep you posted once I get something.

Thank you so much for the response and tips.