MODBUS Communications Driver - Functions
Starting Point No.
Integer < 1950
short status = MB_ForceMultipleCoils(short Address, long Start, short Count, short Values);
This command is the converse of the Read Output Status command. It writes new values onto "Count" consecutive coils (address 0xxxx) starting at the Starting Point Number (Start). Like the Read Output Status command, the Data array, which contains the new values for the coils, is "packed". This is, each 16-bit word in the Data array corresponds to 16 Output coils, beginning with the LSb of array element 0 and continuing upwards toward Bit 15.
ForceMultipleCoils: Write (Force) Multiple Coils
// Value array
bits = 0x27CD; bits = 127;
// Set up bit values
short status = MB ForceMultipleCoils(11, 144, 23, bits);
if (status != 0) MessageBox(NULL, MB ErrorString(status),
This sample will write a total of 23 coil values.
The least significant bit of bits will
determine the new value of Coil 144, Bit 1 of bits corresponds to Coil 145, and so on, through Bit 7 of bits, which corresponds to Coil 166.
June 6, 1998