DavidOtt

MrPLC Member
  • Content count

    18
  • Joined

  • Last visited

Community Reputation

0 Neutral

About DavidOtt

  • Rank
    Sparky

Profile Information

  • Gender
  • Country Hungary
  • Interests nodejs electron Mitsubishi MELSEC iQ-F FX5
  1. Mitsubishi FX5 read/write from PC with nodejs

    Hi @AndreasW  Thank you for your advice. You wrote if value > 255 it should be in hexa. The buffer starts with 0x01, 0xFF, 0x0A, 0x00. Why 10 is written in hexa as 0x0A? It's less then 255. Also the R19999 register: 0x1F, 0x4E, 0x00, 0x00, 0x20, 0x52, where the R is 5220 which is larger than 255, but it was just split up and swapped. For 19999, hexa is used. I realized that I have to use Test(Wrandom Write) as you recommended too. I need to use registers R19990~R19999, but I cannot overwrite data in register with 0x00, I should leave data in register if there is data. I need to create 3 different writings: 1. machine 1 is used write to R19990~R19992 and R19999 or 2. machine 2 is used write to R19993~R19995 and R19999 or 3. 1 and 2 machines are used together write to R19996~R19999. If R19990~R19992 and R19999 is written, app should not overwrite data in R19993~R19998 I.e if input1 = 22, input2 = 40, input3 = 04 and machineUsed = 1 I cannot do this: new Buffer.from([0x03, 0xFF, 0x0A, 0x00, 0x16, 0x4E, 0x00, 0x00, 0x20, 0x52, 0x10, 0x00, 0x22 (input1), 0x40 (input2), 0x04 (input3), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 (machineUsed)]); On page 133 in FX5 documentation it is not clear for me if R19990~R19992 and R19999 is written: Number of devices for this example would be (R19990~R19992 and R19999) 2(?) or (R19990 and R19991 and R19992 and R19999) 4(?) My Test(Wrandom Write) would be as on page 133 and as I thought: new Buffer.from([0x05(subheader), 0xFF(PC No.), 0x0A, 0x00 (monitoring time in 2 parts), 0x04(number of devices?), 0x00 (fixed value),0x16, 0x4E, 0x00, 0x00 (head dev.# in 4 parts), 0x20, 0x52 (device name in 2 part), 0x00, 0x22 (input1 in 2 parts), 0x17, 0x4E, 0x00, 0x00 (head dev.# in 4 parts), 0x20, 0x52 (device name in 2 parts), 0x00, 0x40 (input2 in 2 parts), 0x18, 0x4E, 0x00, 0x00 (head dev.# in 4 parts), 0x20, 0x52 (device name in 2 parts), 0x00, 0x04(input3 in 2 parts),0x1F, 0x4E, 0x00, 0x00 (head dev.# in 4 parts), 0x20, 0x52 (device name in 2 parts), 0x00, 0x01(machineUsed in 2 parts),]);  
  2. Mitsubishi FX5 read/write from PC with nodejs

    Hi @AndreasW It's working. Thank you very much. I'm trying the same way wirting to PLC. So far this is what I have: I need to write 2-2-2 digits numbers to R19990~R19992, numbers are between 0-99 in decimal. ```var writeBuffer = new Buffer.from([0x03, 0xFF, 0x0A, 0x00, 0x16, 0x4E, 0x00, 0x00, 0x20, 0x52, 0x03, 0x00, input1format, input2format, input3format]);``` Where input1format (2,3 too) are string: '0x0'+input if input length is 1 and if input length is 2: '0x'+input. Input is the hexadecimal conversion of the 2-2-2 digits. I also need to write to R19999(writeMachineBuffer), I don't know if I can do that together with R19990~R19992 writing. So I would have 2 client.write. One with writeBuffer and another one with writeMachineBuffer. Can I do that or I should write once from R19990~R19999 and having 0x00 for R19993~R19998. Thank you for all your help.
  3. Mitsubishi FX5 read/write from PC with nodejs

    Hi @AndreasW  If I use your lines above (sndBuff, I changed at client.write(sndBuffer) to sndBuff)  the app receives data from PLC => Buffer.from(data) = 129,86. These 2 numbers are received. Do you know how I can convert to the original data as in PLC? Thank you
  4. Mitsubishi FX5 read/write from PC with nodejs

    @AndreasW I put the received data into Buffer. I got numbers:  176,91,16.This is frame message in binary code, not the stored data I guess. This is my request string: 01FF000A522000004E200900. I attached photo of the PLC settings what it should read and you can see what the received data was when PLC was set to ASCII. Now with binary I got above 3 numbers. Do you know how I can convert the numbers to get the numbers in PLC's current values column? Thank you
  5. Mitsubishi FX5 read/write from PC with nodejs

    @AndreasW I got screenshot of the ethernet configuration. The port 1025 where PC should connect. If PLC is set to binary, the log shows that PC connected to PLC, but PC does not receive string started with 8100, but 3 symbols (no more data). Do you know where is the problem? Thank you for your help.
  6. Mitsubishi FX5 read/write from PC with nodejs

    @AndreasW Thank you for your reply. I got screenshot of the PLC settings where communication data code was changed from ascii to binary. Does this tell you where I miss the reading command to work well?
  7. Mitsubishi FX5 read/write from PC with nodejs

    @AndreasW Hello again, I got far with your info. Thank you. However, I stuck again. All went fine with reading string as you recommended in ascii format. Now that more parts are set together in the system, PLC got robot and HMI. With such a setup in ascii format, the robot and HMI cannot communicate with PLC, but only PC can. So system needs to be changed to binary format. Now that I understand more, your above info gave me new information:  Using the binary version is also be possible, but would be a little bit more complicated, because you can't use the net.Socket.write() function. In this case you would have to build the senddata byte by byte and you have to care about endianess so using the ascii version is easier. I need to change the reading request to binary. Can you please send information how to form such request?
  8. Mitsubishi FX5 read/write from PC with nodejs

    Thank you Thank you Thank you. It's working. I really appreciate your help.  One more question, is it possible to reach the PLC's sd card through such a connection? Thank you again!
  9. Mitsubishi FX5 read/write from PC with nodejs

    With your code it gave me this result (D2050 is read its value in PLC is 133, this string is 500000FF03FF000018000004010000D*0020500001): 1. 'disconnect from plc, terminate connection' 2. 'error: timeout occured, no data received for last ReadRequest' 3. 'send Request to plc....' 4. Data received from the plc: D00000FF03FF00000800000085 And then 3 and 4 repeats Can you please advise what this means? Your request string is different. Shall I try that string? What would be your string to read D2050?    
  10. Mitsubishi FX5 read/write from PC with nodejs

    Thank you very much for your help. It connected to PLC and I could read data from PLC. I still have issues, but I need to solve it by testing different codes. FX5U needs different string line, same as here https://www.c-sharpcorner.com/UploadFile/asmabegam/plc-communication-using-net/ Do you have experience with such a connection? If I use your code the sequence is like: 1. it connects to PLC 2. sends the string and 3. closes connection. If PLC register (ie new value in D10) is updated when app is running, then it shows the data ( console.log('Connection closed'); and then console.log('Received: ' + data); ).  I need to monitor the PLC, hence I need to check its registers if new data is stored there. I should make a while loop for connection and I would break connection if data string (stored data from PLC) ends with 'exit'. Until that it should check every 2-3 seconds for new data (it should send client.write to PLC to read the registers).  
  11. Mitsubishi FX5 read/write from PC with nodejs

    Thank you for your advise and wishes. Is Node-RED a programming app? On npm (https://www.npmjs.com/package/node-red-contrib-mcprotocol), it didn't show code snippet. Is it working on PC as a web browser based app that communicates with PLC (I open web browser and connect to PLC with http address)? The PC side coding (html, server) is done in Node-RED? I checked Node-RED before and I saw it has its own ui with palette and flow window.
  12. Mitsubishi FX5 read/write from PC with nodejs

    I understood the same when you wrote PLC version should be checked in order to make mc protocol work. What confused me that MC is a protocol and SLMP is also a protocol. I found in the link you wrote: The message format of each SLMP is the same as that of the following MC protocols frames. • 3E frame: QnA compatible 3E frame of MC protocol • 1E frame: A compatible 1E frame of MC protocol The external devices used with the above MC protocols can be connected to SLMP compatible devices.   So If I understood well, the nodejs net format (client.write('ASCII format string')) is compatible to MC protocol so with that a communication channel can be established to a PLC that is SLMP compatible.
  13. Mitsubishi FX5 read/write from PC with nodejs

    Sounds very promising, I will write the code. However, I have problems with definitions. You wrote check version "otherwise mc-protocol" won't work and at the end you wrote "for nodejs you only need the net module". Why should I check if mc protocol can work based on version? I won't use the mc-protocol module if I need only the net module. You also wrote "Add an SLMP connection". I thought it is a different protocol, other than MC. In nodejs code you wrote:  client.write('01FF000A44200000000A0200');      // read D10,D11  Client.write is not a writing command? Because you wrote in comment: // read D10,D11  Nevertheless, I prepare app with your nodejs codes. Thank you for your help.
  14. Mitsubishi FX5 read/write from PC with nodejs

    Can you help me please? The PLC serial number is 2010516. The MC protocol package (https://github.com/plcpeople/mcprotocol) uses 1E frame (I don't know what this means). If I cannot use this package I would write code with socket as you recommended. I can connect to host, but I do not know the syntax for ASCII string. Can you please give some ASCII string example for read and write? I had a test with MC protocol app. Unfortunately, it did not connect. However, my partner said that PLC is in SLMP. My app uses MC protocol. Do you think this can cause connection error? I found a site https://www.codeproject.com/Articles/616262/PLC-Communication-Using-NET it shows ascii strings like this  500000FF03FF00001C000A14010000D*0095010002  where 1401 and 00950 refer to writing and D is the device code. I don't know if I should use such a string. And I also don't know what is the data in this string?
  15. Mitsubishi FX5 read/write from PC with nodejs

    Can you help me please? The PLC serial number is 2010516. The MC protocol package (https://github.com/plcpeople/mcprotocol) uses 1E frame (I don't know what this means). If I cannot use this package I would write code with socket as you recommended. I can connect to host, but I do not know the syntax for ASCII string. Can you please give some ASCII string example for read and write?