Any MODBUS-RTU Libraries ? for Model Base Design

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Any MODBUS-RTU Libraries ? for Model Base Design

1,821 Views
Narudol-T
Contributor III

Hi Guy,

 

I am working on S32K1xx series to communicate with some sensors via RS485 (LPUART).

Ex. Read Coils, Write Coil, etc.

I am just hoping there should be any public library for such MATLAB Function to start with.

Please help share us start line for this Simulink integration.

 

Thank you in advance,

Narudol T.

Tags (1)
0 Kudos
3 Replies

1,810 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @Narudol-T ,

Unfortunately, we do not support Modbus in our MBDT for S32K144 and right now I don't know any C library to recommend to you. Of course, if you find one, we can discuss the implementation using custom code insertion as we did on the BMS.

Just in small lines, you can keep the UART config block for UART peripheral/pins and clock initialization and the rest of the calls might be done over custom code and uart interrupts.

Best Regards,

Marius

0 Kudos

1,795 Views
Narudol-T
Contributor III

Hi Marius,

 

Sorry again, after your suggestion, I am trying to implement the way you suggest as attached.

Am I doing wrong with this code ? ( Add modbus_config.h for config driver and call lpuart_driver.h)

 

And there is Modbus_Master_Millis(void) function which call "HAL_get_tick".

Should NXP have any this tick function as well to replace ?

 

 

Thank you,

Narudol T.

 

0 Kudos

1,803 Views
Narudol-T
Contributor III

Hi Marius

 

Thank you, last time with your support now our Kalman SoC state Estimator is success.

Even it is little bit slow, because the current sensor is at 10ms looping.

But I am doing fine tune software later.

 

Regarding this topic, I also saw the same suggested ways of implementation from your code.

(Initialization by Simulink and call LPSPI function from lpspi_driver C header.)

I even try to implement same way but not working in Real-Time Clock module via I2C module and calling LPI2C header which hide inside MBDT.

Anyway, The system was comply sucessfully but nothing working. 

So I adapt to code to be call just direct byte write and read from hardware adress directly and work now.

 

 

In this case of UART MODBUS, we use this to read LEL explosive sensor from commericial product via coil read.

I get the attached file from github and try to implement but it is too complex.

Frankly speaking, I am still learning the logic behind the MODBUS protocol yet. 

I think if we implement the same way as BCC; there is the HAL_UART_Receive function which should be replaced by the lpuart C header function.

 

Question.


1. What function should I initilaze in Simulink ?

2. What header should I call in this case  (lpuart_driver.h.. lpuart_hw_access.h...)? 

 

 

Thank you in advance for your kind support.

Narudol T.

0 Kudos