News:

  • May 05, 2026, 08:21:03 AM

Login with username, password and session length

Author Topic: Modbus function 5 with multiple bits  (Read 10207 times)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Modbus function 5 with multiple bits
« 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)
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 702
  • Hmmm...
    • Host Engineering, Inc.
Re: Modbus function 5 with multiple bits
« Reply #1 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
There are two types of people in the world; those that can extrapolate from incomplete data sets.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: Modbus function 5 with multiple bits
« Reply #2 on: May 29, 2013, 05:06:17 PM »
Sorry -- it's what I do!  It's just the way God made me!   :-\

Thanks!
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: Modbus function 5 with multiple bits
« Reply #3 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

« Last Edit: May 29, 2013, 11:26:36 PM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: Modbus function 5 with multiple bits
« Reply #4 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'. ;)
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO