Mc protocol - how to use mc write node

good day,

I managed to use node-contrib-mcprotocol for fetching status & analog value. However, i cant send command @ write value using MC Write node. It keeps writing error 'the value must be between >= 0 and <= 0. How to solve this ?

Hi, could you post your flow please (only the relevant parts).

A screenshot of the error (and a copy of debug output would be good too)

Attached here the screenshot from command line

I found that my customer uses M114 (BOOL datatype) for this command from their HMI.

image

You are trying to write a string of true to a bit

change it to number and value 1

image

Still the same offset out of range error. Is my address definition correct in the node ? I'm not quiet understand the definition from the mc-write help notice

Add a catch node and debug nodes

image

ensure debug nodes are set to show full message

image

then copy any output from the debug window using the copy button

image

and paste any debug output in a reply

```
paste between backticks like this
```

Also, could you please export your MC Write node.

select the node, press CTRL+E, click "copy" then paste the flow in a reply
```
paste like this
```

mcWriteDetails: object
isGood: false
quality: 0
TAG: "Y30"
addr: "Y30"
timeTaken: 0
timeStamp: 1606276033084
problem: true
[{"id":"d54d6867.815788","type":"MC Write","z":"d6b1168b.3df54","name":"","topic":"","connection":"bce6340b.f635c8","data":"1","address":"Y30","addressType":"str","dataType":"num","errorHandling":"throw","outputs":1,"x":490,"y":100,"wires":[["85c23b34.9d16d8"]]},{"id":"adb82038.ff9dd","type":"MC Write","z":"d6b1168b.3df54","name":"","topic":"","connection":"bce6340b.f635c8","data":"1","address":"M125","addressType":"str","dataType":"num","errorHandling":"throw","outputs":1,"x":500,"y":220,"wires":[["9fca7a94.cf41d"]]},{"id":"bce6340b.f635c8","type":"MC Protocol Connection","name":"3403","host":"192.168.1.171","port":"2020","protocol":"TCP","frame":"3E","plcType":"Q","ascii":false,"PLCStation":"","PCStation":"","PLCModuleNo":"","network":"","octalInputOutput":false}]

You have not copied like i said

{"_msgid":"33f0801f.b2dd4","payload":false,"topic":"","mcWriteDetails":{"isGood":false,"quality":0,"TAG":"M116,1","addr":"M116,1","timeTaken":0,"timeStamp":1606345908216,"problem":true}}

that is a different address to the flow you posted.

So are you still getting the error "the value must be between >= 0 and <= 0"?

Are you able to read any values?

Also, what happens if you set address to M116,1 and the "data" dropdown to csv with a value of 1
image

Also, unless you Reply to me, I dont get a notification.

Also, you are not using backticks ``` to format your code - it is un-importable.

Still same problem. fortunately it works when i simulate using script from peopleplc/mcprotocol (not trying to compare :pray:)

Still same problem. fortunately it works when i simulate using script from peopleplc/mcprotocol (not trying to compare :pray:)

'''
[{"id":"adb82038.ff9dd","type":"MC Write","z":"d6b1168b.3df54","name":"","topic":"","connection":"bce6340b.f635c8","data":"1","address":"M118,1","addressType":"str","dataType":"csv","errorHandling":"throw","outputs":1,"x":500,"y":220,"wires":[["9fca7a94.cf41d"]]},{"id":"bce6340b.f635c8","type":"MC Protocol Connection","name":"3403","host":"192.168.1.171","port":"2020","protocol":"TCP","frame":"3E","plcType":"Q","ascii":false,"PLCStation":"","PCStation":"","PLCModuleNo":"","network":"","octalInputOutput":false}]
'''

could you answer questions?


NOTE...

I am not in a position to test this with a PLC right now.

Will take a look tomorrow if I get a chance.

'''
{"isGood":false,"quality":0,"TAG":"M118,1","addr":"M118,1","timeTaken":0,"timeStamp":1606346503368,"problem":true}
'''

@tunbendahara Please try the latest update now in flows library (V1.1.6 V1.1.7)

you can update via node-red manage pallete (but you will need to restart node-red afterwards)

You can set individual buts using bools true / false or ints 0 / 1

If you wish to set multiples bits you can send an array

Address Examples...

  • Write 4 bits
    • Address: M110,4
    • Value Type: csv
    • Value 0,1,0,1
  • Write 1 int16
    • Address: K4M110
    • Value Type: number
    • Value 12345
Address Example Data Type Notes
K4Y0 int16 −32,768 to 32,767
DSTR0,10 string Up to 10 chars long
DUINT0,10 UINT[10] 10 WD array containing values 0 to 65535
Y0 bit 0 / 1
RINT0,20 int16 Array of ints −32,768 to 32,767
D4800.0,16 bool array Array of 16 bools D4800.0 ~ D4800.F