question

nada avatar image
0 Likes"
nada asked Julie Weller edited

connection nodered and flexsim without modbus simulator

hey everyone . i was able to connect flexsim to node red but with the use of modbus simulator as intermidiate . can anyone have any sollution to connect nodered to flexsim without the use of intermidiate . !

flexsimnoderdmodbus.7z

FlexSim 23.1.2
connection
· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Luciano Cavallero avatar image
0 Likes"
Luciano Cavallero answered

Hi,

I taken a look the your video.

To connect Flexsim to node-red directly I installed the 'node-red-contrib-modbus' palette. This palette provide a set of nodes to read/write data using modbus and a node to create a modbus server.

Below a JSON of a simple flow that create a server and write a coil (manually): this coil's changes can be read by FlexSim using the a Modbus TCP control variable.

Copy this code and import in your node-red.
Let me know if this solve your question.

  1. [
  2. {
  3. "id": "516f34a37fd9ca8f",
  4. "type": "tab",
  5. "label": "Flow 1",
  6. "disabled": false,
  7. "info": "",
  8. "env": []
  9. },
  10. {
  11. "id": "b1087276c245dd59",
  12. "type": "modbus-server",
  13. "z": "516f34a37fd9ca8f",
  14. "name": "local Modbus server",
  15. "logEnabled": true,
  16. "hostname": "0.0.0.0",
  17. "serverPort": 10502,
  18. "responseDelay": 100,
  19. "delayUnit": "ms",
  20. "coilsBufferSize": "1024",
  21. "holdingBufferSize": "1024",
  22. "inputBufferSize": "1024",
  23. "discreteBufferSize": "1024",
  24. "showErrors": true,
  25. "x": 260,
  26. "y": 180,
  27. "wires": [
  28. [
  29. "2e4504ae37d46948"
  30. ],
  31. [
  32. "06a20a26617f8155"
  33. ],
  34. [
  35. "8ef2824f128f9705"
  36. ],
  37. [
  38. "114eb13f974d836c"
  39. ],
  40. [
  41. "be48a0148fd15ed5"
  42. ]
  43. ]
  44. },
  45. {
  46. "id": "d85a3e8499f06b3b",
  47. "type": "modbus-write",
  48. "z": "516f34a37fd9ca8f",
  49. "name": "",
  50. "showStatusActivities": false,
  51. "showErrors": false,
  52. "showWarnings": true,
  53. "unitid": "1",
  54. "dataType": "Coil",
  55. "adr": "1",
  56. "quantity": "1",
  57. "server": "db6f9b3e.e5f338",
  58. "emptyMsgOnFail": false,
  59. "keepMsgProperties": false,
  60. "delayOnStart": false,
  61. "startDelayTime": "",
  62. "x": 320,
  63. "y": 380,
  64. "wires": [
  65. [
  66. "8bd5cac1c87591b3"
  67. ],
  68. [
  69. "4b70615abbb827b9"
  70. ]
  71. ]
  72. },
  73. {
  74. "id": "8bd5cac1c87591b3",
  75. "type": "debug",
  76. "z": "516f34a37fd9ca8f",
  77. "name": "debug 1 write FALSE ",
  78. "active": true,
  79. "tosidebar": true,
  80. "console": false,
  81. "tostatus": false,
  82. "complete": "payload",
  83. "targetType": "msg",
  84. "statusVal": "",
  85. "statusType": "auto",
  86. "x": 580,
  87. "y": 360,
  88. "wires": []
  89. },
  90. {
  91. "id": "4b70615abbb827b9",
  92. "type": "debug",
  93. "z": "516f34a37fd9ca8f",
  94. "name": "debug 2 write FALSE",
  95. "active": true,
  96. "tosidebar": true,
  97. "console": false,
  98. "tostatus": false,
  99. "complete": "payload",
  100. "targetType": "msg",
  101. "statusVal": "",
  102. "statusType": "auto",
  103. "x": 580,
  104. "y": 400,
  105. "wires": []
  106. },
  107. {
  108. "id": "2e4504ae37d46948",
  109. "type": "debug",
  110. "z": "516f34a37fd9ca8f",
  111. "name": "debug 3",
  112. "active": true,
  113. "tosidebar": true,
  114. "console": false,
  115. "tostatus": false,
  116. "complete": "false",
  117. "statusVal": "",
  118. "statusType": "auto",
  119. "x": 440,
  120. "y": 120,
  121. "wires": []
  122. },
  123. {
  124. "id": "06a20a26617f8155",
  125. "type": "debug",
  126. "z": "516f34a37fd9ca8f",
  127. "name": "debug 4",
  128. "active": true,
  129. "tosidebar": true,
  130. "console": false,
  131. "tostatus": false,
  132. "complete": "false",
  133. "statusVal": "",
  134. "statusType": "auto",
  135. "x": 440,
  136. "y": 180,
  137. "wires": []
  138. },
  139. {
  140. "id": "8ef2824f128f9705",
  141. "type": "debug",
  142. "z": "516f34a37fd9ca8f",
  143. "name": "debug 5",
  144. "active": true,
  145. "tosidebar": true,
  146. "console": false,
  147. "tostatus": false,
  148. "complete": "false",
  149. "statusVal": "",
  150. "statusType": "auto",
  151. "x": 440,
  152. "y": 220,
  153. "wires": []
  154. },
  155. {
  156. "id": "114eb13f974d836c",
  157. "type": "debug",
  158. "z": "516f34a37fd9ca8f",
  159. "name": "debug 6",
  160. "active": true,
  161. "tosidebar": true,
  162. "console": false,
  163. "tostatus": false,
  164. "complete": "false",
  165. "statusVal": "",
  166. "statusType": "auto",
  167. "x": 440,
  168. "y": 260,
  169. "wires": []
  170. },
  171. {
  172. "id": "be48a0148fd15ed5",
  173. "type": "debug",
  174. "z": "516f34a37fd9ca8f",
  175. "name": "debug 7",
  176. "active": true,
  177. "tosidebar": true,
  178. "console": false,
  179. "tostatus": false,
  180. "complete": "false",
  181. "statusVal": "",
  182. "statusType": "auto",
  183. "x": 440,
  184. "y": 300,
  185. "wires": []
  186. },
  187. {
  188. "id": "e620fa03c581a662",
  189. "type": "inject",
  190. "z": "516f34a37fd9ca8f",
  191. "name": "",
  192. "props": [
  193. {
  194. "p": "payload"
  195. },
  196. {
  197. "p": "topic",
  198. "vt": "str"
  199. }
  200. ],
  201. "repeat": "",
  202. "crontab": "",
  203. "once": false,
  204. "onceDelay": 0.1,
  205. "topic": "",
  206. "payload": "false",
  207. "payloadType": "bool",
  208. "x": 110,
  209. "y": 360,
  210. "wires": [
  211. [
  212. "d85a3e8499f06b3b"
  213. ]
  214. ]
  215. },
  216. {
  217. "id": "e1bcd02cea0c7a7e",
  218. "type": "inject",
  219. "z": "516f34a37fd9ca8f",
  220. "name": "",
  221. "props": [
  222. {
  223. "p": "payload"
  224. },
  225. {
  226. "p": "topic",
  227. "vt": "str"
  228. }
  229. ],
  230. "repeat": "",
  231. "crontab": "",
  232. "once": false,
  233. "onceDelay": 0.1,
  234. "topic": "",
  235. "payload": "true",
  236. "payloadType": "bool",
  237. "x": 90,
  238. "y": 180,
  239. "wires": [
  240. [
  241. "b1087276c245dd59"
  242. ]
  243. ]
  244. },
  245. {
  246. "id": "281b06d6960c9eb7",
  247. "type": "debug",
  248. "z": "516f34a37fd9ca8f",
  249. "name": "debug 2 write TRUE",
  250. "active": true,
  251. "tosidebar": true,
  252. "console": false,
  253. "tostatus": false,
  254. "complete": "payload",
  255. "targetType": "msg",
  256. "statusVal": "",
  257. "statusType": "auto",
  258. "x": 580,
  259. "y": 520,
  260. "wires": []
  261. },
  262. {
  263. "id": "edb022239470c36c",
  264. "type": "modbus-write",
  265. "z": "516f34a37fd9ca8f",
  266. "name": "",
  267. "showStatusActivities": false,
  268. "showErrors": false,
  269. "showWarnings": true,
  270. "unitid": "1",
  271. "dataType": "Coil",
  272. "adr": "1",
  273. "quantity": "1",
  274. "server": "db6f9b3e.e5f338",
  275. "emptyMsgOnFail": false,
  276. "keepMsgProperties": false,
  277. "delayOnStart": false,
  278. "startDelayTime": "",
  279. "x": 320,
  280. "y": 500,
  281. "wires": [
  282. [
  283. "9a90992d12a3d8eb"
  284. ],
  285. [
  286. "281b06d6960c9eb7"
  287. ]
  288. ]
  289. },
  290. {
  291. "id": "9a90992d12a3d8eb",
  292. "type": "debug",
  293. "z": "516f34a37fd9ca8f",
  294. "name": "debug 1 write TRUE",
  295. "active": true,
  296. "tosidebar": true,
  297. "console": false,
  298. "tostatus": false,
  299. "complete": "payload",
  300. "targetType": "msg",
  301. "statusVal": "",
  302. "statusType": "auto",
  303. "x": 580,
  304. "y": 480,
  305. "wires": []
  306. },
  307. {
  308. "id": "83642f64bbd72459",
  309. "type": "inject",
  310. "z": "516f34a37fd9ca8f",
  311. "name": "",
  312. "props": [
  313. {
  314. "p": "payload"
  315. },
  316. {
  317. "p": "topic",
  318. "vt": "str"
  319. }
  320. ],
  321. "repeat": "",
  322. "crontab": "",
  323. "once": false,
  324. "onceDelay": 0.1,
  325. "topic": "",
  326. "payload": "true",
  327. "payloadType": "bool",
  328. "x": 110,
  329. "y": 480,
  330. "wires": [
  331. [
  332. "edb022239470c36c"
  333. ]
  334. ]
  335. },
  336. {
  337. "id": "db6f9b3e.e5f338",
  338. "type": "modbus-client",
  339. "name": "local",
  340. "clienttype": "tcp",
  341. "bufferCommands": true,
  342. "stateLogEnabled": false,
  343. "tcpHost": "127.0.0.1",
  344. "tcpPort": "10502",
  345. "tcpType": "DEFAULT",
  346. "serialPort": "/dev/ttyUSB",
  347. "serialType": "RTU-BUFFERD",
  348. "serialBaudrate": "9600",
  349. "serialDatabits": "8",
  350. "serialStopbits": "1",
  351. "serialParity": "none",
  352. "serialConnectionDelay": "100",
  353. "unit_id": 1,
  354. "commandDelay": 1,
  355. "clientTimeout": 1000,
  356. "reconnectTimeout": 2000
  357. }
  358. ]



5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.