LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus protocol implementation

Hi all

I have a question about modbus :

In my project, I have to use other function codes than the one defined by the standard modbus :

for example :

  • function code = 0x74 from the master => the slave must configure an acquisition
  • function code = 0x75 from the master => the slave must acquire analog inputs
  • function code = 0x77 from the master => the slave must send samples ...

I must never use standard function codes like 03, 06 ...

Has anyone done the same ?

Anyone has an idea ?

Thx

 

 

 

 

 

0 Kudos
Message 11 of 14
(1,004 Views)
What you will have to do is create your own higher level Modbus VI that uses those function codes.  You will need to know the format of the command for those codes.  You'll be able to use the lower level subVI's such as CRC calculations.  Take a look at the Modbus RW VI's.  Copy them and give them a new name.  You should be able to model your code after what they did and just make sure you add your function codes and any other bytes that need to be written according to the structure specified for those codes.
0 Kudos
Message 12 of 14
(997 Views)
Hi Ravens Fan and thanks for the answer
 
So that's what I thought, I must break the existing architecture of the modbus Labview VIs and adapt it to make it compatible with the new function codes, and the new frames.
 
 
0 Kudos
Message 13 of 14
(995 Views)
You're welcome.
 
Adding function codes will definitely dig down deeper into the code than I first thought.  I recommend starting with the MB Master Query VI and looking down through all the VI's and subVI's to understand what each does.  I think if you are careful, you could modify the code without actually breaking it too much.  It looks like the key factor for the function codes is the Typedef control for MB Modbus Data Unit.  (also possibly  MB Modbus Command.)  You could add the new function codes to that.  If you rename them, you will have to relink the controls all throughout the MB code to the new name.  If you just add new function codes to the typedef, you may not have to do as much relinking.  The risk is that you could break too much, it may be a lot of work fixing everything.  But you could always download the modbus library again.
 
With new function codes added to MB Modbus Data Unit, and always using the Use Modbus Data Unit when using the MB Master Query when you need to use those codes (because it gives direct raw access to each and every byte in the command), you'll be able to get this to work.
0 Kudos
Message 14 of 14
(990 Views)