ADS in - Change Var.Name

Hello,

I like to change the variable name during run mode.
If I understand the documentation right, there is a possibility

Quote of the documentation:

"There is an possible to override the node configuration. You can add an property config to the message object. Not all configuration properties need to be overridden.

*** config.varName : (string) override the variable name**

  • config.varType : (string) override the variable type
  • config.varSize : (integer) the length on RAW and STRING type
  • config.timezone : (string) only on date and time type 'TO_LOCAL' or 'UNCHANGED'
  • config.inProperty : (string) the property for the outvalue
  • config.useInputMsg : (bool) the input message will be used to build the out message or an new message will be build.
  • config.topic : (string) the topic being checked against the message topic. It can be '' to delete an topic."

So far I have this - but it is not working (the variable name is not changing):

[{"id":"35c5b282.47cf2e","type":"tab","label":"Übungen","disabled":false,"info":""},{"id":"2d687142.4e1c6e","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":890,"y":140,"wires":[]},{"id":"56f546c8.125f18","type":"ADS In","z":"35c5b282.47cf2e","name":"","datasource":"d6fbcc42.bcca8","varName":".RolloFunktionStatus_NodeRed[1]","varTyp":"INT","inValue":"payload","varSize":"","useInputMsg":false,"timezone":"UNCHANGED","topic":"","x":640,"y":140,"wires":[["2d687142.4e1c6e"]]},{"id":"beeedd8b.28c0c","type":"inject","z":"35c5b282.47cf2e","name":"","topic":"","payload":"config.varName:(.RolloFunktionStatus_NodeRed[3])","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":140,"wires":[["56f546c8.125f18","8dc752cc.2bb3f"]]},{"id":"8dc752cc.2bb3f","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":590,"y":220,"wires":[]},{"id":"d6fbcc42.bcca8","type":"ads-connection","z":"","host":"192.168.178.11","amsNetIdTarget":"5.36.137.117.1.1","amsNetIdSource":"192.168.178.47.1.1","port":"48898","amsPortSource":"32905","amsPortTarget":"801","adsTimeout":"500"}]

What is the syntax to program this.
Please a EASY answer, best with a example - I'm a complete newbie!!

Thanks in advance for your support!!

What node type are you using? node-red-contrib-something probably.

Hello,

I use the node "ADS In" from "node-red-contrib-ads 1.1.22" which is running on a Raspberry PI 3B.
The ADS-communication path is between node red on the PI and a Beckhoff CX9020 Controller which is running under Twincat 2.

You are feeding the string "config.varName:(.RolloFunktionStatus_NodeRed[3])" into the node. What you need to do is to feed the variable name, as a string, into the node by putting it in msg.config.varname. You can do that with a Change node.
Have a look at the node red doc page Working with Messages, that explains about messages and how to handle data within them.

Hello,

thanks for the input!
I read the mentioned document and watched the videos.
Than I try this:

[{"id":"35c5b282.47cf2e","type":"tab","label":"Übungen","disabled":false,"info":""},{"id":"2d687142.4e1c6e","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1160,"y":220,"wires":[]},{"id":"56f546c8.125f18","type":"ADS In","z":"35c5b282.47cf2e","name":"","datasource":"d6fbcc42.bcca8","varName":".RolloFunktionStatus_NodeRed[1]","varTyp":"INT","inValue":"payload","varSize":"","useInputMsg":false,"timezone":"UNCHANGED","topic":"","x":920,"y":140,"wires":[["2d687142.4e1c6e"]]},{"id":"beeedd8b.28c0c","type":"inject","z":"35c5b282.47cf2e","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":140,"wires":[["8dc752cc.2bb3f","3b94965f.b4e93a"]]},{"id":"8dc752cc.2bb3f","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":480,"y":220,"wires":[]},{"id":"3b94965f.b4e93a","type":"change","z":"35c5b282.47cf2e","name":"","rules":[{"t":"set","p":"config.varname","pt":"msg","to":".RolloFunktionStatus_NodeRed[3]","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":140,"wires":[["56f546c8.125f18","b3470884.8d9118"]]},{"id":"b3470884.8d9118","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"true","targetType":"full","x":800,"y":220,"wires":[]},{"id":"d6fbcc42.bcca8","type":"ads-connection","z":"","host":"192.168.178.11","amsNetIdTarget":"5.36.137.117.1.1","amsNetIdSource":"192.168.178.47.1.1","port":"48898","amsPortSource":"32905","amsPortTarget":"801","adsTimeout":"500"}]

