Luynmax243
please help me add modbus stm32 slave in openplc RUNTIME 
 
[203128%2F8752229%2Fmceclip0]
Reply 0 0
thiagoralves
First you need to upload an OpenPLC program to your STM32 with Modbus enabled so that you have a device that can respond to Modbus commands. You can use a generic Modbus library as well if you want, but then you will have to code everything yourself, so I always recommend uploading an OpenPLC program. Once you have your device working with Modbus (you can test it with Modbus tools like Radzio or Modbus Poll), then on the OpenPLC Runtime you can just add a Generic Modbus RTU device, filling out the parameters you set for you serial Modbus (slave ID, baud rate, etc). Finally you fill out the addresses for the available Modbus registers you have on the device. By default, OpenPLC firmware on microcontrollers (including STM32) creates 55 coils, 55 discrete inputs, 32 input registers and 32 holding registers (see https://autonomylogic.com/docs/2-5-modbus-addressing/ 😉. You don't have to use them all though. The first coils and registers are tied to physical GPIO pins according to the mapping at https://autonomylogic.com/docs/2-4-physical-addressing/
Reply 1 0
Luynmax243
Trước tiên, bạn cần tải chương trình OpenPLC lên STM32 có bật Modbus để bạn có một thiết bị có thể phản hồi các lệnh Modbus. Bạn cũng có thể sử dụng thư viện Modbus chung nếu muốn, nhưng sau đó bạn sẽ phải tự viết mã mọi thứ, vì vậy tôi luôn khuyên bạn nên tải lên chương trình OpenPLC. Sau khi thiết bị của bạn hoạt động với Modbus (bạn có thể kiểm tra thiết bị bằng các công cụ Modbus như Radzio hoặc Modbus Poll), thì trên OpenPLC Runtime, bạn có thể chỉ cần thêm thiết bị Generic Modbus RTU, điền vào các tham số bạn đặt cho Modbus nối tiếp (nô lệ) ID, tốc độ truyền, v.v.). Cuối cùng bạn điền địa chỉ cho các thanh ghi Modbus có sẵn trên thiết bị. Theo mặc định, chương trình cơ sở OpenPLC trên vi điều khiển (bao gồm STM32) tạo ra 55 cuộn dây, 55 đầu vào riêng biệt, 32 thanh ghi đầu vào và 32 thanh ghi giữ (xem https://autonomylogic.com/docs/2-5-modbus-addressing/  😉. Bạn không Tuy nhiên, không nhất thiết phải sử dụng tất cả chúng. Các cuộn dây và thanh ghi đầu tiên được gắn với các chân GPIO vật lý theo ánh xạ tại.  https://autonomylogic.com/docs/2-4-physical-addressing/
Thank you very much!!!
On openplc editor, I successfully submitted the code to stm32 by directly submitting it to Port_#0002.Hub_#0002 attached to STLINK V2 as shown, but in openplc runtime, the port attached to STLINK is not displayed so I cannot find it ( stlink = com 3)[203128%2F8753104%2Fmceclip0]
[203128%2F8753101%2Fmceclip0]
Reply 1 0
Reply