Closed alejoseb closed 6 years ago
Hi,alejoseb. I learned your code and changed the
Hi guys, can you send me an example how to implement it with fucntion 1? Tnx
Not sure what is your question, function codes are already implemented. You can use the examples of the library changing the function codes accordingly.
I find out the way to make it works. I need to read 512 coils using function 0x01 (ReadCoils) that has been implemented by that guy. But when i try to read more than 450 coils, it stop working :(
Dear Maurizio,
I suggest you to replace your 512 coils read with a 32-words (32 words x16 bits/word = 512 bits) read. This shall need function code 0x3. Indeed it is the same.
BR
-- SAMUEL MARCO i ARMENGOL Enginyer Industrial
2018-02-23 11:44 GMT+01:00 MaurizioAndaloro notifications@github.com:
I find out the way to make it works. I need to read 512 coils using function 0x01 (ReadCoils) that has been implemented by that guy. But when i try to read more than 450 coils, it stop working :(
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino/pull/27#issuecomment-367974916, or mute the thread https://github.com/notifications/unsubscribe-auth/AANq5Ql3wUnZvK9axKRZw_gdq-e-50Kyks5tXpamgaJpZM4PX55F .
I can't i need to use function 1. No problem, i'll find another library o will text it by my self. Thank you.
I think using either function codes 3 or 1 will not work for this library, because you need a buffer bigger than 64 bytes to hold a 512 coils message. Don't forget that you need slave ID, function code, start address, number of coils and CRC bytes. If you check library code the maximum buffer size supported is 64 bytes. I suggest to change this value carefully to accommodate the message that you need. In addition Arduino serial library requires changes to support it, check this site https://internetofhomethings.com/homethings/?p=927 Probably you will not find another library that supports such amount of data, unless it's implementation uses a different method to access USART. I have not tested this solution by myself, so it's up to you. In addition, consider that changing buffer size could affect other parts of the code.
I just implemented master functions codes 1, 2 and 15 and changed the length validation to 6 to accommodate functions 1 and 2