Unfortunately without success.... :thinking:

The variable name is not changing - I still pull the ...[1] content oft the array and not the ...[3].

What is my fault?

I don't know anything about the twincat PLC, but .RolloFunktionStatus_NodeRed[3] sounds like a very odd variable name. If you configure it via the node configuration what would you put in for the variable name to get what you want?

Yes, if I put in the string .RolloFunktionStatus_NodeRed[3] direct into the node config. the result is valid.
It is variable out of a array. The number in the brackets describe the position inside the array.

Is the way I described in my last post the right way to override the given variable name?

Well it looks right to me, according to the readme. However, I wonder whether you have to provide the full config object rather than just one field. It might be worth trying that. Other than that, since no-one else has come to help, I guess maybe no-one here is using that node. I think the best thing may be to ask via an issue on the node's Github page.
If you do find the solution post it back here in case others find this thread.

Also, can I check that you have left the field empty in the config. Most nodes will give priority to the value in the config, though the readme does not say anything about that.

Unfortunately it doesn't help. I get an configuration error of the ADS-Node. If I go ahead with the config error the function is not working at all....
I try also a other ("easier") variable name - not a array variable - also without success. I make a general fault. I think I lack that crucial piece of knowledge how to inject the new variable name.

I think you will have to ask on the github page.

I already did this yesterday evening:

I hope that is the formal right location to enter such a question /problem. For me, it was the first time I ever did that.

Nevertheless, many thanks for your help!

1 Like

Now it works - thanks to all for your support. :slightly_smiling_face:

[{"id":"2d687142.4e1c6e","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1280,"y":200,"wires":[]},{"id":"56f546c8.125f18","type":"ADS In","z":"35c5b282.47cf2e","name":"","datasource":"d6fbcc42.bcca8","varName":".RolloFunktionStatus_NodeRed[1]","varTyp":"INT","inValue":"payload","varSize":"","useInputMsg":false,"timezone":"UNCHANGED","topic":"","x":1180,"y":140,"wires":[["2d687142.4e1c6e"]]},{"id":"beeedd8b.28c0c","type":"inject","z":"35c5b282.47cf2e","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":140,"wires":[["3b94965f.b4e93a"]]},{"id":"3b94965f.b4e93a","type":"change","z":"35c5b282.47cf2e","name":"","rules":[{"t":"set","p":"config.varName","pt":"msg","to":".RolloFunktionStatus_NodeRed[1]","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":140,"wires":[["56f546c8.125f18"]]},{"id":"4d41dd73.36dbe4","type":"inject","z":"35c5b282.47cf2e","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":180,"wires":[["6105b1af.87914"]]},{"id":"6105b1af.87914","type":"change","z":"35c5b282.47cf2e","name":"","rules":[{"t":"set","p":"config.varName","pt":"msg","to":".RolloFunktionStatus_NodeRed[2]","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":180,"wires":[["56f546c8.125f18"]]},{"id":"4a0870cd.4e0be","type":"inject","z":"35c5b282.47cf2e","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":220,"wires":[["3485e63f.dbdfaa"]]},{"id":"3485e63f.dbdfaa","type":"change","z":"35c5b282.47cf2e","name":"","rules":[{"t":"set","p":"config.varName","pt":"msg","to":".RolloFunktionStatus_NodeRed[3]","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":220,"wires":[["56f546c8.125f18"]]},{"id":"d6fbcc42.bcca8","type":"ads-connection","z":"","host":"192.168.178.11","amsNetIdTarget":"5.36.137.117.1.1","amsNetIdSource":"192.168.178.47.1.1","port":"48898","amsPortSource":"32905","amsPortTarget":"801","adsTimeout":"500"}]

my main fault was additional dot inside the change node after the msg :joy:

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