Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Controls Guy on May 29, 2013, 04:40:36 PM

Title: Modbus function 5 with multiple bits
Post by: Controls Guy on May 29, 2013, 04:40:36 PM
I have a device that "supports Modbus", but to assert Modbus control over the device, your first Modbus query must be a write of 0xff00 to bit address 0x0427 using FC5 (single coil write)!

I tested the device using my MMI as a Modbus master and it will send an FC5 with a 16-bit value, but as far as I can see, MWX will not.  The device supposedly doesn't support FC15.

Can I use the same port in a free-form "user" mode and just send the precalced request down the wire, then switch the port to Modbus mode?  (H2-SERIO-4 RS485 port C)
Title: Re: Modbus function 5 with multiple bits
Post by: Greg on May 29, 2013, 05:02:38 PM
The syntax for the FC05 is:

Function Code: 05
Coil Address High Order: 04
Coil Address Low Order: 27
Force Data High Order: FF
Force Data Low Order: 00

In other words the function code itself sends a 16-bit value to turn a single coil ON or OFF. It sends 0xFF00 for ON and 0x0000 for OFF. So all you have to do is use the MWX in the normal way and just turn 0x0427 ON.

BobO says quit trying so hard!  ;D
Title: Re: Modbus function 5 with multiple bits
Post by: Controls Guy on May 29, 2013, 05:06:17 PM
Sorry -- it's what I do!  It's just the way God made me!   :-\

Thanks!
Title: Re: Modbus function 5 with multiple bits
Post by: Controls Guy on May 29, 2013, 05:16:56 PM
BTW -- OPENTCP/STREAMOUT/STREAMIN/CLOSE on another portion of the project -- VERY VERY cool!

The free-form protocol ability, usable over Ethernet, was a real home run for this application!

It will save my machine builder OEM customer lots of binary I/O on every unit (both wiring labor and unit I/O expansion card cost, PLUS more PLC I/O, which had to be 5V -- ugh!), AND may even allow them to buy a cheaper unit, because it thinks it's being operated by the mfgr's software from a PC if you control it using the Ethernet port.

Big, BIG kudos to Host and Hosties!   ;D

Title: Re: Modbus function 5 with multiple bits
Post by: BobO on May 29, 2013, 05:25:33 PM
Sorry -- it's what I do!  It's just the way God made me!   :-\

'Us' dude, 'us'. ;)