Omron NJ OPC UA write to the PLC not working

Hi all.
After trying everything , I get into a dead end.
I know there is some similar topics on this forum but I tried everything and so far no luck to get the OPCUA to write values into the plc.
I tried with the OCPUA item before the OCPUA Client , without OCPUA Item ...
I can READ values form the NJ PLC (I'm using UA Expert) with no problems.
Did anyone tried to do the same with a Omron NJ PLC?
Bellow some print screens showing what I have done so far.

FYI: I tried as well with the extension ns=4;s=NodeRed_Start,datatype:Boolean in the inject object but no difference at all .

Thanks in advance

I didnt have much success with writing via OPC to NJ PLC but I did with FINS using node-red-contrib-omron-fins

From the readme:

FINS works with PLC Addresses. NJ and NX PLCs do NOT have direct addresses to addresses like DM or E0_, E1_.

  • In order to use C Series addresses in an N Series PLC, you will need to create a variable in the PLC and set its AT property. E.G. If you want to read and write 40 WDs from E0_9000 ~ E0_9039 then you need to add a TAG like this TAG_NAME ARRAY[0..39] Of WORD %E0_9000 image

Thanks for your reply.
I think write values to the NJ doesn't work, and probably I have to try FINS.
Have you got smc sysmac file that you can share ?

Sorry, no (ex company property)

But really easy - just add global tags and assign AT addresses. Then read/write from FINS to those AT addresses.

To keep things simple and consistent, I strongly recommend you create 2 arrays of WORD (100 long) - something like "DATA_TO_NODE_RED" and "DATA_FROM_NODE_RED" and assign them to something like E0_1000 and E0_2000 - this gives you plenty scope for future additions. Also, since values will be read/written in contiguous blocks, the data is consistent (i.e. read+written on the same scan of the PLC)

To help with conversion of data types (bytes, strings, floats etc), there is the companion nodes in the node-red-contrib-buffer-parser package.

Hi Steve.
Thanks again for your reply.
Don't know for sure what I'm doing wrong but , still not working.
Please, can you look at the pictures bellow and give me some advise.

Sysmac settings for FINS

Node Red

Thanks again

Read the Omron nodes built in help. The fins address should not start with a %.

Also, why are you specifying an array of 40 bools? Fins works with 16bit words.

I recommend you set-up as I proposed earlier then you can share the whole address range with other tags in the PLC without having to modify the coms in the future

Hi Steve.
I manage to get it working.
Sorry for my lack of knowledge, I thought could work with array of bool .
I cant use as you said % before the address.
So far not to bad.
Thanks again Steve for your time.

1 Like

Hi Steve , just another question.
I have created and array of 40 positions of 16 bit Words.
I can see as well the values are coming into the plc in Hex format.
I would like to know if is possible to change the state of the 16 bits individually for example
Array[0]= 0000 0000 0000 0001 or 0000 0000 0000 0010 from red-node.
If not there is always the option to send an Hex value and use it on the plc.

Thanks again

No, FINS reads and writes in WORD values

Yes, use function node or JSONata in change node or the buffer-maker node to generate a WORD and write that.
BUT: Be mindful if you set a BIT in a WORD, all BITS will be written.

There are several options...

  1. it is safer to use 1 WORD per BIT
  2. Use status numbers (e.g. 1 = RUN, 2=STOP, 3=MANUAL MODE) etc
  3. Read WORD → set/reset BIT → WRITE WORD (see example below)


Demo Flow (use CTRL+I to import)

[{"id":"ca252362.2b25d","type":"inject","z":"d8bcc25e815f0bc3","name":"....... SET BIT 7 (0000 0000 1000 0000)","props":[{"p":"topic","vt":"str"},{"p":"bit","v":"7","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"SET","x":210,"y":840,"wires":[["5c3706dc0fedcf96"]]},{"id":"5c3706dc0fedcf96","type":"function","z":"d8bcc25e815f0bc3","name":"(FAKE) Read PLC D100","func":"msg.payload = flow.get(\"D100\") || 0\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":840,"wires":[["ab3d83e36d37d5af"]]},{"id":"ab3d83e36d37d5af","type":"function","z":"d8bcc25e815f0bc3","name":"Bit Operations","func":"\nconst ops = {\n    GET(num, bit) {\n        return ((num >> bit) % 2 != 0)\n    },\n    SET(num, bit) {\n        return num | 1 << bit;\n    },\n    RESET(num, bit) {\n        return num & ~(1 << bit);\n    },\n    TOGGLE(num, bit) {\n        return ops.GET(num, bit) ? ops.RESET(num, bit) : ops.SET(num, bit);\n    }\n}\n\nconst op = ops[msg.topic];\nif(!op) {\n    node.error(`Bad topic '${msg.topic}'. Expected one of \"GET\",\"SET\",\"RESET\" or \"TOGGLE\" `, msg);\n}\nmsg.payload = op(msg.payload, msg.bit)\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":740,"y":840,"wires":[["91eb7a105be43c2d"]]},{"id":"02cd37dadd749199","type":"inject","z":"d8bcc25e815f0bc3","name":".. RESET BIT 7 (0000 0000 1000 0000)","props":[{"p":"topic","vt":"str"},{"p":"bit","v":"7","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"RESET","x":210,"y":880,"wires":[["5c3706dc0fedcf96"]]},{"id":"e8b5505c20f9e30e","type":"inject","z":"d8bcc25e815f0bc3","name":"TOGGLE BIT 2 (0000 0000 0000 0100)","props":[{"p":"topic","vt":"str"},{"p":"bit","v":"2","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"TOGGLE","x":210,"y":800,"wires":[["5c3706dc0fedcf96"]]},{"id":"91eb7a105be43c2d","type":"function","z":"d8bcc25e815f0bc3","name":"(FAKE) Write PLC D100","func":"flow.set(\"D100\", msg.payload) \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":900,"wires":[["321cb40e7f7bfed4"]]},{"id":"321cb40e7f7bfed4","type":"debug","z":"d8bcc25e815f0bc3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":770,"y":900,"wires":[]}]