Arduino_Profibus_DP icon indicating copy to clipboard operation
Arduino_Profibus_DP copied to clipboard

some issue

Open feecat opened this issue 3 years ago • 5 comments
trafficstars

We wanted to do a replacement for an old profibus DP device and I found this repository which is easy transformer to ESP-IDF or PicoSDK. It does what I need successfully, Thanks a lot! I encountered two issues in use, as follows:

1, Line 689 need replace to profibus_send_CMD(SD2, DATA_LOW, 0, &uart_buffer[7], Output_Data_Size); // send data https://github.com/tuenhidiy/Arduino_Profibus_DP/blob/d4603382e719bc186f36b2f058f3578deac56685/Arduino_Profibus_DP.ino#L685-L689

2, Here just accept function code = 0x5D or 0x7D, but 0x6D also is a good function code. According https://www.felser.ch/profibus-manual/funktionscode.html, 0x6D is first frame with FCV. For our application, we don't have to strictly follow the protocol, we just need to add 0x6D to the if then it works well.

https://github.com/tuenhidiy/Arduino_Profibus_DP/blob/d4603382e719bc186f36b2f058f3578deac56685/Arduino_Profibus_DP.ino#L662-L664

cheers

feecat avatar Oct 28 '22 05:10 feecat

thank you @feecat . I'm trying this code on s7400 plc and uno. But doesn't work as expected. If there are any modifications other then the above mentioned in the arduino code, please provide it, also whether gsd file is ok or any modifications required?

whatdtech avatar Aug 17 '24 08:08 whatdtech

hi @whatdtech , In my project it works fine. maybe you need a logic analyze for rs485 communication, also you need read mostly important documents on https://www.felser.ch/profibus-manual/telegrammformate.html

feecat avatar Aug 18 '24 11:08 feecat

@feecat Worked fine for me with uno but I'm trying to adapt the code for esp32 and Arduino framework.

whatdtech avatar Sep 03 '24 04:09 whatdtech

@whatdtech The uart response speed of esp32 is slower than stm32/ch32v. But esp32 is dual-core. In my code, I had isolate one core to do UART communication, Otherwise, UART communication will be affected by FreeRTOS scheduling. profibus_RX() will be your data process loop. You need more work to do real-time response not profibus communication, Anyway its little diffcult. Im suggest to use stm32 and stm32cubeide, cuz arduino framework is too slow when compile.

And if you really want to use esp32, i cannot provide code but a little tips:

  1. Use esp-idf with vscode
  2. xTaskCreatePinnedToCore() pinned uart loop to core 1
  3. use portMUX_INITIALIZER_UNLOCKED spinlock to disable rtos scheduling in core 1, enter critical and never release it.
  4. check rx logic level to check if frame finish, cuz in 1.5MHz uart need quicklly response.
  5. read frame use UART.fifo.rw_byte by 1 byte, write frame use uart_ll_write_txfifo() and check status.st_utx_out.

feecat avatar Sep 03 '24 05:09 feecat

thank you @feecat . any example of yours with stm32?

whatdtech avatar Sep 05 '24 02:09 whatdtech