Web HMI for CompactLogix PLC to manually command stepper motor

I just built a web HMI that connects to a CompactLogix AB PLC via EthernetIP to command a stepper motor. If the motor is alarmed, it sends me an email notifying the alarm code.

Hardware used:

  • Any Logix family Allen Bradley PLC with Ethernet/IP communication
  • Oriental motor AZD-KEP stepper motor driver
  • DC 24V PS to supply voltage to both PLC and stepper driver

Packages used:

  • node-red-contrib-ui-led
  • node-red-contrib-cip-ethernet-ip
  • node-red-dashboard
  • node-red-node-email

Code:

[{"id":"a60e62c7ae0220e4","type":"tab","label":"Motor test","disabled":false,"info":"","env":[]},{"id":"396048eaf0ebb339","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Dashboard_MotorSpeed","program":"","name":"","x":630,"y":420,"wires":[]},{"id":"0e2b0097fbcb83a5","type":"ui_numeric","z":"a60e62c7ae0220e4","name":"","label":"Motor speed","tooltip":"","group":"954e3ebf35b76646","order":9,"width":6,"height":1,"wrap":false,"passthru":true,"topic":"topic","topicType":"msg","format":"{{value}}","min":0,"max":"20000","step":"100","className":"","x":190,"y":420,"wires":[["396048eaf0ebb339"]]},{"id":"07b8910e5a4da8b1","type":"ui_led","z":"a60e62c7ae0220e4","order":1,"group":"954e3ebf35b76646","width":4,"height":1,"label":"Stepper connection","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"#ff0000","value":"false","valueType":"bool"},{"color":"#008000","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"circle","showGlow":true,"name":"Stepper connection","x":710,"y":80,"wires":[]},{"id":"381700072cda5a96","type":"eth-ip in","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","mode":"single","variable":"Stepper_ModuleConnectionGood","program":"","name":"","x":230,"y":80,"wires":[["07b8910e5a4da8b1"]]},{"id":"3013b5e157b525d1","type":"ui_numeric","z":"a60e62c7ae0220e4","name":"","label":"Operating current","tooltip":"","group":"954e3ebf35b76646","order":11,"width":6,"height":1,"wrap":false,"passthru":true,"topic":"topic","topicType":"msg","format":"%","min":0,"max":"100","step":"10","className":"","x":210,"y":500,"wires":[["ad559cf04819c1d1"]]},{"id":"eac96ed77a0ff768","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Dashboard_OperatingCurrent","program":"","name":"","x":650,"y":500,"wires":[]},{"id":"98efa139ac951587","type":"ui_numeric","z":"a60e62c7ae0220e4","name":"","label":"Operating position","tooltip":"","group":"954e3ebf35b76646","order":15,"width":6,"height":1,"wrap":false,"passthru":true,"topic":"topic","topicType":"msg","format":"mm","min":0,"max":"280","step":"10","className":"","x":210,"y":600,"wires":[["d79b7930d5978019"]]},{"id":"39653c53d7fed79d","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Dashboard_OperationPosition","program":"","name":"","x":650,"y":600,"wires":[]},{"id":"d7ebc8a11b4e557e","type":"ui_numeric","z":"a60e62c7ae0220e4","name":"","label":"Operation starting/changing rate","tooltip":"","group":"954e3ebf35b76646","order":13,"width":6,"height":1,"wrap":false,"passthru":true,"topic":"topic","topicType":"msg","format":"{{value}}","min":0,"max":"1000000","step":"100000","className":"","x":250,"y":700,"wires":[["a38ccb04b2a28db0"]]},{"id":"a38ccb04b2a28db0","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Dashboard_StartingChangingRate","program":"","name":"","x":660,"y":700,"wires":[]},{"id":"f47fb55dce3a42b1","type":"ui_numeric","z":"a60e62c7ae0220e4","name":"","label":"Operation stopping rate","tooltip":"","group":"954e3ebf35b76646","order":21,"width":6,"height":1,"wrap":false,"passthru":true,"topic":"topic","topicType":"msg","format":"{{value}}","min":0,"max":"1000000","step":"100000","className":"","x":230,"y":800,"wires":[["da3c9c5fdf9b40d2"]]},{"id":"da3c9c5fdf9b40d2","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Dashboard_StoppingDeceleration","program":"","name":"","x":660,"y":800,"wires":[]},{"id":"a7ef5cc36b1eaade","type":"eth-ip in","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","mode":"single","variable":"Stepper.In.RIO_READY","program":"","name":"","x":200,"y":160,"wires":[["5c4355712098ab65"]]},{"id":"8afcf753233ad1e1","type":"eth-ip in","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","mode":"single","variable":"Stepper.In.RIO_ALM_A","program":"","name":"","x":200,"y":240,"wires":[["fcb0270669e8add9"]]},{"id":"2e8ac318e6c9234b","type":"eth-ip in","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","mode":"single","variable":"Stepper.In.RIO_MOVE","program":"","name":"","x":200,"y":360,"wires":[["4b106c760a242c43"]]},{"id":"5c4355712098ab65","type":"ui_led","z":"a60e62c7ae0220e4","order":2,"group":"954e3ebf35b76646","width":4,"height":1,"label":"Stepper ready","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"#ff0000","value":"false","valueType":"bool"},{"color":"#008000","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"circle","showGlow":true,"name":"Stepper ready","x":700,"y":160,"wires":[]},{"id":"fcb0270669e8add9","type":"ui_led","z":"a60e62c7ae0220e4","order":5,"group":"954e3ebf35b76646","width":4,"height":1,"label":"Stepper alarmed","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"#ff0000","value":"true","valueType":"bool"},{"color":"#808080","value":"false","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"circle","showGlow":true,"name":"Stepper alarmed","x":710,"y":240,"wires":[]},{"id":"4b106c760a242c43","type":"ui_led","z":"a60e62c7ae0220e4","order":6,"group":"954e3ebf35b76646","width":4,"height":1,"label":"Stepper moving","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"#808080","value":"false","valueType":"bool"},{"color":"#008000","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"circle","showGlow":true,"name":"Stepper moving","x":700,"y":360,"wires":[]},{"id":"1b3c16fcfbe76953","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Stepper.Out.FW_JOG","program":"","name":"","x":620,"y":900,"wires":[]},{"id":"d354430211a1b724","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Stepper.Out.RV_JOG","program":"","name":"","x":620,"y":980,"wires":[]},{"id":"49fc6cd0774bd5e4","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Stepper.Out.TRIG","program":"","name":"","x":610,"y":1060,"wires":[]},{"id":"22ceceae0d625232","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Stepper.Out.STOP","program":"","name":"","x":610,"y":1140,"wires":[]},{"id":"64e5ab6a3ff8e4a3","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Stepper.Out.FREE","program":"","name":"","x":610,"y":1220,"wires":[]},{"id":"15e3b1d2c7628856","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Stepper.Out.ZHOME","program":"","name":"","x":620,"y":1300,"wires":[]},{"id":"445121e857da5326","type":"eth-ip out","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","variable":"Stepper.Out.ALM_RST","program":"","name":"","x":620,"y":1380,"wires":[]},{"id":"4329fa7a793ce4f1","type":"ui_switch","z":"a60e62c7ae0220e4","name":"","label":"Forward motor","tooltip":"","group":"954e3ebf35b76646","order":25,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":220,"y":900,"wires":[["1b3c16fcfbe76953"]]},{"id":"8674a1ed3abe83e4","type":"ui_switch","z":"a60e62c7ae0220e4","name":"","label":"Reverse motor","tooltip":"","group":"954e3ebf35b76646","order":26,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":220,"y":980,"wires":[["d354430211a1b724"]]},{"id":"356112e51c4be25c","type":"ui_switch","z":"a60e62c7ae0220e4","name":"","label":"Trigger position","tooltip":"","group":"954e3ebf35b76646","order":16,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":220,"y":1060,"wires":[["49fc6cd0774bd5e4"]]},{"id":"1d8aa55e51283b41","type":"ui_switch","z":"a60e62c7ae0220e4","name":"","label":"Stop motor","tooltip":"","group":"954e3ebf35b76646","order":28,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":210,"y":1140,"wires":[["22ceceae0d625232"]]},{"id":"fd76f14704252dfb","type":"ui_switch","z":"a60e62c7ae0220e4","name":"","label":"Free motor","tooltip":"","group":"954e3ebf35b76646","order":31,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":210,"y":1220,"wires":[["64e5ab6a3ff8e4a3"]]},{"id":"93667ae128e89fb4","type":"ui_switch","z":"a60e62c7ae0220e4","name":"","label":"ZHOME","tooltip":"","group":"954e3ebf35b76646","order":32,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":200,"y":1300,"wires":[["15e3b1d2c7628856"]]},{"id":"13c8b74d066f16f5","type":"ui_switch","z":"a60e62c7ae0220e4","name":"","label":"Reset alarm","tooltip":"","group":"954e3ebf35b76646","order":29,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":210,"y":1380,"wires":[["445121e857da5326"]]},{"id":"b39efc1f8a3860e1","type":"ui_gauge","z":"a60e62c7ae0220e4","name":"","group":"954e3ebf35b76646","order":4,"width":10,"height":6,"gtype":"gage","title":"Speed","label":"kHz","format":"{{value}}","min":0,"max":"20","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":810,"y":1500,"wires":[]},{"id":"48c4ae444ae5d61d","type":"eth-ip in","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","mode":"single","variable":"Stepper.In.Feedback_speed","program":"","name":"","x":260,"y":1500,"wires":[["75750beca3714f3d"]]},{"id":"75750beca3714f3d","type":"function","z":"a60e62c7ae0220e4","name":"function 1","func":"msg.payload = Math.abs(msg.payload/1000);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":1500,"wires":[["b39efc1f8a3860e1"]]},{"id":"33ad56a4b353a480","type":"eth-ip in","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","mode":"single","variable":"Stepper.In.CST_operating_current","program":"","name":"","x":280,"y":1580,"wires":[["46832d818eb50334"]]},{"id":"46832d818eb50334","type":"function","z":"a60e62c7ae0220e4","name":"function 2","func":"msg.payload = msg.payload/10\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":1580,"wires":[["bd7e0116c011a6c1"]]},{"id":"bd7e0116c011a6c1","type":"ui_gauge","z":"a60e62c7ae0220e4","name":"","group":"954e3ebf35b76646","order":23,"width":10,"height":6,"gtype":"gage","title":"Current","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":820,"y":1580,"wires":[]},{"id":"c193390c5995b50e","type":"function","z":"a60e62c7ae0220e4","name":"function 3","func":"msg.payload = Math.round(msg.payload/74.09)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":1660,"wires":[["7e9e7b2312d40717"]]},{"id":"f4b154b067f594b9","type":"eth-ip in","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","mode":"single","variable":"Stepper.In.Feedback_position","program":"","name":"","x":260,"y":1660,"wires":[["c193390c5995b50e"]]},{"id":"7e9e7b2312d40717","type":"ui_text","z":"a60e62c7ae0220e4","group":"954e3ebf35b76646","order":18,"width":5,"height":1,"name":"","label":"Feedack position","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":870,"y":1660,"wires":[]},{"id":"d2c742dda038ad70","type":"ui_text","z":"a60e62c7ae0220e4","group":"954e3ebf35b76646","order":19,"width":1,"height":1,"name":"","label":"mm","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":1050,"y":1660,"wires":[]},{"id":"d79b7930d5978019","type":"function","z":"a60e62c7ae0220e4","name":"function 4","func":"msg.payload = msg.payload * 74.09;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":600,"wires":[["39653c53d7fed79d"]]},{"id":"6ccf755c7e89fcfe","type":"e-mail","z":"a60e62c7ae0220e4","server":"smtp.gmail.com","port":"465","authtype":"BASIC","saslformat":true,"token":"oauth2Response.access_token","secure":true,"tls":false,"name":"","dname":"","credentials":{},"x":890,"y":300,"wires":[]},{"id":"a1b8599e3ee9233b","type":"function","z":"a60e62c7ae0220e4","name":"function 5","func":"var AlarmCode = msg.payload;\n\nmsg.to = 'esteban.torres.perez.1994@gmail.com';\nmsg.topic = 'Motor alarmed';\nmsg.payload = 'Motor alarm code: ' + msg.payload + '. Please look at https://catalog.orientalmotor.com/ and look for AZD-KEP item to see alarm codes.';\n\nif (AlarmCode > 0){\n    return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":300,"wires":[["6ccf755c7e89fcfe"]]},{"id":"2e8b7189d84fe26d","type":"eth-ip in","z":"a60e62c7ae0220e4","endpoint":"34e120684374a12b","mode":"single","variable":"Stepper.In.Present_alarm","program":"","name":"","x":210,"y":300,"wires":[["a1b8599e3ee9233b"]]},{"id":"ad559cf04819c1d1","type":"function","z":"a60e62c7ae0220e4","name":"function 6","func":"msg.payload = msg.payload * 10;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":500,"wires":[["eac96ed77a0ff768"]]},{"id":"db63e060d69a0282","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":3,"width":2,"height":1},{"id":"6d4f31cb924d3265","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":7,"width":2,"height":1},{"id":"4201352b2b949d58","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":8,"width":10,"height":1},{"id":"522d1369cbb9306e","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":10,"width":4,"height":1},{"id":"06c5f1a65b90b9db","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":12,"width":4,"height":1},{"id":"b09f711bfdc64478","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":14,"width":4,"height":1},{"id":"5eb0efc93549aab5","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":17,"width":2,"height":1},{"id":"ff393e509ecc95d2","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":20,"width":2,"height":1},{"id":"7391d70743fdea97","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":22,"width":4,"height":1},{"id":"9b86bfa63d189f3d","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":24,"width":10,"height":1},{"id":"7a21d57a31e44b23","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":27,"width":2,"height":1},{"id":"3cd52fc78fb1c86a","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":30,"width":2,"height":1},{"id":"a5200525ccd42c8e","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":33,"width":2,"height":1},{"id":"5db8357c331ede7e","type":"ui_spacer","z":"a60e62c7ae0220e4","name":"spacer","group":"954e3ebf35b76646","order":34,"width":10,"height":1},{"id":"34e120684374a12b","type":"eth-ip endpoint","address":"192.168.1.1","slot":"0","cycletime":"100","name":"","vartable":{"":{"Local:1:O.Data.0":{"type":"BOOL"},"Local:1:O.Data.1":{"type":"BOOL"},"Local:1:O.Data.2":{"type":"BOOL"},"Local:1:O.Data.3":{"type":"BOOL"},"Local:1:O.Data.4":{"type":"BOOL"},"Local:1:O.Data.5":{"type":"BOOL"},"Local:1:O.Data.6":{"type":"BOOL"},"Local:1:O.Data.7":{"type":"BOOL"},"Local:1:I.Data.0":{"type":"BOOL"},"Local:1:I.Data.1":{"type":"BOOL"},"Local:1:I.Data.2":{"type":"BOOL"},"Local:1:I.Data.3":{"type":"BOOL"},"Local:1:I.Data.4":{"type":"BOOL"},"Local:1:I.Data.5":{"type":"BOOL"},"Local:1:I.Data.6":{"type":"BOOL"},"Local:1:I.Data.7":{"type":"BOOL"},"Dashboard_MotorSpeed":{"type":"DINT"},"Stepper_ModuleConnectionGood":{"type":"BOOL"},"Dashboard_OperatingCurrent":{"type":"INT"},"Dashboard_OperationPosition":{"type":"DINT"},"Dashboard_StartingChangingRate":{"type":"DINT"},"Dashboard_StoppingDeceleration":{"type":"DINT"},"Stepper.Out.FW_JOG":{"type":"BOOL"},"Stepper.Out.RV_JOG":{"type":"BOOL"},"Stepper.Out.TRIG":{"type":"BOOL"},"Stepper.Out.STOP":{"type":"BOOL"},"Stepper.Out.FREE":{"type":"BOOL"},"Stepper.Out.ZHOME":{"type":"BOOL"},"Stepper.Out.ALM_RST":{"type":"BOOL"},"Stepper.In.RIO_READY":{"type":"BOOL"},"Stepper.In.RIO_ALM_A":{"type":"BOOL"},"Stepper.In.RIO_MOVE":{"type":"BOOL"},"Stepper.In.Feedback_speed":{"type":"DINT"},"Stepper.In.Torque_monitor":{"type":"INT"},"Stepper.In.Feedback_position":{"type":"DINT"},"Stepper.In.CST_operating_current":{"type":"INT"},"Stepper.In.Present_alarm":{"type":"INT"}}}},{"id":"954e3ebf35b76646","type":"ui_group","name":"Motor","tab":"2252da75f5c867c7","order":1,"disp":true,"width":20,"collapse":false,"className":""},{"id":"2252da75f5c867c7","type":"ui_tab","name":"Motor test","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

To setup email node, please refer to the following tutorial:

https://www.youtube.com/watch?v=DaY8Q9rNbq4

Send me an email if you need json import file, PLC project file or if you have any doubt.

etp94@outlook.com
Tebi

2 Likes