Help writing 16-bit data via Modbus to a VFD

This post is sort of the reverse of this solved problem, where I was reading the 16-bit Modbus data from a VFD.

I have an Allen Bradley PowerFlex 525 VFD all configured via RS485 Modbus. I can read the data no problem thanks to the above linked post. For writing the data, here are the 16 bits that the VFD can accept:

I am pretty lost when it comes to this. I am thinking something like this, whereby I send some decimal respresentations of the Modbus data and use the Buffer-Maker node to convert it before sending to the Modbus-Flex-Write node?

[{"id":"e9a2d5a0998cb28c","type":"function","z":"46e0ed13d406fbe2","name":"Inputs to Modbus write","func":"msg.payload = {\n    value: msg.payload,\n    'fc': 6,\n    'unitid': 100,\n    'address': 8192,\n    'quantity': 1\n}\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":440,"wires":[["b3034fb7124579d1","5a94ef56a873588e"]]},{"id":"5a94ef56a873588e","type":"modbus-flex-write","z":"46e0ed13d406fbe2","name":"","showStatusActivities":false,"showErrors":false,"server":"a536fdaba00fed1f","emptyMsgOnFail":false,"keepMsgProperties":false,"x":870,"y":440,"wires":[["8f5e78ef1fe33f7f"],[]]},{"id":"8f5e78ef1fe33f7f","type":"debug","z":"46e0ed13d406fbe2","name":"debug 41","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1080,"y":440,"wires":[]},{"id":"b3034fb7124579d1","type":"debug","z":"46e0ed13d406fbe2","name":"debug 42","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":820,"y":500,"wires":[]},{"id":"893f132894a4cb0c","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"271","payloadType":"num","x":110,"y":400,"wires":[["dbbdc269b30e701e"]]},{"id":"120dbdcad61a8d06","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"303","payloadType":"num","x":110,"y":480,"wires":[["dbbdc269b30e701e"]]},{"id":"dbbdc269b30e701e","type":"buffer-maker","z":"46e0ed13d406fbe2","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint16be","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":310,"y":440,"wires":[["e9a2d5a0998cb28c"]]},{"id":"fb8cdd993928a92a","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"18","payloadType":"num","x":105,"y":440,"wires":[["dbbdc269b30e701e"]]},{"id":"a536fdaba00fed1f","type":"modbus-client","name":"","clienttype":"serial","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"failureLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"1000","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"","commandDelay":"2000","clientTimeout":"3000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":false}]

To start with, all I want to send is START and FORWARD, so I presume (per the above table):
Bit 0: 0 (not stop)
Bit 1: 1 (start)
Bit 2: 0 (no jog)
Bit 3: 1 (clear faults)
Bits 4 & 5: 01 (forward command)
Bits 6 & 6: both 0
Bits 9, 8 and 11, 10: both 00
Bits 14, 13, 12: 000
Bit 15: 0

FYI, I am planning to send the command frequency setpoint (e.g. 40 Hz, or 4000) via a separate Modbus command which I believe should work (it's just a simple Function Cod 06 writing to register 8193)

Then you can simply set the value to 1 for stop or 2 for start.

in essance, that is

bit hex binary decimal
0 0x0001 0000 0000 0000 0001 1
1 0x0002 0000 0000 0000 0010 2

The difficulty comes when you need to track actual value and set/clear bits before writing.

The 2nd difficulty is when you need to set multiple bits.

I recommend you make a helper function using this code - probably a good candidate for a link-call or subflow.

Thank you, but am I even on the right track here regarding how to write the Modbus data? I have only read Modbus data in the past, so this is entirely new to me (plus I am kinda lost in the terminology...is address 8192 a register or a coil?).

Modbus-Flex-Write

Modbus TCP flexible input triggered write node with connection input parameters.

Connects to a Modbus TCP or serial to write coils/registers on each incoming msg.

Function codes currently supported include:

  • FC 5: Force Single Coil
  • FC 6: Preset Single Register
  • FC 15: Force Multiple Coils
  • FC 16: Preset Multiple Registers

Input parameter for connecting Modbus

  • unitid (0..255 tcp | 0..247 serial) - overrides default Unit-ID
  • fc (5|6|15|16)
  • start address (0:65535)
  • quantity (1:65535) of coils/inputs/registers to be written from the start address

For FC 5, msg.payload must be a value of 1 or 0 or true or false. For FC 6, msg.payload must be a single value between 0:65535. For FC 16, msg.payload must be an array of comma separated values between 0:65535 each.

Since writing these values will be infrequent, I would setup individual flows and use the basic write node instead of the flex node.

According to your screenshot it would be FC06 AKA Preset Single Register.

Unfortunately, due to dev work, I have no modbus stuff around but I am certain if you select the correct write node, you can trigger it by a wire input and can enter the register number 8193 and msg.payload should be your decimal number equivalent of the bits you want to set. e.g. 1 - trigger STOP, 2 - trigger START, 0 - CLEAR ALL.

OK, had a chance to try this simplified approach, but am getting nothing.

I am simply injecting 1, 2 or 3 into the Modbus Write node. Flow is here:

[{"id":"46e0ed13d406fbe2","type":"tab","label":"Modbus data from VFD","disabled":false,"info":"","env":[]},{"id":"832f6fbf4698bebc","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":140,"wires":[["e1bbbca292e8ef2e"]]},{"id":"e1bbbca292e8ef2e","type":"function","z":"46e0ed13d406fbe2","name":"Inputs to Modbus call","func":"msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 100,\n    'address': 8448,\n    'quantity': 5\n}\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":140,"wires":[["cbc7d5e06979c4f8"]]},{"id":"cbc7d5e06979c4f8","type":"modbus-flex-getter","z":"46e0ed13d406fbe2","name":"","showStatusActivities":false,"showErrors":true,"logIOActivities":false,"server":"a536fdaba00fed1f","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":570,"y":140,"wires":[["7ffc538a510b2e77","c5a4bd89b814463c"],[]]},{"id":"7e0ee4facfa865c3","type":"influxdb out","z":"46e0ed13d406fbe2","influxdb":"8c4a32ceeeedeb64","name":"","measurement":"SingleRotaryFurnaceElementData","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"heattreat","bucket":"AMPdata","x":1280,"y":240,"wires":[]},{"id":"801560f82d87ee4b","type":"function","z":"46e0ed13d406fbe2","name":"function 1","func":"msg.payload = [\n    [{\n        Direction: msg.payload.status.RotatingForward\n    },\n    {\n        MeasType: \"actual\",\n        EquipElement: \"retort\",\n        EquipNumber: \"6\"\n    }],\n    [{\n        RotationalSpeed: msg.responseBuffer.data[2]/100\n    },\n    {\n        MeasType: \"actual\",\n        EquipElement: \"retort\",\n        EquipNumber: \"6\"\n    }]\n];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":760,"wires":[["4e66fc10637f1b09"]]},{"id":"4e66fc10637f1b09","type":"debug","z":"46e0ed13d406fbe2","name":"debug 33","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":760,"wires":[]},{"id":"10054256c158b696","type":"debug","z":"46e0ed13d406fbe2","name":"debug 34","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":300,"y":800,"wires":[]},{"id":"45f33ae7bda1e04a","type":"function","z":"46e0ed13d406fbe2","name":"function 2","func":"msg.payload = [\n    [{\n        Direction: msg.payload.status.RotatingForward\n    },\n    {\n        MeasType: \"actual\",\n        EquipElement: \"retort\",\n        EquipNumber: \"8\"\n    }],\n    [{\n        DriveErrorCode: msg.responseBuffer.data[1]\n    },\n    {\n        EquipElement: \"retort\",\n        EquipNumber: \"8\"\n    }],\n    [{\n        RotationalSpeed: msg.responseBuffer.data[2] / 100\n    },\n        {\n            MeasType: \"setpoint\",\n            EquipElement: \"retort\",\n            EquipNumber: \"8\"\n    }],\n    [{\n        RotationalSpeed: msg.responseBuffer.data[3]/100\n    },\n    {\n        MeasType: \"actual\",\n        EquipElement: \"retort\",\n        EquipNumber: \"8\"\n    }],\n    [{\n        ElectricalCurrent: msg.responseBuffer.data[4]/100\n    },\n    {\n        MeasType: \"actual\",\n        EquipElement: \"retort\",\n        EquipNumber: \"8\"\n    }]\n];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":180,"wires":[["c7bb78791985c320","7e0ee4facfa865c3"]]},{"id":"c7bb78791985c320","type":"debug","z":"46e0ed13d406fbe2","name":"debug 36","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1260,"y":180,"wires":[]},{"id":"764ba16d3eebf71a","type":"comment","z":"46e0ed13d406fbe2","name":"Simplified version of above.  Connect to 2nd output of Modbus Flex Getter.  Did not correctly populate InfluxDB.","info":"","x":390,"y":720,"wires":[]},{"id":"0ea7ca6416775103","type":"debug","z":"46e0ed13d406fbe2","name":"debug 37","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1020,"y":140,"wires":[]},{"id":"c5a4bd89b814463c","type":"debug","z":"46e0ed13d406fbe2","name":"debug 38","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":100,"wires":[]},{"id":"a67e0552b9b6be99","type":"modbus-read","z":"46e0ed13d406fbe2","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"100","dataType":"HoldingRegister","adr":"027","quantity":"1","rate":"2","rateUnit":"m","delayOnStart":false,"startDelayTime":"","server":"a536fdaba00fed1f","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":130,"y":300,"wires":[["940db86e03b2bcee"],[]]},{"id":"940db86e03b2bcee","type":"function","z":"46e0ed13d406fbe2","name":"function 3","func":"msg.payload = [\n    [{\n        temperature: (msg.payload[0]) * (9 / 5) + 32,\n    },\n    {\n        MeasType: \"actual\",\n        EquipNumber: \"8\",\n        EquipZone: \"VFD_Retort\"\n    }]\n];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":300,"wires":[["0f407e0b3e2a229e","4a0344d68a1b81ab"]]},{"id":"0f407e0b3e2a229e","type":"influxdb out","z":"46e0ed13d406fbe2","influxdb":"8c4a32ceeeedeb64","name":"","measurement":"SingleRotaryFurnaceZoneData","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"heattreat","bucket":"AMPdata","x":650,"y":280,"wires":[]},{"id":"46a6bf73e5929b4a","type":"comment","z":"46e0ed13d406fbe2","name":"Temperature of VFD","info":"","x":110,"y":260,"wires":[]},{"id":"0689a93ef20be34d","type":"comment","z":"46e0ed13d406fbe2","name":"Status, Direction, Speed, Current & Error Code of VFD","info":"","x":220,"y":80,"wires":[]},{"id":"7ffc538a510b2e77","type":"buffer-maker","z":"46e0ed13d406fbe2","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint16be","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":810,"y":140,"wires":[["ba25e56ebb34c869"]]},{"id":"ba25e56ebb34c869","type":"buffer-parser","z":"46e0ed13d406fbe2","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"decimal","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"16bitbe","name":"binary","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bool","name":"status=>ReadyToRun","offset":1,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bool","name":"status=>ActiveRunning","offset":1,"length":1,"offsetbit":1,"scale":"1","mask":""},{"type":"bool","name":"status=>Forward","offset":1,"length":1,"offsetbit":2,"scale":"1","mask":""},{"type":"bool","name":"status=>RotatingForward","offset":1,"length":1,"offsetbit":3,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":850,"y":180,"wires":[["45f33ae7bda1e04a","0ea7ca6416775103"]]},{"id":"90f17c949723088c","type":"buffer-parser","z":"46e0ed13d406fbe2","name":"","data":"payload.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"decimal","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"16bitbe","name":"binary","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bool","name":"status=>ReadyToRun","offset":1,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bool","name":"status=>ActiveRunning","offset":1,"length":1,"offsetbit":1,"scale":"1","mask":""},{"type":"bool","name":"status=>Forward","offset":1,"length":1,"offsetbit":2,"scale":"1","mask":""},{"type":"bool","name":"status=>RotatingForward","offset":1,"length":1,"offsetbit":3,"scale":"1","mask":""},{"type":"bool","name":"status=>Accelerating","offset":1,"length":1,"offsetbit":4,"scale":"1","mask":""},{"type":"bool","name":"status=>Decelerating","offset":1,"length":1,"offsetbit":5,"scale":"1","mask":""},{"type":"bool","name":"status=>Faulted","offset":1,"length":1,"offsetbit":7,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":130,"y":760,"wires":[["801560f82d87ee4b","10054256c158b696"]]},{"id":"4a0344d68a1b81ab","type":"debug","z":"46e0ed13d406fbe2","name":"VFD_Retort temperature","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":320,"wires":[]},{"id":"66421659a93696c3","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"45","payloadType":"num","x":90,"y":640,"wires":[["7ea908580c5fc135"]]},{"id":"7ea908580c5fc135","type":"function","z":"46e0ed13d406fbe2","name":"Inputs to Modbus write","func":"msg.payload = {\n    value: msg.payload,\n    'fc': 6,\n    'unitid': 100,\n    'address': 8193,\n    'quantity': 1\n}\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":640,"wires":[["9155d76c484df144","e2a3d9b1b1b0dba6"]]},{"id":"e2a3d9b1b1b0dba6","type":"modbus-flex-write","z":"46e0ed13d406fbe2","name":"","showStatusActivities":false,"showErrors":false,"server":"a536fdaba00fed1f","emptyMsgOnFail":false,"keepMsgProperties":false,"x":570,"y":640,"wires":[["889d5b5ad65e7e99"],[]]},{"id":"889d5b5ad65e7e99","type":"debug","z":"46e0ed13d406fbe2","name":"debug 39","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":820,"y":640,"wires":[]},{"id":"9155d76c484df144","type":"debug","z":"46e0ed13d406fbe2","name":"debug 40","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":680,"wires":[]},{"id":"e9a2d5a0998cb28c","type":"function","z":"46e0ed13d406fbe2","name":"Inputs to Modbus write","func":"msg.payload = {\n    value: msg.payload,\n    'fc': 6,\n    'unitid': 100,\n    'address': 8192,\n    'quantity': 1\n}\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":460,"wires":[["b3034fb7124579d1","5a94ef56a873588e"]]},{"id":"5a94ef56a873588e","type":"modbus-flex-write","z":"46e0ed13d406fbe2","name":"","showStatusActivities":false,"showErrors":false,"server":"a536fdaba00fed1f","emptyMsgOnFail":false,"keepMsgProperties":false,"x":870,"y":460,"wires":[["8f5e78ef1fe33f7f"],[]]},{"id":"8f5e78ef1fe33f7f","type":"debug","z":"46e0ed13d406fbe2","name":"debug 41","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1080,"y":460,"wires":[]},{"id":"b3034fb7124579d1","type":"debug","z":"46e0ed13d406fbe2","name":"debug 42","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":820,"y":520,"wires":[]},{"id":"58ac966d042d3316","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"271","payloadType":"num","x":310,"y":900,"wires":[["08987b674403c309"]]},{"id":"6136282e5f1afdf4","type":"debug","z":"46e0ed13d406fbe2","name":"debug 23","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":900,"y":940,"wires":[]},{"id":"526f4c0ba1b974ae","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"303","payloadType":"num","x":310,"y":980,"wires":[["08987b674403c309"]]},{"id":"46162558616eca58","type":"debug","z":"46e0ed13d406fbe2","name":"debug 24","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":680,"y":900,"wires":[]},{"id":"d331af2c32f60b2a","type":"buffer-parser","z":"46e0ed13d406fbe2","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"decimal","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"16bitbe","name":"binary","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":710,"y":940,"wires":[["6136282e5f1afdf4"]]},{"id":"08987b674403c309","type":"buffer-maker","z":"46e0ed13d406fbe2","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint16be","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":510,"y":940,"wires":[["d331af2c32f60b2a","46162558616eca58"]]},{"id":"70b9003bdde44375","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"18","payloadType":"num","x":305,"y":940,"wires":[["08987b674403c309"]]},{"id":"893f132894a4cb0c","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"271","payloadType":"num","x":110,"y":420,"wires":[["dbbdc269b30e701e"]]},{"id":"120dbdcad61a8d06","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"303","payloadType":"num","x":110,"y":500,"wires":[["dbbdc269b30e701e"]]},{"id":"dbbdc269b30e701e","type":"buffer-maker","z":"46e0ed13d406fbe2","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint16be","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":310,"y":460,"wires":[["e9a2d5a0998cb28c"]]},{"id":"fb8cdd993928a92a","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"18","payloadType":"num","x":105,"y":460,"wires":[["dbbdc269b30e701e"]]},{"id":"9ffe8a5c7048ff86","type":"modbus-write","z":"46e0ed13d406fbe2","name":"","showStatusActivities":false,"showErrors":false,"unitid":"100","dataType":"HoldingRegister","adr":"8192","quantity":"1","server":"a536fdaba00fed1f","emptyMsgOnFail":false,"keepMsgProperties":false,"x":620,"y":400,"wires":[["421d39533ba91a3d"],[]]},{"id":"5a790bfcb3e290b6","type":"inject","z":"46e0ed13d406fbe2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":430,"y":400,"wires":[["9ffe8a5c7048ff86"]]},{"id":"421d39533ba91a3d","type":"debug","z":"46e0ed13d406fbe2","name":"debug 43","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":860,"y":400,"wires":[]},{"id":"a536fdaba00fed1f","type":"modbus-client","name":"","clienttype":"serial","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"failureLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"1000","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"","commandDelay":"2000","clientTimeout":"3000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":false},{"id":"8c4a32ceeeedeb64","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"database","name":"","usetls":false,"tls":"","influxdbVersion":"2.0","url":"http://192.168.10.25:8086","rejectUnauthorized":true}]

image

In all cases (injecting 1, 2 or 3), nothing changes on the VFD.

PS: I see you used register 8193 on your reply above, but am pretty sure you meant 8192. In any event, I tried both registers and no change.

At the very least writing a 1 as the payload to 8192 should stop the VFD if it's running but commanding it to start might require some other information. Maybe??

for example, commanding 000000000000010 (2) start might not do anything without a direction, therefore 000000000010010 (18) start + forward would be required

Might be a good idea to confirm you are still able to read data right before you try to write as a way to eliminate any possible communication issues. You might already be doing that though.

I don't really have much to contribute as help, just going to follow along to learn.

Thanks for the suggestions, but just to back up a second...

Am I injecting this...
image

or this?
image

I tried both and neither does anything.

I am going to try to hook up a test VFD offline where I can experiment more with this. I have to believe I am missing something very fundamental. I just assumed it would be like the Read (03) command, but change the 03 to 06 (Write), but I think there are some additional things that need to be addressed.

How was the unit-ID assigned? Was that done with a modbus write?

The unit-ID of 100 is what the VFD was configured with by me (parameter C124, aka RS485 Node Address). I am sure it works because I have done Modbus Read commands for over a year collecting speed, direction, current draw, etc.

In the Modbus Write node, I was specifying unit-ID to be 100.

Oh I didn't doubt it worked. I just thought if you did some writing to it already to get the ID set then there is at least proof of concept for the write node.

Hi @grant1,

I noticed you use the wrong syntax in your payload.
You try to send "0000000000010010" as a number. So you actually are sending 10010 instead of 18.
What you need to do is (if you want this notation) define it as a string and then use "parseInt" function using base 2.
msg.payload = parseInt(msg.payload,2);

I often split bitranked integers that I read from devices into arrays.
First thing is to add padding to the front of the bitstring and then slice only the last x bits you need.
Then split the string into an array and reverse the order to have the least significant bit as array index 0.

msg.payload = ('0'.repeat(16) + msg.payload.toString(2)).slice(-16).split('').reverse()

Also before doing any coding in node-red, it is best to just verify communication with "modbus-poll" software. This way you get some feedback and learn quickly if the device is 0 or 1 based.
And you can set the view to binary to toggle the correct bits.

Thanks @JeroenVH

I will follow your tips. Unfortunately, I had to park the project because the VFD which I was trying this on had to go into a production application. My plan was to use a spare unit (if we have one) and set it up on a test bench with Modbus.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.