Modbus Serial Master v1.0 8-14-2006 Multiple Slaves


#1

I am using your sample code Modbus Serial Master v1.0 8-14-2006 successfully with a single slave. What is the proper way to add another slave. Do have to add another instance of the chart? Can you just increment the slave address in the existing chart?

Thanks,
Craig


#2

You can increment the address. However you many need to change other passed parameters. If the start register address is the same it would overwrite the last read.
Each block in the example calls the master subroutine one time. You can add another call of the subroutine with some of the parameters changed. You would use the same Com Handle in both and any other parameter that does not change.
You would use different data tables for each call.

It would look like this

MBMASTER READ HOLDING REGISTER
Slave Address nMB_Slave Address
Starting Address nMB_Holding_Register_Starting_Address
Qty H Register n03_Qty
Comm Mode nMB_Comm_Mode
Wait Time (s) fWait_Time
MB H Register 4X ftMB_Holding_Register_4X
Data Type nMB_Data_Type
Return Status sMB_03_status
Put status In nMB_Sub_Status

MBMASTER READ HOLDING REGISTER
Slave Address nMB_Slave2 Address
Starting Address nMB_Holding_Register_Starting_Address2
Qty H Register n03_Qty2
Comm Mode nMB_Comm_Mode
Wait Time (s) fWait_Time
MB H Register 4X ftMB_Holding_Register2_4X
Data Type nMB_Data_Type
Return Status sMB_03_status2
Put status In nMB_Sub_Status